-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.php
More file actions
executable file
·103 lines (87 loc) · 2.75 KB
/
action.php
File metadata and controls
executable file
·103 lines (87 loc) · 2.75 KB
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
<?php
class action_plugin_codeprism extends DokuWiki_Action_Plugin
{
private function getTheme()
{
$theme = $this->getConf('theme');
if ($theme != 'default') {
$theme = '-' . $theme;
}
return $theme;
}
private function getCdn()
{
if ($this->getConf('custom-cdn')) {
return $this->getConf('custom-cdn');
}
else {
return $this->getConf('cdn');
}
}
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_hookjs');
}
public function _hookjs(Doku_Event $event, $param)
{
$pluginBase = DOKU_BASE.'lib/plugins';
$theme = $this->getTheme();
$cdn = $this->getCdn();
/** CSS */
$event->data['link'][] = array(
'rel' => 'stylesheet',
'href' => $pluginBase.'/codeprism/codeprism.css'
);
$css_hrefs = array(
'themes/prism' . $theme . '.min.css',
'plugins/line-numbers/prism-line-numbers.min.css',
'plugins/line-highlight/prism-line-highlight.min.css',
'plugins/toolbar/prism-toolbar.min.css',
'plugins/command-line/prism-command-line.min.css',
);
/** Scripts */
$scripts = array(
'prism.js',
'plugins/autoloader/prism-autoloader.min.js',
'components/prism-core.min.js',
'plugins/line-numbers/prism-line-numbers.min.js',
'plugins/line-highlight/prism-line-highlight.min.js',
'plugins/toolbar/prism-toolbar.min.js',
'plugins/copy-to-clipboard/prism-copy-to-clipboard.js',
'plugins/show-language/prism-show-language.min.js',
'plugins/command-line/prism-command-line.min.js',
'plugins/file-highlight/prism-file-highlight.min.js'
);
if ($this->getConf('show-invis')) {
$css_hrefs[] = 'plugins/show-invisibles/prism-show-invisibles.min.css';
$scripts[] = 'plugins/show-invisibles/prism-show-invisibles.min.js';
}
if ($this->getConf('hl-brace')) {
$css_hrefs[] = 'plugins/match-braces/prism-match-braces.min.css';
$scripts[] = 'plugins/match-braces/prism-match-braces.min.js';
}
if ($this->getConf('previewer')) {
/* Need to load css-extras.min.js to preview CSS and need to load css.min.js
* first. so it seems impossible to use autoloder.min.js to load CSS resources.
*/
$scripts[] = 'components/prism-css.min.js';
$scripts[] = 'components/prism-css-extras.min.js';
$css_hrefs[] = 'plugins/previewers/prism-previewers.min.css';
$css_hrefs[] = 'plugins/inline-color/prism-inline-color.min.css';
$scripts[] = 'plugins/previewers/prism-previewers.min.js';
$scripts[] = 'plugins/inline-color/prism-inline-color.min.js';
}
foreach($css_hrefs as $href) {
$event->data['link'][] = array(
'rel' => 'stylesheet',
'href' => $cdn . $href
);
}
foreach($scripts as $script) {
$event->data['script'][] = array(
'src' => $cdn . $script,
'_data' => ''
);
}
}
}