-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (69 loc) · 2.55 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
<?php
use Pagekit\Application as App;
return [
'name' => 'highlight',
'type' => 'extension',
'resources' => [
'highlight:' => '',
'views:highlight' => 'views'
],
'autoload' => [
'Pagekit\\Highlight\\' => 'src'
],
'routes' => [
'/highlight' => [
'name' => '@highlight',
'controller' => [
'Pagekit\\Highlight\\HighlightController'
]
],
],
'config' => [
// default style. styles are located as css files in the styles folder
'style' => 'vs',
// Only load if page contains pre or code
'autodetect' => true,
// ids of pages where highlighting should be enabled
//frontend menu id(node database table)
'nodes' => [1,2,3,4]
],
'menu' => [
'highlight' => [
'label' => 'Highlight',
'icon' => 'highlight:icon.svg',
'url' => '@highlight/settings',
'active' => '@highlight/settings*',
'access' => 'highlight: see highlight',
'priority' => 117
],
'highlight: settings' => [
'parent' => 'highlight',
'label' => 'Settings',
'url' => '@highlight/settings',
'access' => 'system: manage settings'
]
],
'permissions' => [
'highlight: see highlight' => [
'title' => 'See highlight setting'
]
],
'settings' => '@highlight/settings',
'events' => [
// 'view.scripts' => function ($event, $scripts) use ($app) {
// $scripts->register('highlight-settings', 'highlight:app/bundle/settings.js', ['~extensions', 'input-tree']);
// },
'site' => function ($event, $app) {
$app->on('view.content', function ($event, $test) use ($app) {
if ((!$this->config['nodes'] || in_array($app['node']->id, $this->config['nodes']))
&& (!$this->config['autodetect'] || (strpos($event->getResult(), '<pre') !== false || strpos($event->getResult(), '<code') !== false))
) {
$app['scripts']->add('highlight', 'highlight:assets/highlight.pack.js');
$app['scripts']->add('highlight-init', 'highlight:assets/highlight.js', 'highlight');
$app['styles']->add('highlight', 'highlight:assets/styles/'.$this->config['style'].'.css');
$app['styles']->add('highlight-override', 'highlight:assets/style.css', 'highlight');
}
});
}
]
];