From 1545c55a8a13756bf8e212ab19c888f1d0d53479 Mon Sep 17 00:00:00 2001 From: Martin Folkers Date: Fri, 25 Jun 2021 12:08:18 +0200 Subject: [PATCH] Add sections about 'Configuration' & 'Methods' --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 4 ++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 092e374..e4ed472 100755 --- a/README.md +++ b/README.md @@ -27,6 +27,58 @@ composer require s1syphos/kirby3-dejure 2. Unzip / Move the folder to `site/plugins`. +## Configuration + +You may change certain options from your `config.php` globally (`'kirby3-dejure.optionName'`): + +| Option | Type | Default | Description | +| ----------------- | ------ | ----------- | --------------------------------- | +| `'enabled'` | bool | `false` | Enables / disables plugin | +| `'ignore'` | string | `''` | Global file number ignore | +| `'email'` | string | `''` | Contact mail | +| `'buzer'` | bool | `false` | Fallback linking to 'buzer.de' | +| `'class'` | string | `''` | Controls `class` attribute | +| `'lineBreak'` | string | `'auto'` | Controls links across line breaks | +| `'linkStyle'` | string | `'weit'` | Controls link range | +| `'target'` | string | `'_blank'` | Controls `target` attribute | +| `'tooltip'` | string | `'neutral'` | Controls `title` attribute | +| `'cacheDuration'` | int | `2` | Cache duration (days) | +| `'streamTimeout'` | int | `10` | Response stream timeout (seconds) | +| `'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: + +## Methods + +There are several ways to do this, you can either use a standalone function, a page method or a field method: + +### Method: `dejurify(string $text, string $ignore = ''): string` + +Processes linkable citations & caches text (if uncached or expired) + + +### Method: `clearDJO(): bool` + +Clears DJO cache + + +### Page method: `$page->dejurify(string $text, string $ignore = '')` + +Same as `dejurify` + + +### Field method: `$field->dejurify(string $text, string $ignore = '', bool $useKirbytext = true)` + +Same as `dejurify`, but supports applying `kirbytext()` out-of-the-box via its third parameter `$useKirbytext`. + + +## Roadmap + +- [ ] Add tests +- [ ] Cache entries per-site (?) + + ## Credits / License `kirby3-dejure` is based on [`php-dejure`](https://github.com/S1SYPHOS/php-dejure) library (an OOP port of `vernetzungsfunction.inc.php`, which can be [downloaded here](https://dejure.org/vernetzung.html). It is licensed under the [MIT License](LICENSE), but **using Kirby in production** requires you to [buy a license](https://getkirby.com/buy). diff --git a/index.php b/index.php index a70e3c7..87cc3ed 100755 --- a/index.php +++ b/index.php @@ -52,7 +52,7 @@ function dejurify(string $text, string $ignore = null): string # Set defaults # (1) General information - $object->setEmail(option('kirby3-dejure.mail', '')); + $object->setEmail(option('kirby3-dejure.email', '')); # (2) Text processing $object->setBuzer(option('kirby3-dejure.buzer', false)); @@ -68,7 +68,7 @@ function dejurify(string $text, string $ignore = null): string $object->setUserAgent(option('kirby3-dejure.userAgent', 'kirby3-dejure @ ' . Kirby\Http\Server::host())); # (4) Caching - $object->setCacheDuration(option('kirby3-dejure.cachePeriod', 2)); + $object->setCacheDuration(option('kirby3-dejure.cacheDuration', 2)); # Fallback to global ignore if (!isset($ignore)) {