angel_seo 1.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new57

seo

Pub build status

Helpers for building SEO-friendly Web pages in Angel. The goal of package:angel_seo is to speed up perceived client page loads, prevent the infamous flash of unstyled content, and other SEO optimizations that can easily become tedious to perform by hand.

inlineAssets

A response finalizer that can be used in any application to patch HTML responses, including those sent with a templating engine like Jael.

In any text/html response sent down, link and script elements that point to internal resources will have the contents of said file read, and inlined into the HTML page itself.

In this case, "internal resources" refers to a URI without a scheme, i.e. /site.css or foo/bar/baz.js.

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
import 'package:file/local.dart';

main() async {
  var app = new Angel()..lazyParseBodies = true;
  var fs = const LocalFileSystem();
  var http = new AngelHttp(app);

  app.responseFinalizers.add(inlineAssets(fs.directory('web')));

  app.use(() => throw new AngelHttpException.notFound());

  var server = await http.startServer('127.0.0.1', 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}

inlineAssetsFromVirtualDirectory

This function is a simple one; it wraps a VirtualDirectory to patch the way it sends .html files.

Produces the same functionality as inlineAssets.

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
import 'package:file/local.dart';

main() async {
  var app = new Angel()..lazyParseBodies = true;
  var fs = const LocalFileSystem();
  var http = new AngelHttp(app);

  var vDir = inlineAssets(
    new VirtualDirectory(
      app,
      fs,
      source: fs.directory('web'),
    ),
  );

  app.use(vDir.handleRequest);

  app.use(() => throw new AngelHttpException.notFound());

  var server = await http.startServer('127.0.0.1', 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}

1.0.0

  • Initial release.

example/main.dart

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
import 'package:dart2_constant/convert.dart';
import 'package:file/local.dart';

main() async {
  var app = new Angel()..lazyParseBodies = true;
  var fs = const LocalFileSystem();
  var http = new AngelHttp(app);

  // You can wrap a [VirtualDirectory]
  var vDir = inlineAssetsFromVirtualDirectory(
    new VirtualDirectory(
      app,
      fs,
      source: fs.directory('web'),
    ),
  );

  app.use(vDir.handleRequest);

  // OR, just add a finalizer. Note that [VirtualDirectory] *streams* its response,
  // so a response finalizer does not touch its contents.
  //
  // You likely won't need to use both; it just depends on your use case.
  app.responseFinalizers.add(inlineAssets(fs.directory('web')));

  app.get('/using_response_buffer', (ResponseContext res) async {
    var indexHtml = fs.directory('web').childFile('index.html');
    var contents = await indexHtml.readAsString();
    res
      ..headers['content-type'] = 'text/html; charset=utf-8'
      ..buffer.add(utf8.encode(contents));
  });

  app.use(() => throw new AngelHttpException.notFound());

  var server = await http.startServer('127.0.0.1', 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_seo: "^1.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:angel_seo/angel_seo.dart';
  
Version Uploaded Documentation Archive
1.0.0 Jul 9, 2018 Go to the documentation of angel_seo 1.0.0 Download angel_seo 1.0.0 archive

Analysis

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
13 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
57
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_seo/angel_seo.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
angel_framework ^1.0.0-dev 1.1.5
angel_static ^1.3.0 1.3.0+1
dart2_constant ^1.0.0 1.0.1+dart2
file ^2.0.0 2.3.7 5.0.1
html ^0.13.0 0.13.3+1
path ^1.0.0 1.6.1
Transitive dependencies
angel_http_exception 1.0.0+3
angel_model 1.0.0
angel_route 2.0.7
args 1.4.3
async 2.0.7
body_parser 1.1.0
charcode 1.1.2
code_buffer 1.0.1
collection 1.14.10
combinator 1.0.0+3
container 0.1.2
csslib 0.14.4
http_parser 3.1.2
http_server 0.9.8
intl 0.15.6
json_god 2.0.0-beta+3
logging 0.11.3+1
matcher 0.12.3
merge_map 1.0.0
meta 1.1.5
mime 0.9.6+1
pool 1.3.5
quiver_hashcode 1.0.0
random_string 0.0.1
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
tuple 1.0.1
typed_data 1.1.5
utf 0.9.0+4
Dev dependencies
angel_test ^1.0.0
test ^0.12.0