This repository has been archived by the owner on Oct 7, 2023. It is now read-only.
forked from Extum/signature
-
Notifications
You must be signed in to change notification settings - Fork 10
/
extend.php
43 lines (33 loc) · 1.59 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
<?php
use Illuminate\Contracts\Events\Dispatcher;
use katosdev\Signature\Validation\ValidateSignature;
use katosdev\Signature\Model;
use Flarum\Extend;
use Flarum\User\User;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\Frontend\Document;
use FoF\Components\Extend\AddFofComponents;
return [
new AddFofComponents(),
(new Extend\Frontend('forum'))
->content(function (Document $document) {
$document->head[] = '<script src="//cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script><script>window.jQuery || document.write(\'<script src="js/vendor/jquery-3.3.1.min.js"><\/script>\')</script><script src="https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.4.0/trumbowyg.js"></script>';
}),
new Extend\Locales(__DIR__ . '/locale'),
(new Flarum\Extend\ApiSerializer(UserSerializer::class))
->attributes(function (UserSerializer $serializer, User $user, array $attributes) {
$attributes['signature'] = $user->signature;
return $attributes;
}),
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/less/signature.less')
->css(__DIR__ . '/less/trumbowyg.less')
->route('/settings/signature', 'settings.signature', \Flarum\Forum\Content\AssertRegistered::class),
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),
(new Extend\Routes('api'))
->post('/settings/signature/validate', 'settings.signature', ValidateSignature::class),
(new Extend\Event())
->subscribe(Model\UserSignatureAttributes::class),
];