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.
This commit is contained in:
are0h 2023-04-06 20:07:02 -07:00
parent 0799250b8e
commit a70bb7b2b0
20 changed files with 24 additions and 30 deletions

10
.gitignore vendored
View file

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

View file

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

View file

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

View file

Before

Width:  |  Height:  |  Size: 202 KiB

After

Width:  |  Height:  |  Size: 202 KiB

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

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