2021-04-21 04:20:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require "vendor/autoload.php";
|
2022-02-01 00:57:19 +01:00
|
|
|
class StartKit
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$settings = json_decode(file_get_contents("./package.json"), true);
|
|
|
|
$theme = $settings["config"]["current_theme"];
|
|
|
|
new ThemeEngine(
|
|
|
|
"src/themes/theme-" . $theme,
|
|
|
|
"/src/themes/theme-" . $theme . "/" . $theme
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-04-21 04:20:42 +02:00
|
|
|
|
|
|
|
class ThemeEngine
|
|
|
|
{
|
|
|
|
public $data = [];
|
|
|
|
public $loader;
|
|
|
|
public $twig;
|
2021-06-03 22:08:01 +02:00
|
|
|
public function __construct(string $themePath, string $themeAssetPath)
|
2021-04-21 04:20:42 +02:00
|
|
|
{
|
2021-06-03 22:08:01 +02:00
|
|
|
$this->themePath = $themePath;
|
|
|
|
$this->themeAssetPath = $themeAssetPath;
|
|
|
|
$path = explode("/", $themeAssetPath);
|
|
|
|
$this->themeFolder = $path[4];
|
2021-04-21 04:20:42 +02:00
|
|
|
$this->data = json_decode(file_get_contents("./config.json"), true);
|
2022-02-06 00:27:02 +01:00
|
|
|
$this->loader = new \Twig\Loader\FilesystemLoader(
|
|
|
|
$themePath . "/" . $path[4]
|
|
|
|
);
|
2021-04-21 04:20:42 +02:00
|
|
|
$this->twig = new \Twig\Environment($this->loader, []);
|
|
|
|
$this->router($_SERVER["REQUEST_URI"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function router(string $request)
|
|
|
|
{
|
2021-04-21 22:42:23 +02:00
|
|
|
$pageInfo = [
|
|
|
|
"keywords" => $this->data["keywords"],
|
|
|
|
"description" => $this->data["description"],
|
2021-06-03 22:08:01 +02:00
|
|
|
"image" => $this->themeAssetPath . "/assets/images/global/default-bg.jpg",
|
2021-04-21 22:42:23 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
$menu = $this->data["menu"];
|
2021-04-21 04:20:42 +02:00
|
|
|
switch ($request) {
|
|
|
|
case "/":
|
2021-04-21 08:14:49 +02:00
|
|
|
$recent = $this->data["recent_posts"];
|
|
|
|
$featured = $this->data["featured_posts"];
|
2022-02-06 00:27:02 +01:00
|
|
|
$template = "index.twig";
|
|
|
|
$content = $this->data["index-content"];
|
2021-04-21 22:42:23 +02:00
|
|
|
|
|
|
|
$pageOptions = [
|
2022-02-06 00:27:02 +01:00
|
|
|
"debug" => true, //for theme kit
|
|
|
|
"theme" => $this->themeFolder, //for theme kit
|
2021-04-21 22:42:23 +02:00
|
|
|
"title" => "This is Fipamo",
|
|
|
|
"background" =>
|
2021-06-03 22:08:01 +02:00
|
|
|
$this->themeAssetPath . "/assets/images/global/default-bg.jpg",
|
2021-04-21 22:42:23 +02:00
|
|
|
"recent" => $recent,
|
|
|
|
"featured" => $featured,
|
|
|
|
"info" => $pageInfo,
|
|
|
|
"menu" => $menu,
|
2022-02-06 00:27:02 +01:00
|
|
|
"content" => $content,
|
2021-04-21 22:42:23 +02:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case "/page":
|
|
|
|
$content = $this->data["content"];
|
|
|
|
$meta = $this->data["meta"];
|
2022-02-06 00:27:02 +01:00
|
|
|
$template = $request . ".twig";
|
2021-04-21 22:42:23 +02:00
|
|
|
$pageOptions = [
|
2022-02-06 00:27:02 +01:00
|
|
|
"debug" => true, //for theme kit
|
|
|
|
"theme" => $this->themeFolder, //for theme kit
|
2021-04-21 22:42:23 +02:00
|
|
|
"title" => "Page Title",
|
|
|
|
"background" =>
|
2021-06-03 22:08:01 +02:00
|
|
|
$this->themeAssetPath . "/assets/images/global/default-bg.jpg",
|
2021-04-21 22:42:23 +02:00
|
|
|
"content" => $content,
|
|
|
|
"meta" => $meta,
|
|
|
|
"info" => $pageInfo,
|
|
|
|
"menu" => $menu,
|
|
|
|
];
|
2021-04-21 04:20:42 +02:00
|
|
|
break;
|
2021-04-21 21:47:15 +02:00
|
|
|
case "/tags":
|
|
|
|
$tags = $this->data["tag_list"];
|
2021-06-03 22:08:01 +02:00
|
|
|
$template = $this->themeFolder . "/tags.twig";
|
2021-04-21 22:42:23 +02:00
|
|
|
$pageOptions = [
|
2022-02-06 00:27:02 +01:00
|
|
|
"debug" => true, //for theme kit
|
|
|
|
"theme" => $this->themeFolder, //for theme kit
|
2021-04-21 22:42:23 +02:00
|
|
|
"title" => "Pages Tagged as Tag",
|
|
|
|
"background" =>
|
2021-06-03 22:08:01 +02:00
|
|
|
$this->themeAssetPath . "/assets/images/global/default-bg.jpg",
|
2021-04-21 22:42:23 +02:00
|
|
|
"tag_list" => $tags,
|
|
|
|
"info" => $pageInfo,
|
|
|
|
"menu" => $menu,
|
|
|
|
];
|
|
|
|
break;
|
2021-04-21 04:20:42 +02:00
|
|
|
case "/archive":
|
|
|
|
$archive = $this->data["archives"];
|
2021-06-03 22:08:01 +02:00
|
|
|
$template = $this->themeFolder . "/archive.twig";
|
2021-04-21 22:42:23 +02:00
|
|
|
$pageOptions = [
|
2022-02-06 00:27:02 +01:00
|
|
|
"debug" => true, //for theme kit
|
|
|
|
"theme" => $this->themeFolder, //for theme kit
|
2021-04-21 22:42:23 +02:00
|
|
|
"title" => "Archive",
|
|
|
|
"background" =>
|
2021-06-03 22:08:01 +02:00
|
|
|
$this->themeAssetPath . "/assets/images/global/default-bg.jpg",
|
2021-04-21 22:42:23 +02:00
|
|
|
"archives" => $archive,
|
|
|
|
"info" => $pageInfo,
|
|
|
|
"menu" => $menu,
|
|
|
|
];
|
2021-04-21 04:20:42 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
http_response_code(404);
|
|
|
|
require __DIR__ . "/views/404.php";
|
|
|
|
break;
|
|
|
|
}
|
2021-04-21 22:42:23 +02:00
|
|
|
|
|
|
|
echo $this->twig->render($template, $pageOptions);
|
2021-04-21 04:20:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 00:57:19 +01:00
|
|
|
new StartKit();
|