Merge pull request #1097 from annando/acvlang
[friendica-addons.git/.git] / highlightjs / highlightjs.php
1 <?php
2 /**
3  * Name: Syntax Highlighting
4  * Description: Highlights syntax of code blocks with highlight.js
5  * Version: 1.0
6  * Author: Hypolite Petovan <hypolite@mrpetovan.com>
7  */
8
9 use Friendica\App;
10 use Friendica\Core\Hook;
11 use Friendica\DI;
12
13 function highlightjs_install()
14 {
15         Hook::register('head'  , __FILE__, 'highlightjs_head');
16         Hook::register('footer', __FILE__, 'highlightjs_footer');
17 }
18
19 function highlightjs_head(App $a, &$b)
20 {
21         if ($a->getCurrentTheme() == 'frio') {
22                 $style = 'bootstrap';
23         } else {
24                 $style = 'default';
25         }
26
27         DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
28 }
29
30 function highlightjs_footer(App $a, &$b)
31 {
32         DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
33         DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js');
34 }