Config: Rename theme_url to themes_url, add plugins_url, assets_url and assets_dir

This commit is contained in:
Daniel Rudolf 2019-04-30 15:34:11 +02:00
parent 38bb0a4ac7
commit 33117be981
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538
2 changed files with 42 additions and 8 deletions

View file

@ -12,7 +12,7 @@ timezone: UTC # Your PHP installation might require you to
# Theme # Theme
# #
theme: default # The name of your custom theme theme: default # The name of your custom theme
theme_url: ~ # Pico will try to guess the URL to the themes dir of your installation; themes_url: ~ # Pico will try to guess the URL to the themes dir of your installation;
# If this fails, override it here. Example: https://example.com/pico/themes/ # If this fails, override it here. Example: https://example.com/pico/themes/
theme_config: theme_config:
widescreen: false # Default theme: Use more horicontal space (i.e. make the site container wider) widescreen: false # Default theme: Use more horicontal space (i.e. make the site container wider)
@ -41,10 +41,15 @@ content_config:
escape: false # Escape HTML markup in your content files; don't confuse this with some sort of escape: false # Escape HTML markup in your content files; don't confuse this with some sort of
# safe mode, enabling this doesn't allow you to process untrusted user input! # safe mode, enabling this doesn't allow you to process untrusted user input!
auto_urls: true # Automatically link URLs found in your markup auto_urls: true # Automatically link URLs found in your markup
assets_dir: assets/ # The path to Pico's assets directory
assets_url: ~ # Pico will try to guess the URL to the assets dir of your installation;
# If this fails, override it here. Example: https://example.com/pico/assets/
## ##
# Plugins # Plugins
# #
plugins_url: ~ # Pico will try to guess the URL to the plugins dir of your installation;
# If this fails, override it here. Example: https://example.com/pico/plugins/
DummyPlugin.enabled: false # Force the plugin "DummyPlugin" to be disabled DummyPlugin.enabled: false # Force the plugin "DummyPlugin" to be disabled
## ##

View file

@ -910,8 +910,9 @@ class Pico
'rewrite_url' => null, 'rewrite_url' => null,
'debug' => null, 'debug' => null,
'timezone' => null, 'timezone' => null,
'plugins_url' => null,
'theme' => 'default', 'theme' => 'default',
'theme_url' => null, 'themes_url' => null,
'twig_config' => null, 'twig_config' => null,
'date_format' => '%D %T', 'date_format' => '%D %T',
'pages_order_by_meta' => 'author', 'pages_order_by_meta' => 'author',
@ -919,7 +920,9 @@ class Pico
'pages_order' => 'asc', 'pages_order' => 'asc',
'content_dir' => null, 'content_dir' => null,
'content_ext' => '.md', 'content_ext' => '.md',
'content_config' => null 'content_config' => null,
'assets_dir' => 'assets/',
'assets_url' => null
); );
if (!$this->config['base_url']) { if (!$this->config['base_url']) {
@ -943,10 +946,16 @@ class Pico
} }
date_default_timezone_set($this->config['timezone']); date_default_timezone_set($this->config['timezone']);
if (!$this->config['theme_url']) { if (!$this->config['plugins_url']) {
$this->config['theme_url'] = $this->getUrlFromPath($this->getThemesDir()); $this->config['plugins_url'] = $this->getUrlFromPath($this->getPluginsDir());
} else { } else {
$this->config['thems_url'] = $this->getAbsoluteUrl($this->config['theme_url']); $this->config['plugins_url'] = $this->getAbsoluteUrl($this->config['plugins_url']);
}
if (!$this->config['themes_url']) {
$this->config['themes_url'] = $this->getUrlFromPath($this->getThemesDir());
} else {
$this->config['themes_url'] = $this->getAbsoluteUrl($this->config['themes_url']);
} }
$defaultTwigConfig = array( $defaultTwigConfig = array(
@ -989,6 +998,18 @@ class Pico
} else { } else {
$this->config['content_config'] += $defaultContentConfig; $this->config['content_config'] += $defaultContentConfig;
} }
if (!$this->config['assets_dir']) {
$this->config['assets_dir'] = $this->getRootDir() . 'assets/';
} else {
$this->config['assets_dir'] = $this->getAbsolutePath($this->config['assets_dir']);
}
if (!$this->config['assets_url']) {
$this->config['assets_url'] = $this->getUrlFromPath($this->config['assets_dir']);
} else {
$this->config['assets_url'] = $this->getAbsoluteUrl($this->config['assets_url']);
}
} }
/** /**
@ -1486,8 +1507,13 @@ class Pico
} }
$variables['%base_url%'] = rtrim($this->getBaseUrl(), '/'); $variables['%base_url%'] = rtrim($this->getBaseUrl(), '/');
// replace %plugins_url%, %themes_url% and %assets_url%
$variables['%plugins_url%'] = rtrim($this->getConfig('plugins_url'), '/');
$variables['%themes_url%'] = rtrim($this->getConfig('themes_url'), '/');
$variables['%assets_url%'] = rtrim($this->getConfig('assets_url'), '/');
// replace %theme_url% // replace %theme_url%
$variables['%theme_url%'] = $this->getConfig('theme_url') . $this->getConfig('theme'); $variables['%theme_url%'] = $this->getConfig('themes_url') . $this->getConfig('theme');
// replace %meta.*% // replace %meta.*%
if ($meta) { if ($meta) {
@ -2005,8 +2031,11 @@ class Pico
'config' => $this->getConfig(), 'config' => $this->getConfig(),
'base_dir' => rtrim($this->getRootDir(), '/'), 'base_dir' => rtrim($this->getRootDir(), '/'),
'base_url' => rtrim($this->getBaseUrl(), '/'), 'base_url' => rtrim($this->getBaseUrl(), '/'),
'plugins_url' => rtrim($this->getConfig('plugins_url'), '/'),
'themes_url' => rtrim($this->getConfig('themes_url'), '/'),
'assets_url' => rtrim($this->getConfig('assets_url'), '/'),
'theme_dir' => $this->getThemesDir() . $this->getConfig('theme'), 'theme_dir' => $this->getThemesDir() . $this->getConfig('theme'),
'theme_url' => $this->getConfig('theme_url') . $this->getConfig('theme'), 'theme_url' => $this->getConfig('themes_url') . $this->getConfig('theme'),
'site_title' => $this->getConfig('site_title'), 'site_title' => $this->getConfig('site_title'),
'meta' => $this->meta, 'meta' => $this->meta,
'content' => $this->content, 'content' => $this->content,