This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
/
index.php
executable file
·136 lines (115 loc) · 5.07 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* Kirby 3 "Commentions" - Comments and Mentions Plugin
*
* @version 1.0.7
* @author Sebastian Greger <msg@sebastiangreger.net>
* @copyright Sebastian Greger <msg@sebastiangreger.net>
* @link https://github.com/sebastiangreger/kirby3-commentions
* @license MIT
*/
use sgkirby\Commentions\Commentions;
use sgkirby\Commentions\Structure;
use Kirby\Cms\App as Kirby;
use Kirby\Toolkit\F;
if (F::exists(__DIR__ . '/vendor/autoload.php') === false) {
// Fallback to manual autoloading via class map, if composer
// autoloader is not present
load([
'sgkirby\\commentions\\Commention' => 'lib/Commention.php',
'sgkirby\\commentions\\Commentions' => 'lib/Commentions.php',
'sgkirby\\commentions\\Cron' => 'lib/Cron.php',
'sgkirby\\commentions\\Endpoint' => 'lib/Endpoint.php',
'sgkirby\\commentions\\Frontend' => 'lib/Frontend.php',
'sgkirby\\commentions\\Migration' => 'lib/Migration.php',
'sgkirby\\commentions\\Formatter' => 'lib/Formatter.php',
'sgkirby\\commentions\\Formatter\\CacheAdapter' => 'lib/Formatter/CacheAdapter.php',
'sgkirby\\commentions\\Formatter\\CodeClassAttrDef' => 'lib/Formatter/CodeClassAttrDef.php',
'sgkirby\\commentions\\Formatter\\LinkTransformer' => 'lib/Formatter/LinkTransformer.php',
'sgkirby\\commentions\\Formatter\\RemoveEmptyLinksInjector' => 'lib/Formatter/RemoveEmptyLinksInjector.php',
'sgkirby\\commentions\\Storage' => 'lib/Storage.php',
'sgkirby\\commentions\\Structure' => 'lib/Structure.php',
], __DIR__);
}
@require_once __DIR__ . '/helpers.php';
@require_once __DIR__ . '/includes/mf2-parser.php';
@require_once __DIR__ . '/includes/php-comments.php';
@include_once __DIR__ . '/vendor/autoload.php';
Kirby::plugin('sgkirby/commentions', [
'options' => [
'cache' => [
'sanitized-text' => true,
'purifier-definitions' => true,
],
'templatesWithComments' => null,
'templatesWithWebmentions' => null,
'secret' => '',
'keepfailed' => true,
'defaultstatus' => 'pending',
'endpoint' => 'webmention-endpoint',
'spamprotection' => [ 'honeypot', 'timemin', 'timemax' ],
'spamtimemin' => 5,
'spamtimemax' => 86400,
'avatarurls' => false,
'hideforms' => false,
'expand' => false,
'allowlinks' => true,
'autolinks' => true,
'commentfields' => ['name'],
'webmentionfields' => ['text', 'name', 'website'],
'grouped' => [
'read' => 'Read by',
'like' => 'Likes',
'repost' => 'Reposts',
'bookmark' => 'Bookmarks',
'rsvp:yes' => 'RSVP: yes',
'rsvp:maybe' => 'RSVP: maybe',
'rsvp:interested' => 'RSVP: interested',
'rsvp:no' => 'RSVP: no',
],
],
'api' => require __DIR__ . '/config/api.php',
'blueprints' => [
// DEPRECATED as of 1.0.0: replaced with section 'commentions'
'fields/commentions' => __DIR__ . '/blueprints/fields/commentions.yml'
],
'hooks' => require __DIR__ . '/config/hooks.php',
'sections' => [
'commentions' => require __DIR__ . '/sections/commentions.php',
],
'routes' => require __DIR__ . '/config/routes.php',
'snippets' => [
'commentions-list' => __DIR__ . '/snippets/commentions-list.php',
'commentions-form' => __DIR__ . '/snippets/commentions-form.php',
'commentions-help' => __DIR__ . '/snippets/commentions-help.php',
'commentions-feedback' => __DIR__ . '/snippets/commentions-feedback.php',
],
'pageMethods' => [
'commentions' => function(string $status = 'approved', string $language = null) {
return Commentions::get($this, $status, $language);
},
'addCommention' => function(array $data) {
return Commentions::add($this, $data, 'commentions');
},
'deleteCommention' => function(string $uid) {
return Commentions::update($this, $uid, 'delete');
},
'updateCommention' => function(string $uid, array $data) {
return Commentions::update($this, $uid, $data);
},
],
'pagesMethods' => [
'commentions' => function(string $status = 'approved', string $language = null): Structure {
$commentions = new Structure();
foreach ($this as $page) {
$commentions = $commentions->add($page->commentions($status, $language));
}
return $commentions->sortBy('timestamp');
},
],
'translations' => [
'de' => require __DIR__ . '/languages/de.php',
'en' => require __DIR__ . '/languages/en.php',
'fr' => require __DIR__ . '/languages/fr.php',
],
]);