2014-02-27 15:04:36 +01:00
|
|
|
<?php
|
2014-04-29 21:35:29 +02:00
|
|
|
class Assets extends \Chibi\Util\Assets
|
2014-02-27 15:04:36 +01:00
|
|
|
{
|
|
|
|
private static $pageThumb = null;
|
|
|
|
private static $subTitle = null;
|
|
|
|
|
2014-04-29 21:35:29 +02:00
|
|
|
public static function init()
|
|
|
|
{
|
|
|
|
\Chibi\Util\Assets::disable();
|
|
|
|
self::enable();
|
|
|
|
}
|
|
|
|
|
2014-02-27 15:04:36 +01:00
|
|
|
public static function setSubTitle($text)
|
|
|
|
{
|
|
|
|
self::$subTitle = $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setPageThumb($path)
|
|
|
|
{
|
|
|
|
self::$pageThumb = $path;
|
|
|
|
}
|
|
|
|
|
2014-04-29 21:35:29 +02:00
|
|
|
public static function addStylesheet($path)
|
|
|
|
{
|
|
|
|
return parent::addStylesheet('/media/css/' . $path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function addScript($path)
|
|
|
|
{
|
|
|
|
return parent::addScript('/media/js/' . $path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function transformHtml($html)
|
2014-02-27 15:04:36 +01:00
|
|
|
{
|
|
|
|
self::$title = isset(self::$subTitle)
|
|
|
|
? sprintf('%s – %s', self::$title, self::$subTitle)
|
|
|
|
: self::$title;
|
|
|
|
|
|
|
|
$html = parent::transformHtml($html);
|
|
|
|
|
|
|
|
$headSnippet = '<meta property="og:title" content="' . self::$title . '"/>';
|
2014-04-29 21:35:29 +02:00
|
|
|
$headSnippet .= '<meta property="og:url" content="' . \Chibi\Util\Url::currentUrl() . '"/>';
|
2014-02-27 15:04:36 +01:00
|
|
|
if (!empty(self::$pageThumb))
|
|
|
|
$headSnippet .= '<meta property="og:image" content="' . self::$pageThumb . '"/>';
|
|
|
|
|
|
|
|
$bodySnippet = '<script type="text/javascript">';
|
|
|
|
$bodySnippet .= '$(function() {';
|
|
|
|
$bodySnippet .= '$(\'body\').trigger(\'dom-update\');';
|
|
|
|
$bodySnippet .= '});';
|
|
|
|
$bodySnippet .= '</script>';
|
|
|
|
|
|
|
|
$html = str_replace('</head>', $headSnippet . '</head>', $html);
|
|
|
|
$html = str_replace('</body>', $bodySnippet . '</body>', $html);
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|
2014-04-29 21:35:29 +02:00
|
|
|
|
|
|
|
Assets::init();
|