Migrated markdown
This commit is contained in:
parent
3906c64fc6
commit
c68e1c2216
8 changed files with 56 additions and 39 deletions
|
@ -93,7 +93,7 @@ Check out [Migrating to Angel3](https://angel3-docs.dukefirehawk.com/migration/a
|
|||
|
||||
## Examples and Documentation
|
||||
|
||||
Visit the [documentation](https://angel3-docs.dukefirehawk.com/) for dozens of guides and resources, including video tutorials, to get up and running as quickly as possible with Angel.
|
||||
Visit the [documentation](https://angel3-docs.dukefirehawk.com/) for dozens of guides and resources, including video tutorials, to get up and running as quickly as possible with Angel3 framework.
|
||||
|
||||
Examples and complete projects can be found [here](https://github.com/dukefirehawk/angel3-examples).
|
||||
|
||||
|
|
|
@ -108,8 +108,13 @@ class AngelAuth<User> {
|
|||
'An `AngelAuth` plug-in was called without its `deserializer` being set. All authentication will fail.');
|
||||
}
|
||||
*/
|
||||
|
||||
if (app.container == null) {
|
||||
log.severe('Angel.container is null.');
|
||||
throw StateError(
|
||||
'Angel.container is null. All authentication will fail.');
|
||||
}
|
||||
var appContainer = app.container!;
|
||||
|
||||
appContainer.registerSingleton(this);
|
||||
if (runtimeType != AngelAuth) {
|
||||
appContainer.registerSingleton(this, as: AngelAuth);
|
||||
|
@ -132,14 +137,14 @@ class AngelAuth<User> {
|
|||
}
|
||||
});
|
||||
|
||||
appContainer.registerLazySingleton<Future<User>>((container) async {
|
||||
appContainer.registerLazySingleton<Future<User?>>((container) async {
|
||||
var result = await container.makeAsync<_AuthResult<User>>();
|
||||
return result!.user;
|
||||
return result?.user;
|
||||
});
|
||||
|
||||
appContainer.registerLazySingleton<Future<AuthToken>>((container) async {
|
||||
appContainer.registerLazySingleton<Future<AuthToken?>>((container) async {
|
||||
var result = await container.makeAsync<_AuthResult<User>>();
|
||||
return result!.token;
|
||||
return result?.token;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -151,7 +156,13 @@ class AngelAuth<User> {
|
|||
}
|
||||
|
||||
void _apply(
|
||||
RequestContext req, ResponseContext? res, AuthToken token, User user) {
|
||||
RequestContext req, ResponseContext res, AuthToken token, User user) {
|
||||
if (req.container == null) {
|
||||
log.severe('RequestContext.container is null.');
|
||||
throw StateError(
|
||||
'RequestContext.container is not set. All authentication will fail.');
|
||||
}
|
||||
|
||||
var reqContainer = req.container!;
|
||||
if (!reqContainer.has<User>()) {
|
||||
reqContainer.registerSingleton<User>(user);
|
||||
|
@ -162,7 +173,7 @@ class AngelAuth<User> {
|
|||
}
|
||||
|
||||
if (allowCookie) {
|
||||
_addProtectedCookie(res!, 'token', token.serialize(_hs256));
|
||||
_addProtectedCookie(res, 'token', token.serialize(_hs256));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +199,7 @@ class AngelAuth<User> {
|
|||
/// }
|
||||
/// ```
|
||||
@deprecated
|
||||
Future decodeJwt(RequestContext req, ResponseContext res) async {
|
||||
Future decodeJwtOld(RequestContext req, ResponseContext res) async {
|
||||
if (req.method == 'POST' && req.path == reviveTokenEndpoint) {
|
||||
return await reviveJwt(req, res);
|
||||
} else {
|
||||
|
@ -231,18 +242,23 @@ class AngelAuth<User> {
|
|||
/// Retrieves a JWT from a request, if any was sent at all.
|
||||
String? getJwt(RequestContext req) {
|
||||
if (req.headers?.value('Authorization') != null) {
|
||||
final authHeader = req.headers!.value('Authorization')!;
|
||||
|
||||
// Allow Basic auth to fall through
|
||||
if (_rgxBearer.hasMatch(authHeader)) {
|
||||
return authHeader.replaceAll(_rgxBearer, '').trim();
|
||||
final authHeader = req.headers?.value('Authorization');
|
||||
if (authHeader != null) {
|
||||
// Allow Basic auth to fall through
|
||||
if (_rgxBearer.hasMatch(authHeader)) {
|
||||
return authHeader.replaceAll(_rgxBearer, '').trim();
|
||||
}
|
||||
}
|
||||
|
||||
log.info('RequestContext.headers is null');
|
||||
} else if (allowCookie &&
|
||||
req.cookies.any((cookie) => cookie.name == 'token')) {
|
||||
return req.cookies.firstWhere((cookie) => cookie.name == 'token').value;
|
||||
} else if (allowTokenInQuery &&
|
||||
req.uri?.queryParameters['token'] is String) {
|
||||
return req.uri!.queryParameters['token']?.toString();
|
||||
} else if (allowTokenInQuery) {
|
||||
//&& req.uri?.queryParameters['token'] is String) {
|
||||
if (req.uri != null) {
|
||||
return req.uri?.queryParameters['token']?.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -19,9 +19,4 @@ dev_dependencies:
|
|||
logging: ^1.0.0
|
||||
pedantic: ^1.11.0
|
||||
test: ^1.17.4
|
||||
#dependency_overrides:
|
||||
# angel3_framework:
|
||||
# path: ../framework
|
||||
# angel3_container:
|
||||
# path: ../container/angel_container
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
# Change Log
|
||||
|
||||
## 3.0.0
|
||||
## 4.0.0
|
||||
|
||||
* Migrated to support Dart SDK 2.12.x NNBD
|
||||
|
||||
## 3.0.0
|
||||
|
||||
* Migrated to support Dart SDK 2.12.x non NNBD
|
||||
|
||||
## 2.0.0
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Angel3 Markdown
|
||||
|
||||
[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_markdown)
|
||||
[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_markdown)
|
||||
[![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)
|
||||
|
||||
|
|
|
@ -16,28 +16,28 @@ final RegExp _braces = RegExp(r'@?{{(((\\})|([^}]))+)}}');
|
|||
/// and returns a String, or a `Future<String>`.
|
||||
AngelConfigurer markdown(
|
||||
Directory viewsDirectory, {
|
||||
String extension,
|
||||
ExtensionSet extensionSet,
|
||||
FutureOr<String> Function(String content, Map<String, dynamic> locals)
|
||||
String? extension,
|
||||
ExtensionSet? extensionSet,
|
||||
FutureOr<String> Function(String content, Map<String, dynamic> locals)?
|
||||
template,
|
||||
}) {
|
||||
extension ??= '.md';
|
||||
extensionSet ??= ExtensionSet.gitHubWeb;
|
||||
|
||||
return (Angel app) async {
|
||||
app.viewGenerator = (String name, [Map<String, dynamic> locals]) async {
|
||||
app.viewGenerator = (String name, [Map<String, dynamic>? locals]) async {
|
||||
var file = viewsDirectory.childFile(
|
||||
viewsDirectory.fileSystem.path.setExtension(name, extension));
|
||||
viewsDirectory.fileSystem.path.setExtension(name, extension!));
|
||||
var contents = await file.readAsString();
|
||||
|
||||
contents = contents.replaceAllMapped(_braces, (m) {
|
||||
var text = m[0];
|
||||
var text = m[0]!;
|
||||
|
||||
if (text.startsWith('@')) {
|
||||
// Raw braces
|
||||
return text.substring(1);
|
||||
} else {
|
||||
var expr = m[1];
|
||||
var expr = m[1]!;
|
||||
var split = expr.split('.');
|
||||
var root = split[0];
|
||||
|
||||
|
@ -46,7 +46,7 @@ AngelConfigurer markdown(
|
|||
'Expected a local named "$root", but none was provided. Expression text: "$text"');
|
||||
}
|
||||
|
||||
return _resolveDotNotation(split, locals[root]).toString();
|
||||
return _resolveDotNotation(split, locals![root]).toString();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
name: angel3_markdown
|
||||
version: 3.0.0
|
||||
version: 4.0.0
|
||||
description: Angel3 Markdown view generator. Write static sites, with no build step.
|
||||
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/markdown
|
||||
environment:
|
||||
sdk: ">=2.10.0 <3.0.0"
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_framework: ^4.0.0
|
||||
file: ^6.1.2
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# angel3_pretty_logging
|
||||
# Angel3 Petty Logging
|
||||
|
||||
[![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_pretty_logging)
|
||||
[![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)
|
||||
|
@ -7,7 +8,8 @@
|
|||
|
||||
Standalone helper for colorful logging output, using pkg:io AnsiCode.
|
||||
|
||||
# Installation
|
||||
## Installation
|
||||
|
||||
In your `pubspec.yaml`:
|
||||
|
||||
```yaml
|
||||
|
@ -15,15 +17,15 @@ dependencies:
|
|||
angel3_pretty_logging: ^3.0.0
|
||||
```
|
||||
|
||||
# Usage
|
||||
## Usage
|
||||
|
||||
Basic usage is very simple:
|
||||
|
||||
```dart
|
||||
myLogger.onRecord.listen(prettyLog);
|
||||
```
|
||||
|
||||
However, you can conditionally pass logic to omit printing an
|
||||
error, provide colors, or to provide a custom print function:
|
||||
However, you can conditionally pass logic to omit printing an error, provide colors, or to provide a custom print function:
|
||||
|
||||
```dart
|
||||
var pretty = prettyLog(
|
||||
|
|
Loading…
Reference in a new issue