2018-09-19 22:03:15 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Syntax Highlighting
|
|
|
|
* Description: Highlights syntax of code blocks with highlight.js
|
|
|
|
* Version: 1.0
|
|
|
|
* Author: Hypolite Petovan <hypolite@mrpetovan.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Friendica\App;
|
2018-12-26 02:28:16 -05:00
|
|
|
use Friendica\Core\Hook;
|
2019-12-15 19:08:47 -05:00
|
|
|
use Friendica\DI;
|
2018-09-19 22:03:15 -04:00
|
|
|
|
|
|
|
function highlightjs_install()
|
|
|
|
{
|
2018-12-26 02:28:16 -05:00
|
|
|
Hook::register('head' , __FILE__, 'highlightjs_head');
|
|
|
|
Hook::register('footer', __FILE__, 'highlightjs_footer');
|
2018-09-19 22:03:15 -04:00
|
|
|
}
|
|
|
|
|
2023-01-13 21:16:09 -05:00
|
|
|
function highlightjs_head(string &$str)
|
2018-09-19 22:03:15 -04:00
|
|
|
{
|
2023-01-13 21:16:09 -05:00
|
|
|
if (DI::app()->getCurrentTheme() == 'frio') {
|
2018-09-19 22:03:15 -04:00
|
|
|
$style = 'bootstrap';
|
|
|
|
} else {
|
|
|
|
$style = 'default';
|
|
|
|
}
|
|
|
|
|
2019-12-15 19:08:47 -05:00
|
|
|
DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
|
2018-09-20 21:32:47 -04:00
|
|
|
}
|
2018-09-19 22:03:15 -04:00
|
|
|
|
2023-01-13 21:16:09 -05:00
|
|
|
function highlightjs_footer(string &$str)
|
2018-09-20 21:32:47 -04:00
|
|
|
{
|
2019-12-15 19:08:47 -05:00
|
|
|
DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
|
|
|
|
DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js');
|
2018-09-19 22:03:15 -04:00
|
|
|
}
|