Theme folder clean up

Cleaned up the themes folder since it did not need the additional folder
depth to manage bundled scripts anymore. Updated the theme engine
accordingly.
develop
Ro 2 years ago
parent 0799250b8e
commit a70bb7b2b0

10
.gitignore vendored

@ -10,10 +10,8 @@ dist
assets assets
vendor vendor
!src/ !themes
src/* themes/*
!src/themes !themes/fipamo-default
src/themes/* !themes/fipamo-default/assets
!src/themes/theme-fipamo-default
!src/themes/theme-fipamo-default/fipamo-default/assets
config.json config.json

@ -8,9 +8,6 @@ class StartKit
{ {
$config = json_decode(file_get_contents("./config.json"), true); $config = json_decode(file_get_contents("./config.json"), true);
$theme = $config["current_theme"]; $theme = $config["current_theme"];
new ThemeEngine( new ThemeEngine("themes/" . $theme);
"src/themes/theme-" . $theme,
"/src/themes/theme-" . $theme . "/" . $theme
);
} }
} }

@ -8,14 +8,13 @@ class ThemeEngine
public $loader; public $loader;
public $twig; public $twig;
public function __construct(string $themePath, string $themeAssetPath) public function __construct(string $themePath)
{ {
$var = []; $var = [];
$this->themePath = $themePath; $this->themePath = $themePath;
$this->themeAssetPath = $themeAssetPath; //$path = explode('/', $themeAssetPath);
$path = explode('/', $themeAssetPath); //$this->themeFolder = $path[4];
$this->themeFolder = $path[4]; $this->settings = json_decode(
$this->settings = json_decode(
file_get_contents('./data/settings.json'), file_get_contents('./data/settings.json'),
true true
); );
@ -25,7 +24,7 @@ class ThemeEngine
true true
); );
$this->loader = new \Twig\Loader\FilesystemLoader( $this->loader = new \Twig\Loader\FilesystemLoader(
$themePath . '/' . $path[4] $themePath . '/'
); );
$this->twig = new \Twig\Environment($this->loader, []); $this->twig = new \Twig\Environment($this->loader, []);
$this->router($_SERVER['REQUEST_URI']); $this->router($_SERVER['REQUEST_URI']);
@ -36,7 +35,7 @@ class ThemeEngine
$pageInfo = [ $pageInfo = [
'keywords' => $this->settings['keywords'], 'keywords' => $this->settings['keywords'],
'description' => $this->settings['description'], 'description' => $this->settings['description'],
'image' => $this->themeAssetPath . '/assets/images/global/default-bg.jpg', 'image' => $this->themePath . '/assets/images/global/default-bg.jpg',
]; ];
$featureList = explode(',', $this->posts['feature']); $featureList = explode(',', $this->posts['feature']);
@ -70,10 +69,10 @@ class ThemeEngine
$pageOptions = [ $pageOptions = [
'debug' => true, // for theme kit 'debug' => true, // for theme kit
'theme' => $this->themeFolder, // for theme kit 'theme' => $this->themePath, // for theme kit
'title' => 'This is Fipamo', 'title' => 'This is Fipamo',
'dynamicRender' => $this->settings['dynamicRender'], 'dynamicRender' => $this->settings['dynamicRender'],
'background' => $this->themeAssetPath . '/assets/images/global/default-bg.jpg', 'background' => $this->themePath . '/assets/images/global/default-bg.jpg',
'recent' => $recent, 'recent' => $recent,
'featured' => $featured, 'featured' => $featured,
'info' => $pageInfo, 'info' => $pageInfo,
@ -89,10 +88,10 @@ class ThemeEngine
$template = $request . '.twig'; $template = $request . '.twig';
$pageOptions = [ $pageOptions = [
'debug' => true, // for theme kit 'debug' => true, // for theme kit
'theme' => $this->themeFolder, // for theme kit 'theme' => $this->themePath, // for theme kit
'title' => 'Page Title', 'title' => 'Page Title',
'dynamicRender' => $this->settings['dynamicRender'], 'dynamicRender' => $this->settings['dynamicRender'],
'background' => $this->themeAssetPath . '/assets/images/global/default-bg.jpg', 'background' => $this->themePath . '/assets/images/global/default-bg.jpg',
'content' => $content, 'content' => $content,
'meta' => $meta, 'meta' => $meta,
'info' => $pageInfo, 'info' => $pageInfo,
@ -106,10 +105,10 @@ class ThemeEngine
$template = 'tags.twig'; $template = 'tags.twig';
$pageOptions = [ $pageOptions = [
'debug' => true, // for theme kit 'debug' => true, // for theme kit
'theme' => $this->themeFolder, // for theme kit 'theme' => $this->themePath, // for theme kit
'title' => 'Pages Tagged as Tag', 'title' => 'Pages Tagged as Tag',
'dynamicRender' => $this->settings['dynamicRender'], 'dynamicRender' => $this->settings['dynamicRender'],
'background' => $this->themeAssetPath . '/assets/images/global/default-bg.jpg', 'background' => $this->themePath . '/assets/images/global/default-bg.jpg',
'tag_list' => $tags, 'tag_list' => $tags,
'info' => $pageInfo, 'info' => $pageInfo,
'menu' => $menu, 'menu' => $menu,
@ -120,10 +119,10 @@ class ThemeEngine
$template = 'archive.twig'; $template = 'archive.twig';
$pageOptions = [ $pageOptions = [
'debug' => true, // for theme kit 'debug' => true, // for theme kit
'theme' => $this->themeFolder, // for theme kit 'theme' => $this->themePath, // for theme kit
'title' => 'Archive', 'title' => 'Archive',
'dynamicRender' => $this->settings['dynamicRender'], 'dynamicRender' => $this->settings['dynamicRender'],
'background' => $this->themeAssetPath . '/assets/images/global/default-bg.jpg', 'background' => $this->themePath . '/assets/images/global/default-bg.jpg',
'archives' => $archive['archives'], 'archives' => $archive['archives'],
'info' => $pageInfo, 'info' => $pageInfo,
'menu' => $menu, 'menu' => $menu,
@ -137,10 +136,10 @@ class ThemeEngine
$template = 'error.twig'; $template = 'error.twig';
$pageOptions = [ $pageOptions = [
'debug' => true, // for theme kit 'debug' => true, // for theme kit
'theme' => $this->themeFolder, // for theme kit 'theme' => $this->themePath, // for theme kit
'title' => 'Uh oh', 'title' => 'Uh oh',
'dynamicRender' => $this->settings['dynamicRender'], 'dynamicRender' => $this->settings['dynamicRender'],
'background' => $this->themeAssetPath . '/assets/images/global/default-bg.jpg', 'background' => $this->themePath . '/assets/images/global/default-bg.jpg',
'info' => $pageInfo, 'info' => $pageInfo,
'content' => "This page is not defined", 'content' => "This page is not defined",
'menu' => $menu, 'menu' => $menu,

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
{% if debug is defined %} {% if debug is defined %}
{% set assetPath = '/src/themes/theme-'~theme~'/'~theme~'/assets/' %} {% set assetPath = theme~'/assets/' %}
{% else %} {% else %}
{% set assetPath = '/assets/' %} {% set assetPath = '/assets/' %}
{% endif %} {% endif %}
Loading…
Cancel
Save