From ee3c087ef526c2899e301dae21559db70b0c22de Mon Sep 17 00:00:00 2001 From: thomashii Date: Fri, 20 Aug 2021 10:33:49 +0800 Subject: [PATCH] Updated seo --- packages/seo/CHANGELOG.md | 18 +++-- packages/seo/LICENSE | 6 +- packages/seo/README.md | 66 +++++++++---------- packages/seo/example/main.dart | 8 +-- .../lib/{angel_seo.dart => angel3_seo.dart} | 0 packages/seo/lib/src/inline_assets.dart | 4 +- packages/seo/pubspec.yaml | 28 +++----- packages/seo/test/inline_assets_test.dart | 8 +-- 8 files changed, 66 insertions(+), 72 deletions(-) rename packages/seo/lib/{angel_seo.dart => angel3_seo.dart} (100%) diff --git a/packages/seo/CHANGELOG.md b/packages/seo/CHANGELOG.md index 782aa377..9aa1a3d6 100644 --- a/packages/seo/CHANGELOG.md +++ b/packages/seo/CHANGELOG.md @@ -1,8 +1,18 @@ -# 3.0.0 +# Change Log + +## 4.0.0 + +* Updated to use `angel3` packages +* Published with `angel3` prefix + +## 3.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 2.0.0 +## 2.0.0 + * Angel 2 updates. -# 1.0.0 -* Initial release. \ No newline at end of file +## 1.0.0 + +* Initial release. diff --git a/packages/seo/LICENSE b/packages/seo/LICENSE index f8e6088a..8f65b579 100644 --- a/packages/seo/LICENSE +++ b/packages/seo/LICENSE @@ -1,6 +1,6 @@ -MIT License +MIT License (MIT) -Copyright (c) 2018 The Angel Framework +Copyright (c) 2021 dukefirehawk.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/packages/seo/README.md b/packages/seo/README.md index 4b64712e..9854e3de 100644 --- a/packages/seo/README.md +++ b/packages/seo/README.md @@ -1,14 +1,16 @@ -# seo -[![Pub](https://img.shields.io/pub/v/angel_seo.svg)](https://pub.dartlang.org/packages/angel_seo) -[![build status](https://travis-ci.org/angel-dart/seo.svg?branch=master)](https://travis-ci.org/angel-dart/seo) +# Angel3 SEO -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](https://en.wikipedia.org/wiki/Flash_of_unstyled_content), -and other SEO optimizations that can easily become tedious to perform by hand. +[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_seo) +[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) +[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) + +[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/seo/LICENSE) + +Helpers for building SEO-friendly Web pages in Angel. The goal of `package:angel3_seo` is to speed up perceived client page loads, prevent +the infamous [flash of unstyled content](https://en.wikipedia.org/wiki/Flash_of_unstyled_content), and other SEO optimizations that can easily become tedious to perform by hand. ## Disabling inlining per-element + Add a `data-no-inline` attribute to a `link` or `script` to prevent inlining it: ```html @@ -16,31 +18,27 @@ Add a `data-no-inline` attribute to a `link` or `script` to prevent inlining it: ``` ## `inlineAssets` -A -[response finalizer](https://angel-dart.gitbook.io/angel/the-basics/request-lifecycle) -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. +A [response finalizer](https://angel3-docs.dukefirehawk.com/guides/request-lifecycle) that can be used in any application to patch HTML responses, including those sent with a templating engine like Jael3. -In this case, "internal resources" refers to a URI *without* a scheme, i.e. `/site.css` or -`foo/bar/baz.js`. +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`. ```dart -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_seo/angel_seo.dart'; -import 'package:angel_static/angel_static.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_seo/angel3_seo.dart'; +import 'package:angel3_static/angel3_static.dart'; import 'package:file/local.dart'; -main() async { - var app = new Angel()..lazyParseBodies = true; +void main() async { + var app = Angel()..lazyParseBodies = true; var fs = const LocalFileSystem(); - var http = new AngelHttp(app); + var http = AngelHttp(app); app.responseFinalizers.add(inlineAssets(fs.directory('web'))); - app.use(() => throw new AngelHttpException.notFound()); + app.use(() => throw AngelHttpException.notFound()); var server = await http.startServer('127.0.0.1', 3000); print('Listening at http://${server.address.address}:${server.port}'); @@ -48,24 +46,22 @@ main() async { ``` ## `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`. +This function is a simple one; it wraps a `VirtualDirectory` to patch the way it sends `.html` files. Produces the same functionality as `inlineAssets`. ```dart -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_seo/angel_seo.dart'; -import 'package:angel_static/angel_static.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_seo/angel3_seo.dart'; +import 'package:angel3_static/angel3_static.dart'; import 'package:file/local.dart'; -main() async { - var app = new Angel()..lazyParseBodies = true; +void main() async { + var app = Angel()..lazyParseBodies = true; var fs = const LocalFileSystem(); - var http = new AngelHttp(app); + var http = AngelHttp(app); var vDir = inlineAssets( - new VirtualDirectory( + VirtualDirectory( app, fs, source: fs.directory('web'), @@ -74,9 +70,9 @@ main() async { app.use(vDir.handleRequest); - app.use(() => throw new AngelHttpException.notFound()); + app.use(() => throw AngelHttpException.notFound()); var server = await http.startServer('127.0.0.1', 3000); print('Listening at http://${server.address.address}:${server.port}'); } -``` \ No newline at end of file +``` diff --git a/packages/seo/example/main.dart b/packages/seo/example/main.dart index 9bd25ecf..3ca4644b 100644 --- a/packages/seo/example/main.dart +++ b/packages/seo/example/main.dart @@ -1,8 +1,8 @@ import 'dart:convert'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_seo/angel_seo.dart'; -import 'package:angel_static/angel_static.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; +import 'package:angel3_seo/angel3_seo.dart'; +import 'package:angel3_static/angel3_static.dart'; import 'package:file/local.dart'; import 'package:http_parser/http_parser.dart'; diff --git a/packages/seo/lib/angel_seo.dart b/packages/seo/lib/angel3_seo.dart similarity index 100% rename from packages/seo/lib/angel_seo.dart rename to packages/seo/lib/angel3_seo.dart diff --git a/packages/seo/lib/src/inline_assets.dart b/packages/seo/lib/src/inline_assets.dart index 3d70362d..63e7863d 100644 --- a/packages/seo/lib/src/inline_assets.dart +++ b/packages/seo/lib/src/inline_assets.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:convert'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_static/angel_static.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_static/angel3_static.dart'; import 'package:file/file.dart'; import 'package:html/dom.dart' as html; import 'package:html/parser.dart' as html; diff --git a/packages/seo/pubspec.yaml b/packages/seo/pubspec.yaml index ff9dbf1e..a02bdb9c 100644 --- a/packages/seo/pubspec.yaml +++ b/packages/seo/pubspec.yaml @@ -1,31 +1,19 @@ -name: angel_seo -version: 2.0.0 -description: Helper infrastructure for building SEO-friendly Web backends in Angel. -homepage: https://github.com/angel-dart/seo -publish_to: none +name: angel3_seo +version: 4.0.0 +description: Helper infrastructure for building SEO-friendly Web backends in Angel3. +homepage: https://angel3-framework.web.app/ +repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/seo environment: sdk: '>=2.12.0 <3.0.0' dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - angel_static: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/static + angel3_framework: ^4.1.0 + angel3_static: ^4.0.0 file: ^6.1.2 html: ^0.15.0 http_parser: ^4.0.0 path: ^1.8.0 dev_dependencies: - angel_test: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/test + angel3_test: ^4.0.0 logging: ^1.0.1 test: ^1.17.8 pedantic: ^1.11.1 \ No newline at end of file diff --git a/packages/seo/test/inline_assets_test.dart b/packages/seo/test/inline_assets_test.dart index 19429cc6..79dde2ab 100644 --- a/packages/seo/test/inline_assets_test.dart +++ b/packages/seo/test/inline_assets_test.dart @@ -1,7 +1,7 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_seo/angel_seo.dart'; -import 'package:angel_static/angel_static.dart'; -import 'package:angel_test/angel_test.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_seo/angel3_seo.dart'; +import 'package:angel3_static/angel3_static.dart'; +import 'package:angel3_test/angel3_test.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:html/dom.dart' as html;