-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
executable file
·53 lines (49 loc) · 1.4 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace texnixe\Similar;
use Kirby\Cms\App as Kirby;
use Kirby\Cms\Files;
use Kirby\Cms\Pages;
use Kirby\Exception\Exception;
/**
* Kirby 3 Similar Plugin
*
* @version 3.0.0
* @author Sonja Broda <hello@sonjabroda.com>
* @copyright Sonja Broda <hello@sonjabroda.com>
* @link https://github.com/texnixe/kirby3-similar
* @license MIT
*/
load([
'texnixe\\similar\\similar' => 'lib/Similar.php'
], __DIR__);
Kirby::plugin('texnixe/similar', [
'options' => [
'cache' => option('texnixe.similar.cache', true),
'expires' => (60 * 24 * 7), // minutes
'defaults' => [
'fields' => 'tags',
'threshold' => 0.1,
'delimiter' => ',',
'languageFilter' => false,
],
],
'pageMethods' => [
'similar' => function (array $options = []) {
try {
return (new Similar($this, new Pages(), $options))->getSimilar();
} catch (Exception $e) {
return new Files();
}
},
],
'fileMethods' => [
'similar' => function (array $options = []) {
try {
return (new Similar($this, new Files(), $options))->getSimilar();
} catch (Exception $e) {
return new Files();
}
},
],
'hooks' => require __DIR__ . '/config/hooks.php',
]);