Skip to content

Commit

Permalink
Add sections about 'Configuration' & 'Methods'
Browse files Browse the repository at this point in the history
  • Loading branch information
S1SYPHOS committed Jun 25, 2021
1 parent 2d8a090 commit 1545c55
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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)) {
Expand Down

0 comments on commit 1545c55

Please sign in to comment.