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>
<meta charset="UTF-8">
<title>Witaj świecie! - {TITLE}</title>
{CSS}
{JS}
<meta name="author" content="{AUTHOR}">
</head>
<body>
+8 -6
View File
@@ -2,12 +2,14 @@
namespace BlogEngine {
class Dictionary {
public $page_tags = [
"posts" => "{POSTS}",
"links" => "{LINKS}",
"tags" => "{TAGS}",
"title" => "{TITLE}",
"author" => "{AUTHOR}",
"description" => "{DESCRIPTION}"
"{POSTS}" => "",
"{LINKS}" => "",
"{TAGS}" => "",
"{TITLE}" => "Tytuł",
"{AUTHOR}" => "lorem",
"{DESCRIPTION}" => "",
"{JS}" => "",
"{CSS}" => ""
];
}
}