Added custom favicon and assets support to config

Also, moved title key to [appearance] section
This commit is contained in:
Marcin Kurczewski 2014-06-10 12:01:15 +02:00
parent 21d72bc17e
commit a3c9338386
6 changed files with 33 additions and 6 deletions

View file

@ -8,9 +8,15 @@ logsPath = "./data/logs/{yyyy}-{mm}.log"
mediaPath = "./public_html/media/"
thumbnailsPath = "./public_html/thumbs/"
avatarsPath = "./public_html/avatars/"
title = "szurubooru"
salt = "1A2/$_4xVa"
[appearance]
title = "szurubooru"
;favicon = "/media/img/favicon.png"
;extraScripts[] = "/media/scripts/extra1.js"
;extraScripts[] = "/media/scripts/extra2.js"
;extraStyles[] = "/media/scripts/extra.css"
[misc]
featuredPostMaxDays=7
debugQueries=0

View file

@ -20,7 +20,7 @@ class GetPostContentJob extends AbstractJob
throw new SimpleException('Post file is not readable');
$fileName = sprintf('%s_%s_%s.%s',
$config->main->title,
$config->appearance->title,
$post->getId(),
join(',', array_map(function($tag) { return $tag->getName(); }, $post->getTags())),
TextHelper::resolveMimeType($post->getMimeType()) ?: 'dat');

View file

@ -14,7 +14,7 @@ class AbstractController
$this->switchLayout('layout-normal');
$this->assets = new Assets();
$this->assets->setTitle(Core::getConfig()->main->title);
$this->assets->setTitle(Core::getConfig()->appearance->title);
}
public function renderAjax()

View file

@ -16,12 +16,22 @@ class Assets extends \Chibi\Util\Assets
public function addStylesheet($path)
{
return parent::addStylesheet($this->decorateUrl('/media/css/' . $path));
return $this->addStylesheetFullPath($this->decorateUrl('/media/css/' . $path));
}
public function addStylesheetFullPath($path)
{
return parent::addStylesheet($path);
}
public function addScript($path)
{
return parent::addScript($this->decorateUrl('/media/js/' . $path));
return $this->addScriptFullPath($this->decorateUrl('/media/js/' . $path));
}
public function addScriptFullPath($path)
{
return parent::addScript($path);
}
public function transformHtml($html)

View file

@ -5,6 +5,12 @@ $this->assets->addScript('../lib/jquery/jquery.min.js');
$this->assets->addScript('../lib/jquery-ui/jquery-ui.min.js');
$this->assets->addScript('../lib/mousetrap/mousetrap.min.js');
$this->assets->addScript('core.js');
if (!empty(Core::getConfig()->appearance->extraScripts))
foreach (Core::getConfig()->appearance->extraScripts as $path)
$this->assets->addScriptFullPath($path);
if (!empty(Core::getConfig()->appearance->extraStylesheets))
foreach (Core::getConfig()->appearance->extraStylesheets as $path)
$this->assets->addStylesheetFullPath($path);
?>
<!DOCTYPE html>
@ -12,6 +18,11 @@ $this->assets->addScript('core.js');
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"/>
<?php if (!empty(Core::getConfig()->appearance->favicon)): ?>
<link rel="shortcut icon"
type="image/png"
href="<?= \Chibi\Util\Url::makeAbsolute(Core::getConfig()->appearance->favicon) ?>"/>
<?php endif ?>
</head>
<body>

View file

@ -4,7 +4,7 @@ $this->assets->addStylesheet('static-main.css');
?>
<div id="welcome">
<h1><?= Core::getConfig()->main->title ?></h1>
<h1><?= Core::getConfig()->appearance->title ?></h1>
<p>
<span>
<?php printf('serving %d posts (%s)',