Implement entry page with dynamic content and update template structure

This commit is contained in:
marc-go committed 2026-10-05 19:25:13 +02:00
1 parent 1a2e1cc33f
commit 0c73ad14f5
8 files changed
+79 -6

No files matched your search

+6 -1
View File
@@ -51,7 +51,7 @@ class HTMLLoader {
die($replace);
}
function show() {
function show($args = []) {
$template = $this->template;
$file = file_get_contents(TEMPLATE_CONF);
@@ -75,6 +75,11 @@ class HTMLLoader {
$html = str_replace("%css%", $css, $html);
// Insert Args
foreach ($args as $key => $value) {
$html = str_replace($key, $value, $html);
}
die($html);
}
}
+27
View File
@@ -8,3 +8,30 @@ require "main.php";
// Init GB Class
$gb = new gb(true);
// Load HTMLLoader Library
require FRONTEND_PATH . "html_loader.php";
$htmlLoader = new HTMLLoader();
// Build Entry Page
$htmlLoader->setTemplate("entrys_frontend");
$url = "http://" . APP_DOMAIN . "/api/entrys/get.php";
$response = file_get_contents($url);
$entrys = json_decode($response, true);
$entrys = $entrys["entrys"];
$html_block = "";
foreach($entrys as $entry) {
$name = $entry["name"];
$text = $entry["text"];
$html_block .= '
<div class="entry">
<h3>' . $name . '</h3>
<p>' . $text . '</p>
</div>
';
}
$htmlLoader->show(["%entrys%" => $html_block]);
+1 -1
View File
@@ -10,7 +10,7 @@ class gb {
// Define Paths
define("APP_DOMAIN", $_SERVER["SERVER_NAME"]);
define("APP_PATH", __DIR__ . "/..");
define("APP_PATH", __DIR__ . "/../");
define("FRONTEND_PATH", __DIR__ . "/");
define("TEMPLATE_PATH", FRONTEND_PATH . "templates/");
define("TEMPLATE_CONF", TEMPLATE_PATH . "templates.json");
Whitespace-only changes.
+35
View File
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<script type="importmap">
{
"imports": {
"@material/web/": "https://esm.run/@material/web/"
}
}
</script>
<script type="module">
import '@material/web/all.js';
import {styles as typescaleStyles} from '@material/web/typography/md-typescale-styles.js';
document.adoptedStyleSheets.push(typescaleStyles.styleSheet);
</script>
<title>%appname% // Entrys</title>
<style>
:root {
--md-sys-color-primary: rgb(58, 58, 255);
}
p {
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
</style>
</head>
<body>
<h1 class="md-typescale-display-large">%appname%</h1>
<h3 class="md-typescale-display-medium">All Entrys</h3>
</body>
</html>
View File
Whitespace-only changes.
+7 -3
View File
@@ -11,8 +11,12 @@
"name":"setup",
"dir_name":"setup",
"html_file":"setup.html",
"css_files":[
"setup.css"
]
"css_files":[]
},
"entrys_frontend":{
"name":"entrys_frontend",
"dir_name":"entrys_frontend",
"html_file":"entrys_frontend.html",
"css_files":[]
}
}
+3 -1
View File
@@ -13,4 +13,6 @@
//echo "Decode: " . hash_equals($string, $secret);
print_r(PDO::getAvailableDrivers());
//print_r(PDO::getAvailableDrivers());
print_r(json_decode('{"entrys":[{"name":"marc"}]}', true));