Skip to content

Commit

Permalink
Add features 'allowList' & 'blockList'
Browse files Browse the repository at this point in the history
  • Loading branch information
S1SYPHOS committed Jul 4, 2021
1 parent 7e93104 commit 2802c0e
Show file tree
Hide file tree
Showing 47 changed files with 1,092 additions and 1,465 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ You may change certain options from your `config.php` globally (`'kirby3-dejure.
| Option | Type | Default | Description |
| ----------------- | ------ | ---------------- | --------------------------------- |
| `'enabled'` | bool | `false` | Enables `kirbytext:after` hook |
| `'allowList'` | array | `[]` | Allowed template names |
| `'blockList'` | array | `[]` | Blocked template names |
| `'ignore'` | string | `''` | Global file number ignore |
| `'email'` | string | `''` | Contact mail |
| `'buzer'` | bool | `false` | Fallback linking to 'buzer.de' |
Expand All @@ -49,7 +51,12 @@ You may change certain options from your `config.php` globally (`'kirby3-dejure.
| `'timeout'` | int | `3` | Request timeout (seconds) |
| `'userAgent'` | string | `null` | Controls `User-Agent` header |

When enabling the plugin via `kirby3-dejure.enabled`, autolinking is applied to all `kirbytext()` / `kt()` calls. Besides that, there are additional methods you can use:
When enabling the plugin via `kirby3-dejure.enabled`, auto-linking is applied to all `kirbytext()` / `kt()` calls, with two exceptions:

1. If a page's `intendedTemplate()` name is allow(list)ed, this overrides `kirby3-dejure.enabled` being `false`
1. If a page's `intendedTemplate()` name is block(list)ed, this overrides `kirby3-dejure.enabled` being `true`

Besides that, there are additional methods you can use:

## Methods

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Auto-linking legal norms to dejure.org for Kirby v3",
"type": "kirby-plugin",
"license": "MIT",
"version": "1.2.3",
"version": "1.3.0",
"keywords": ["getkirby", "kirby", "kirby3", "kirby-plugin", "api", "legal", "dejure", "dejure.org"],
"scripts": {
"cs-dry": "php-cs-fixer fix --dry-run --diff",
Expand Down
15 changes: 13 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @package Kirby CMS
* @author S1SYPHOS <[email protected]>
* @link http://twobrain.io
* @version 1.2.3
* @version 1.3.0
* @license MIT
*/

Expand Down Expand Up @@ -93,11 +93,22 @@ function clearDJO(): bool
'hooks' => [
'kirbytext:after' => function (string $text): string
{
# Leave text unmodified if plugin is disabled (default)
# Process text by all means when page template is allowlisted
if (in_array(page()->intendedTemplate(), option('kirby3-dejure.allowList', [])) === true) {
return dejurify($text);
}

# Leave text unmodified if ..
# (1) .. plugin is disabled (default)
if (!option('kirby3-dejure.enabled', false)) {
return $text;
}

# (2) .. page template is blocklisted
if (in_array(page()->intendedTemplate(), option('kirby3-dejure.blockList', [])) === true) {
return $text;
}

return dejurify($text);
},
],
Expand Down
42 changes: 29 additions & 13 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class InstalledVersions
private static $installed = array (
'root' =>
array (
'pretty_version' => '1.2.2',
'version' => '1.2.2.0',
'pretty_version' => '1.2.3',
'version' => '1.2.3.0',
'aliases' =>
array (
),
Expand Down Expand Up @@ -109,12 +109,12 @@ class InstalledVersions
),
'guzzlehttp/psr7' =>
array (
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'pretty_version' => '2.0.0',
'version' => '2.0.0.0',
'aliases' =>
array (
),
'reference' => 'dc960a912984efb74d0a90222870c72c87f10c91',
'reference' => '1dc8d9cba3897165e16d12bb13d813afb1eb3fe7',
),
'php-cs-fixer/diff' =>
array (
Expand Down Expand Up @@ -175,6 +175,22 @@ class InstalledVersions
0 => '1.0',
),
),
'psr/http-factory' =>
array (
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'aliases' =>
array (
),
'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
),
'psr/http-factory-implementation' =>
array (
'provided' =>
array (
0 => '1.0',
),
),
'psr/http-message' =>
array (
'pretty_version' => '1.0.1',
Expand Down Expand Up @@ -227,8 +243,8 @@ class InstalledVersions
),
's1syphos/kirby3-dejure' =>
array (
'pretty_version' => '1.2.2',
'version' => '1.2.2.0',
'pretty_version' => '1.2.3',
'version' => '1.2.3.0',
'aliases' =>
array (
),
Expand Down Expand Up @@ -297,12 +313,12 @@ class InstalledVersions
),
'symfony/filesystem' =>
array (
'pretty_version' => 'v5.3.0',
'version' => '5.3.0.0',
'pretty_version' => 'v5.3.3',
'version' => '5.3.3.0',
'aliases' =>
array (
),
'reference' => '348116319d7fb7d1faa781d26a48922428013eb2',
'reference' => '19b71c8f313b411172dd5f470fd61f24466d79a9',
),
'symfony/finder' =>
array (
Expand Down Expand Up @@ -423,12 +439,12 @@ class InstalledVersions
),
'symfony/string' =>
array (
'pretty_version' => 'v5.3.2',
'version' => '5.3.2.0',
'pretty_version' => 'v5.3.3',
'version' => '5.3.3.0',
'aliases' =>
array (
),
'reference' => '0732e97e41c0a590f77e231afc16a327375d50b0',
'reference' => 'bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1',
),
),
);
Expand Down
7 changes: 7 additions & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
'GuzzleHttp\\Psr7\\DroppingStream' => $vendorDir . '/guzzlehttp/psr7/src/DroppingStream.php',
'GuzzleHttp\\Psr7\\FnStream' => $vendorDir . '/guzzlehttp/psr7/src/FnStream.php',
'GuzzleHttp\\Psr7\\Header' => $vendorDir . '/guzzlehttp/psr7/src/Header.php',
'GuzzleHttp\\Psr7\\HttpFactory' => $vendorDir . '/guzzlehttp/psr7/src/HttpFactory.php',
'GuzzleHttp\\Psr7\\InflateStream' => $vendorDir . '/guzzlehttp/psr7/src/InflateStream.php',
'GuzzleHttp\\Psr7\\LazyOpenStream' => $vendorDir . '/guzzlehttp/psr7/src/LazyOpenStream.php',
'GuzzleHttp\\Psr7\\LimitStream' => $vendorDir . '/guzzlehttp/psr7/src/LimitStream.php',
Expand Down Expand Up @@ -685,11 +686,17 @@
'Psr\\Http\\Client\\NetworkExceptionInterface' => $vendorDir . '/psr/http-client/src/NetworkExceptionInterface.php',
'Psr\\Http\\Client\\RequestExceptionInterface' => $vendorDir . '/psr/http-client/src/RequestExceptionInterface.php',
'Psr\\Http\\Message\\MessageInterface' => $vendorDir . '/psr/http-message/src/MessageInterface.php',
'Psr\\Http\\Message\\RequestFactoryInterface' => $vendorDir . '/psr/http-factory/src/RequestFactoryInterface.php',
'Psr\\Http\\Message\\RequestInterface' => $vendorDir . '/psr/http-message/src/RequestInterface.php',
'Psr\\Http\\Message\\ResponseFactoryInterface' => $vendorDir . '/psr/http-factory/src/ResponseFactoryInterface.php',
'Psr\\Http\\Message\\ResponseInterface' => $vendorDir . '/psr/http-message/src/ResponseInterface.php',
'Psr\\Http\\Message\\ServerRequestFactoryInterface' => $vendorDir . '/psr/http-factory/src/ServerRequestFactoryInterface.php',
'Psr\\Http\\Message\\ServerRequestInterface' => $vendorDir . '/psr/http-message/src/ServerRequestInterface.php',
'Psr\\Http\\Message\\StreamFactoryInterface' => $vendorDir . '/psr/http-factory/src/StreamFactoryInterface.php',
'Psr\\Http\\Message\\StreamInterface' => $vendorDir . '/psr/http-message/src/StreamInterface.php',
'Psr\\Http\\Message\\UploadedFileFactoryInterface' => $vendorDir . '/psr/http-factory/src/UploadedFileFactoryInterface.php',
'Psr\\Http\\Message\\UploadedFileInterface' => $vendorDir . '/psr/http-message/src/UploadedFileInterface.php',
'Psr\\Http\\Message\\UriFactoryInterface' => $vendorDir . '/psr/http-factory/src/UriFactoryInterface.php',
'Psr\\Http\\Message\\UriInterface' => $vendorDir . '/psr/http-message/src/UriInterface.php',
'Psr\\Log\\AbstractLogger' => $vendorDir . '/psr/log/Psr/Log/AbstractLogger.php',
'Psr\\Log\\InvalidArgumentException' => $vendorDir . '/psr/log/Psr/Log/InvalidArgumentException.php',
Expand Down
1 change: 0 additions & 1 deletion vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
);
2 changes: 1 addition & 1 deletion vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'S1SYPHOS\\' => array($vendorDir . '/s1syphos/php-dejure/lib'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
Expand Down
9 changes: 8 additions & 1 deletion vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ComposerStaticInit611e04ed773a37ce92d91966d7ce00ae
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
);
Expand Down Expand Up @@ -166,6 +165,7 @@ class ComposerStaticInit611e04ed773a37ce92d91966d7ce00ae
'Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-message/src',
1 => __DIR__ . '/..' . '/psr/http-factory/src',
),
'Psr\\Http\\Client\\' =>
array (
Expand Down Expand Up @@ -320,6 +320,7 @@ class ComposerStaticInit611e04ed773a37ce92d91966d7ce00ae
'GuzzleHttp\\Psr7\\DroppingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/DroppingStream.php',
'GuzzleHttp\\Psr7\\FnStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/FnStream.php',
'GuzzleHttp\\Psr7\\Header' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Header.php',
'GuzzleHttp\\Psr7\\HttpFactory' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/HttpFactory.php',
'GuzzleHttp\\Psr7\\InflateStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/InflateStream.php',
'GuzzleHttp\\Psr7\\LazyOpenStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LazyOpenStream.php',
'GuzzleHttp\\Psr7\\LimitStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LimitStream.php',
Expand Down Expand Up @@ -901,11 +902,17 @@ class ComposerStaticInit611e04ed773a37ce92d91966d7ce00ae
'Psr\\Http\\Client\\NetworkExceptionInterface' => __DIR__ . '/..' . '/psr/http-client/src/NetworkExceptionInterface.php',
'Psr\\Http\\Client\\RequestExceptionInterface' => __DIR__ . '/..' . '/psr/http-client/src/RequestExceptionInterface.php',
'Psr\\Http\\Message\\MessageInterface' => __DIR__ . '/..' . '/psr/http-message/src/MessageInterface.php',
'Psr\\Http\\Message\\RequestFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/RequestFactoryInterface.php',
'Psr\\Http\\Message\\RequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/RequestInterface.php',
'Psr\\Http\\Message\\ResponseFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/ResponseFactoryInterface.php',
'Psr\\Http\\Message\\ResponseInterface' => __DIR__ . '/..' . '/psr/http-message/src/ResponseInterface.php',
'Psr\\Http\\Message\\ServerRequestFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/ServerRequestFactoryInterface.php',
'Psr\\Http\\Message\\ServerRequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/ServerRequestInterface.php',
'Psr\\Http\\Message\\StreamFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/StreamFactoryInterface.php',
'Psr\\Http\\Message\\StreamInterface' => __DIR__ . '/..' . '/psr/http-message/src/StreamInterface.php',
'Psr\\Http\\Message\\UploadedFileFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/UploadedFileFactoryInterface.php',
'Psr\\Http\\Message\\UploadedFileInterface' => __DIR__ . '/..' . '/psr/http-message/src/UploadedFileInterface.php',
'Psr\\Http\\Message\\UriFactoryInterface' => __DIR__ . '/..' . '/psr/http-factory/src/UriFactoryInterface.php',
'Psr\\Http\\Message\\UriInterface' => __DIR__ . '/..' . '/psr/http-message/src/UriInterface.php',
'Psr\\Log\\AbstractLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/AbstractLogger.php',
'Psr\\Log\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/log/Psr/Log/InvalidArgumentException.php',
Expand Down
42 changes: 29 additions & 13 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php return array (
'root' =>
array (
'pretty_version' => '1.2.2',
'version' => '1.2.2.0',
'pretty_version' => '1.2.3',
'version' => '1.2.3.0',
'aliases' =>
array (
),
Expand Down Expand Up @@ -85,12 +85,12 @@
),
'guzzlehttp/psr7' =>
array (
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'pretty_version' => '2.0.0',
'version' => '2.0.0.0',
'aliases' =>
array (
),
'reference' => 'dc960a912984efb74d0a90222870c72c87f10c91',
'reference' => '1dc8d9cba3897165e16d12bb13d813afb1eb3fe7',
),
'php-cs-fixer/diff' =>
array (
Expand Down Expand Up @@ -151,6 +151,22 @@
0 => '1.0',
),
),
'psr/http-factory' =>
array (
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'aliases' =>
array (
),
'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
),
'psr/http-factory-implementation' =>
array (
'provided' =>
array (
0 => '1.0',
),
),
'psr/http-message' =>
array (
'pretty_version' => '1.0.1',
Expand Down Expand Up @@ -203,8 +219,8 @@
),
's1syphos/kirby3-dejure' =>
array (
'pretty_version' => '1.2.2',
'version' => '1.2.2.0',
'pretty_version' => '1.2.3',
'version' => '1.2.3.0',
'aliases' =>
array (
),
Expand Down Expand Up @@ -273,12 +289,12 @@
),
'symfony/filesystem' =>
array (
'pretty_version' => 'v5.3.0',
'version' => '5.3.0.0',
'pretty_version' => 'v5.3.3',
'version' => '5.3.3.0',
'aliases' =>
array (
),
'reference' => '348116319d7fb7d1faa781d26a48922428013eb2',
'reference' => '19b71c8f313b411172dd5f470fd61f24466d79a9',
),
'symfony/finder' =>
array (
Expand Down Expand Up @@ -399,12 +415,12 @@
),
'symfony/string' =>
array (
'pretty_version' => 'v5.3.2',
'version' => '5.3.2.0',
'pretty_version' => 'v5.3.3',
'version' => '5.3.3.0',
'aliases' =>
array (
),
'reference' => '0732e97e41c0a590f77e231afc16a327375d50b0',
'reference' => 'bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1',
),
),
);
Loading

0 comments on commit 2802c0e

Please sign in to comment.