Took 33 minutes
This commit is contained in:
Krzysztof 'KrzysiekSiemv' Smaga
2023-04-25 11:02:52 +02:00
parent 41fa19344b
commit e9216f1710
5 changed files with 37 additions and 6 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
require "vendor/blog-engine/php/Dictionary.php";
$dictionary = new \BlogEngine\Dictionary();
$src = __DIR__ . "/src/";
$html = scandir($src . "views");
$css = scandir($src . "css");
$js = scandir($src . "js");
for($i = 2; $i < count($html); $i++){
$site = file_get_contents($src . "views/" . $html[$i]);
foreach (array_keys($dictionary->page_tags) as $page_tag){
if($page_tag = "{CSS}"){
for($j = 2; $j < count($css); $j++)
$dictionary->page_tags[$page_tag] .= "<link rel='stylesheet' href='public/css/{$css[$j]}' />";
}
if($page_tag = "{JS}"){
for($j = 2; $j < count($js); $j++)
$dictionary->page_tags[$page_tag] .= "<script src='public/js/{$js[$j]}'></script>";
}
$site = str_replace($page_tag, $dictionary->page_tags[$page_tag], $site);
}
echo $site;
}
View File
View File
+2
View File
@@ -3,6 +3,8 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Witaj świecie! - {TITLE}</title> <title>Witaj świecie! - {TITLE}</title>
{CSS}
{JS}
<meta name="author" content="{AUTHOR}"> <meta name="author" content="{AUTHOR}">
</head> </head>
<body> <body>
+8 -6
View File
@@ -2,12 +2,14 @@
namespace BlogEngine { namespace BlogEngine {
class Dictionary { class Dictionary {
public $page_tags = [ public $page_tags = [
"posts" => "{POSTS}", "{POSTS}" => "",
"links" => "{LINKS}", "{LINKS}" => "",
"tags" => "{TAGS}", "{TAGS}" => "",
"title" => "{TITLE}", "{TITLE}" => "Tytuł",
"author" => "{AUTHOR}", "{AUTHOR}" => "lorem",
"description" => "{DESCRIPTION}" "{DESCRIPTION}" => "",
"{JS}" => "",
"{CSS}" => ""
]; ];
} }
} }