Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagecell
Path: blob/master/contrib/dokuwiki/action.php
447 views
1
<?php
2
/**
3
* DokuWiki Plugin sagecell (Action Component)
4
*
5
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6
* @author Jason Grout <[email protected]>
7
*/
8
9
// must be run within Dokuwiki
10
if (!defined('DOKU_INC')) die();
11
12
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
13
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
14
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15
16
require_once DOKU_PLUGIN.'action.php';
17
18
class action_plugin_sagecell extends DokuWiki_Action_Plugin {
19
20
public function register(Doku_Event_Handler &$controller) {
21
22
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_tpl_metaheader_output');
23
24
}
25
26
public function handle_tpl_metaheader_output(Doku_Event &$event, $param) {
27
$url = rtrim($this->getConf('url'), '/');
28
// Adding js
29
$event->data["script"][] = array (
30
"type" => "text/javascript",
31
"src" => $url . "/static/jquery.min.js",
32
"_data" => "",
33
);
34
$event->data["script"][] = array (
35
"type" => "text/javascript",
36
"src" => $url . "/static/embedded_sagecell.js",
37
"_data" => "",
38
);
39
// Initializing cells
40
$event->data["script"][] = array (
41
"type" => "text/javascript",
42
"charset" => "utf-8",
43
"_data" => "sagecell.makeSagecell({inputLocation: '.sage'});",
44
);
45
// Adding stylesheet
46
$event->data["link"][] = array (
47
"type" => "text/css",
48
"rel" => "stylesheet",
49
"href" => $url . "/static/sagecell_embed.css",
50
);
51
$event->data['style'][] = array('type' => 'text/css',
52
'_data' => $this->getConf('style'));
53
}
54
55
}
56
57
// vim:ts=4:sw=4:et:
58
59