mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-22 13:23:40 +00:00
27a48ae84a
- Create separate addon javascript file - Register stylesheet and Javascript files
39 lines
937 B
PHP
39 lines
937 B
PHP
<?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;
|
|
use Friendica\Core\Addon;
|
|
|
|
function highlightjs_install()
|
|
{
|
|
Addon::registerHook('head' , __FILE__, 'highlightjs_head');
|
|
Addon::registerHook('footer', __FILE__, 'highlightjs_footer');
|
|
}
|
|
|
|
function highlightjs_uninstall()
|
|
{
|
|
Addon::unregisterHook('head' , __FILE__, 'highlightjs_head');
|
|
Addon::unregisterHook('footer', __FILE__, 'highlightjs_footer');
|
|
}
|
|
|
|
function highlightjs_head(App $a, &$b)
|
|
{
|
|
if ($a->getCurrentTheme() == 'frio') {
|
|
$style = 'bootstrap';
|
|
} else {
|
|
$style = 'default';
|
|
}
|
|
|
|
$a->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
|
|
}
|
|
|
|
function highlightjs_footer(App $a, &$b)
|
|
{
|
|
$a->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
|
|
$a->registerFooterScript(__DIR__ . '/highlightjs.js');
|
|
}
|