Implement entry page with dynamic content and update template structure
This commit is contained in:
1 parent
1a2e1cc33f
commit
0c73ad14f5
8 files changed
+79
-6
No files matched your search
@@ -51,7 +51,7 @@ class HTMLLoader {
|
|||||||
die($replace);
|
die($replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show($args = []) {
|
||||||
$template = $this->template;
|
$template = $this->template;
|
||||||
|
|
||||||
$file = file_get_contents(TEMPLATE_CONF);
|
$file = file_get_contents(TEMPLATE_CONF);
|
||||||
@@ -75,6 +75,11 @@ class HTMLLoader {
|
|||||||
|
|
||||||
$html = str_replace("%css%", $css, $html);
|
$html = str_replace("%css%", $css, $html);
|
||||||
|
|
||||||
|
// Insert Args
|
||||||
|
foreach ($args as $key => $value) {
|
||||||
|
$html = str_replace($key, $value, $html);
|
||||||
|
}
|
||||||
|
|
||||||
die($html);
|
die($html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,3 +8,30 @@ require "main.php";
|
|||||||
// Init GB Class
|
// Init GB Class
|
||||||
$gb = new gb(true);
|
$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
@@ -10,7 +10,7 @@ class gb {
|
|||||||
|
|
||||||
// Define Paths
|
// Define Paths
|
||||||
define("APP_DOMAIN", $_SERVER["SERVER_NAME"]);
|
define("APP_DOMAIN", $_SERVER["SERVER_NAME"]);
|
||||||
define("APP_PATH", __DIR__ . "/..");
|
define("APP_PATH", __DIR__ . "/../");
|
||||||
define("FRONTEND_PATH", __DIR__ . "/");
|
define("FRONTEND_PATH", __DIR__ . "/");
|
||||||
define("TEMPLATE_PATH", FRONTEND_PATH . "templates/");
|
define("TEMPLATE_PATH", FRONTEND_PATH . "templates/");
|
||||||
define("TEMPLATE_CONF", TEMPLATE_PATH . "templates.json");
|
define("TEMPLATE_CONF", TEMPLATE_PATH . "templates.json");
|
||||||
|
|||||||
Whitespace-only changes.
+35
@@ -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>
|
||||||
Whitespace-only changes.
@@ -11,8 +11,12 @@
|
|||||||
"name":"setup",
|
"name":"setup",
|
||||||
"dir_name":"setup",
|
"dir_name":"setup",
|
||||||
"html_file":"setup.html",
|
"html_file":"setup.html",
|
||||||
"css_files":[
|
"css_files":[]
|
||||||
"setup.css"
|
},
|
||||||
]
|
"entrys_frontend":{
|
||||||
|
"name":"entrys_frontend",
|
||||||
|
"dir_name":"entrys_frontend",
|
||||||
|
"html_file":"entrys_frontend.html",
|
||||||
|
"css_files":[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-1
@@ -13,4 +13,6 @@
|
|||||||
|
|
||||||
//echo "Decode: " . hash_equals($string, $secret);
|
//echo "Decode: " . hash_equals($string, $secret);
|
||||||
|
|
||||||
print_r(PDO::getAvailableDrivers());
|
//print_r(PDO::getAvailableDrivers());
|
||||||
|
|
||||||
|
print_r(json_decode('{"entrys":[{"name":"marc"}]}', true));
|
||||||
Reference in new issue
Block a user