mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-27 11:22:17 -05:00
some fix to courgette theme
This commit is contained in:
parent
21f50d5a08
commit
f4fbfaa7cb
@ -22,16 +22,6 @@ class Poche
|
|||||||
private $currentTheme = '';
|
private $currentTheme = '';
|
||||||
private $currentLanguage = '';
|
private $currentLanguage = '';
|
||||||
private $notInstalledMessage = array();
|
private $notInstalledMessage = array();
|
||||||
|
|
||||||
# @todo make this dynamic (actually install themes and save them in the database including author information et cetera)
|
|
||||||
private $installedThemes = array(
|
|
||||||
'default' => array('requires' => array()),
|
|
||||||
'dark' => array('requires' => array('default')),
|
|
||||||
'dmagenta' => array('requires' => array('default')),
|
|
||||||
'solarized' => array('requires' => array('default')),
|
|
||||||
'solarized-dark' => array('requires' => array('default')),
|
|
||||||
'courgette' => array('requires' => array())
|
|
||||||
);
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -124,21 +114,26 @@ class Poche
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check if the selected theme and its requirements are present
|
# Check if the selected theme and its requirements are present
|
||||||
if ($this->getTheme() != '' && ! is_dir(THEME . '/' . $this->getTheme())) {
|
$theme = $this->getTheme();
|
||||||
$this->notInstalledMessage[] = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')';
|
|
||||||
|
if ($theme != '' && ! is_dir(THEME . '/' . $theme)) {
|
||||||
|
$this->notInstalledMessage[] = 'The currently selected theme (' . $theme . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $theme . ')';
|
||||||
|
|
||||||
self::$canRenderTemplates = false;
|
self::$canRenderTemplates = false;
|
||||||
|
|
||||||
$passTheme = FALSE;
|
$passTheme = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) {
|
$themeInfo = $this->getThemeInfo($theme);
|
||||||
if (! is_dir(THEME . '/' . $requiredTheme)) {
|
if (isset($themeInfo['requirements']) && is_array($themeInfo['requirements'])) {
|
||||||
$this->notInstalledMessage[] = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')';
|
foreach ($themeInfo['requirements'] as $requiredTheme) {
|
||||||
|
if (! is_dir(THEME . '/' . $requiredTheme)) {
|
||||||
|
$this->notInstalledMessage[] = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $theme . ')';
|
||||||
|
|
||||||
self::$canRenderTemplates = false;
|
self::$canRenderTemplates = false;
|
||||||
|
|
||||||
$passTheme = FALSE;
|
$passTheme = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,32 +189,36 @@ class Poche
|
|||||||
private function initTpl()
|
private function initTpl()
|
||||||
{
|
{
|
||||||
$loaderChain = new Twig_Loader_Chain();
|
$loaderChain = new Twig_Loader_Chain();
|
||||||
|
$theme = $this->getTheme();
|
||||||
|
|
||||||
# add the current theme as first to the loader chain so Twig will look there first for overridden template files
|
# add the current theme as first to the loader chain so Twig will look there first for overridden template files
|
||||||
try {
|
try {
|
||||||
$loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $this->getTheme()));
|
$loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $theme));
|
||||||
} catch (Twig_Error_Loader $e) {
|
} catch (Twig_Error_Loader $e) {
|
||||||
# @todo isInstalled() should catch this, inject Twig later
|
# @todo isInstalled() should catch this, inject Twig later
|
||||||
die('The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (' . THEME . '/' . $this->getTheme() .' is missing)');
|
die('The currently selected theme (' . $theme . ') does not seem to be properly installed (' . THEME . '/' . $theme .' is missing)');
|
||||||
}
|
}
|
||||||
|
|
||||||
# add all required themes to the loader chain
|
# add all required themes to the loader chain
|
||||||
foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) {
|
$themeInfo = $this->getThemeInfo($theme);
|
||||||
try {
|
if (isset($themeInfo['requirements']) && is_array($themeInfo['requirements'])) {
|
||||||
$loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . DEFAULT_THEME));
|
foreach ($themeInfo['requirements'] as $requiredTheme) {
|
||||||
} catch (Twig_Error_Loader $e) {
|
try {
|
||||||
# @todo isInstalled() should catch this, inject Twig later
|
$loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $requiredTheme));
|
||||||
die('The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')');
|
} catch (Twig_Error_Loader $e) {
|
||||||
|
# @todo isInstalled() should catch this, inject Twig later
|
||||||
|
die('The required "' . $requiredTheme . '" theme is missing for the current theme (' . $theme . ')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_POCHE) {
|
if (DEBUG_POCHE) {
|
||||||
$twig_params = array();
|
$twigParams = array();
|
||||||
} else {
|
} else {
|
||||||
$twig_params = array('cache' => CACHE);
|
$twigParams = array('cache' => CACHE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tpl = new Twig_Environment($loaderChain, $twig_params);
|
$this->tpl = new Twig_Environment($loaderChain, $twigParams);
|
||||||
$this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
|
$this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
|
||||||
|
|
||||||
# filter to display domain name of an url
|
# filter to display domain name of an url
|
||||||
@ -235,7 +234,7 @@ class Poche
|
|||||||
$this->tpl->addFilter($filter);
|
$this->tpl->addFilter($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function install()
|
private function install()
|
||||||
{
|
{
|
||||||
Tools::logm('poche still not installed');
|
Tools::logm('poche still not installed');
|
||||||
echo $this->tpl->render('install.twig', array(
|
echo $this->tpl->render('install.twig', array(
|
||||||
@ -266,34 +265,59 @@ class Poche
|
|||||||
return $this->currentTheme;
|
return $this->currentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLanguage() {
|
/**
|
||||||
return $this->currentLanguage;
|
* Provides theme information by parsing theme.ini file if present in the theme's root directory.
|
||||||
|
* In all cases, the following data will be returned:
|
||||||
|
* - name: theme's name, or key if the theme is unnamed,
|
||||||
|
* - current: boolean informing if the theme is the current user theme.
|
||||||
|
*
|
||||||
|
* @param string $theme Theme key (directory name)
|
||||||
|
* @return array|boolean Theme information, or false if the theme doesn't exist.
|
||||||
|
*/
|
||||||
|
public function getThemeInfo($theme) {
|
||||||
|
if (!is_dir(THEME . '/' . $theme)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$themeIniFile = THEME . '/' . $theme . '/theme.ini';
|
||||||
|
$themeInfo = array();
|
||||||
|
|
||||||
|
if (is_file($themeIniFile) && is_readable($themeIniFile)) {
|
||||||
|
$themeInfo = parse_ini_file($themeIniFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($themeInfo === false) {
|
||||||
|
$themeInfo = array();
|
||||||
|
}
|
||||||
|
if (!isset($themeInfo['name'])) {
|
||||||
|
$themeInfo['name'] = $theme;
|
||||||
|
}
|
||||||
|
$themeInfo['current'] = ($theme === $this->getTheme());
|
||||||
|
|
||||||
|
return $themeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInstalledThemes() {
|
public function getInstalledThemes() {
|
||||||
$handle = opendir(THEME);
|
$handle = opendir(THEME);
|
||||||
$themes = array();
|
$themes = array();
|
||||||
|
|
||||||
while (($theme = readdir($handle)) !== false) {
|
while (($theme = readdir($handle)) !== false) {
|
||||||
# Themes are stored in a directory, so all directory names are themes
|
# Themes are stored in a directory, so all directory names are themes
|
||||||
# @todo move theme installation data to database
|
# @todo move theme installation data to database
|
||||||
if (! is_dir(THEME . '/' . $theme) || in_array($theme, array('..', '.'))) {
|
if (!is_dir(THEME . '/' . $theme) || in_array($theme, array('.', '..'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = false;
|
$themes[$theme] = $this->getThemeInfo($theme);
|
||||||
|
|
||||||
if ($theme === $this->getTheme()) {
|
|
||||||
$current = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$themes[] = array('name' => $theme, 'current' => $current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sort($themes);
|
|
||||||
return $themes;
|
return $themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLanguage() {
|
||||||
|
return $this->currentLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
public function getInstalledLanguages() {
|
public function getInstalledLanguages() {
|
||||||
$handle = opendir(LOCALE);
|
$handle = opendir(LOCALE);
|
||||||
$languages = array();
|
$languages = array();
|
||||||
@ -600,8 +624,8 @@ class Poche
|
|||||||
$themes = $this->getInstalledThemes();
|
$themes = $this->getInstalledThemes();
|
||||||
$actualTheme = false;
|
$actualTheme = false;
|
||||||
|
|
||||||
foreach ($themes as $theme) {
|
foreach (array_keys($themes) as $theme) {
|
||||||
if ($theme['name'] == $_POST['theme']) {
|
if ($theme == $_POST['theme']) {
|
||||||
$actualTheme = true;
|
$actualTheme = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<header>
|
<header>
|
||||||
<h1>
|
<h1>
|
||||||
{% if view == 'home' %}{% block logo %}<img src="{{ poche_url }}/themes/{{ constant('DEFAULT_THEME') }}/img/logo.png" alt="logo poche" />{% endblock %}
|
{% if view == 'home' %}{% block logo %}<img src="{{ poche_url }}/themes/{{ constant('DEFAULT_THEME') }}/img/logo.svg" alt="logo poche" />{% endblock %}
|
||||||
{% elseif view == 'fav' %}<a href="./" title="{% trans "back to home" %}" >{{ block('logo') }} <span>Favoris</span></a>
|
{% elseif view == 'fav' %}<a href="./" title="{% trans "back to home" %}" >{{ block('logo') }} <span>Favoris</span></a>
|
||||||
{% elseif view == 'archive' %}<a href="./" title="{% trans "back to home" %}" >{{ block('logo') }} <span>Archive</span></a>
|
{% elseif view == 'archive' %}<a href="./" title="{% trans "back to home" %}" >{{ block('logo') }} <span>Archive</span></a>
|
||||||
{% else %}<a href="./" title="{% trans "back to home" %}" >{{ block('logo') }}</a>
|
{% else %}<a href="./" title="{% trans "back to home" %}" >{{ block('logo') }}</a>
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col w150p" for="theme">{% trans "Theme:" %}</label>
|
<label class="col w150p" for="theme">{% trans "Theme:" %}</label>
|
||||||
<select class="col" id="theme" name="theme">
|
<select class="col" id="theme" name="theme">
|
||||||
{% for theme in themes %}
|
{% for key, theme in themes %}
|
||||||
<option value="{{ theme.name }}" {{ theme.current ? 'selected' : '' }}>{{ theme.name }}</option>
|
<option value="{{ key }}" {{ theme.current ? 'selected' : '' }}>{{ theme.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
8
themes/courgette/img/logo.svg
Normal file
8
themes/courgette/img/logo.svg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="64" height="64">
|
||||||
|
<circle cx="32" cy="32" r="29.5" style="fill:#000" />
|
||||||
|
<path d="m 16,18 33,0 0,26 -16.5,6 -16.5,-6 z" fill="#fff" />
|
||||||
|
<rect width="9" height="2.5" x="17.5" y="24.5" fill="#000" />
|
||||||
|
<rect width="9" height="2.5" x="28" y="24.5" fill="#000" />
|
||||||
|
<rect width="9" height="2.5" x="38.5" y="24.5" fill="#000" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 444 B |
3
themes/courgette/theme.ini
Normal file
3
themes/courgette/theme.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = Courgette
|
||||||
|
description = Responsive black and white theme especially adapted to smartphones.
|
||||||
|
requirements[] = default
|
2
themes/dark/theme.ini
Normal file
2
themes/dark/theme.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = Dark
|
||||||
|
requirements[] = default
|
@ -49,8 +49,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col w150p" for="theme">{% trans "Theme:" %}</label>
|
<label class="col w150p" for="theme">{% trans "Theme:" %}</label>
|
||||||
<select class="col" id="theme" name="theme">
|
<select class="col" id="theme" name="theme">
|
||||||
{% for theme in themes %}
|
{% for key, theme in themes %}
|
||||||
<option value="{{ theme.name }}" {{ theme.current ? 'selected' : '' }}>{{ theme.name }}</option>
|
<option value="{{ key }}" {{ theme.current ? 'selected' : '' }}>{{ theme.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
1
themes/default/theme.ini
Normal file
1
themes/default/theme.ini
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = Default
|
2
themes/dmagenta/theme.ini
Normal file
2
themes/dmagenta/theme.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = Dark Magenta
|
||||||
|
requirements[] = default
|
2
themes/solarized-dark/theme.ini
Normal file
2
themes/solarized-dark/theme.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = Dark Solarized
|
||||||
|
requirements[] = default
|
2
themes/solarized/theme.ini
Normal file
2
themes/solarized/theme.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = Solarized
|
||||||
|
requirements[] = default
|
Loading…
Reference in New Issue
Block a user