-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.php
57 lines (50 loc) · 2.06 KB
/
extend.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
<?php
/*
* This file is part of flarumite/simple-spoilers.
*
* Copyright (c) 2021 Flarumite.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Flarumite\SimpleSpoilers;
use Flarum\Extend;
use s9e\TextFormatter\Configurator;
return [
(new Extend\Frontend('forum'))
->css(__DIR__ . '/resources/less/forum.less'),
// Add locales
new Extend\Locales(__DIR__ . '/resources/locale'),
// Add spoilers and accordions (this is the cool bit!!)
(new Extend\Formatter)->configure(function (Configurator $configurator) {
$translator = app(\Flarum\Locale\Translator::class);
$configurator->BBCodes->addCustom(
// TEXT = spoiler content
// TEXT2 = spoiler title (optional)
'[spoiler title={TEXT2;optional}]{TEXT}[/spoiler]',
'<details class="flarumite-spoiler">
<summary>
<span class="flarumite-spoiler--title flarumite-spoiler--title-closed">
<span class="flarumite-spoiler--custom-text">
{TEXT2}
</span>
<span class="flarumite-spoiler--default-text">
' . $translator->trans('flarumite.spoilers-and-accordions.forum.post.spoiler.closed') . '
</span>
</span>
<span class="flarumite-spoiler--title flarumite-spoiler--title-open">
<span class="flarumite-spoiler--custom-text">
{TEXT2}
</span>
<span class="flarumite-spoiler--default-text">
' . $translator->trans('flarumite.spoilers-and-accordions.forum.post.spoiler.open') . '
</span>
</span>
</summary>
<div class="flarumite-spoiler--content">
{TEXT}
</div>
</details>'
);
}),
];