-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
extend.php
62 lines (49 loc) · 2.01 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
58
59
60
61
62
<?php
/*
* This file is part of fof/sitemap.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace FoF\Sitemap;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Extend;
use Flarum\Foundation\Paths;
use Flarum\Http\UrlGenerator;
return [
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
(new Extend\Routes('forum'))
// It seems like some search engines add xml to the end of our extension-less URLs. So we'll allow it as well
->get('/sitemap-live/{id:\d+|index}[.xml]', 'fof-sitemap-live', Controllers\MemoryController::class)
->get('/sitemap.xml', 'fof-sitemap-index', Controllers\SitemapController::class),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\ApiSerializer(ForumSerializer::class))
->attributes(ForumAttributes::class),
(new Extend\ServiceProvider())
->register(Providers\Provider::class)
->register(Providers\DeployProvider::class),
(new Extend\Console())
->command(Console\BuildSitemapCommand::class)
->schedule(Console\BuildSitemapCommand::class, new Console\BuildSitemapSchedule()),
(new Extend\View())
->namespace('fof-sitemap', __DIR__.'/views'),
(new Extend\Filesystem())
->disk('flarum-sitemaps', function (Paths $paths, UrlGenerator $url) {
return [
'root' => "$paths->public/sitemaps",
'url' => $url->to('forum')->path('sitemaps'),
];
}),
(new Extend\Settings())
->default('fof-sitemap.mode', 'run')
->default('fof-sitemap.frequency', 'daily')
->default('fof-sitemap.excludeUsers', false)
->default('fof-sitemap.model.user.comments.minimum_item_threshold', 5)
->default('fof-sitemap.model.tags.discussion.minimum_item_threshold', 5),
(new Extend\Event())
->subscribe(Listeners\SettingsListener::class),
];