From d79fb0f0ce4744974d45d7d4e80c3af8c2cca717 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Sun, 21 Jul 2024 13:23:33 +0200 Subject: Switch to more flexible params system and add active navlink state --- common.php | 22 +++++++++++----------- src/pages/about.php | 3 ++- src/pages/index.php | 3 ++- src/pages/not_found.php | 2 +- src/static/nava.gif | Bin 0 -> 1778 bytes src/static/style.css | 8 ++++++++ src/template.php | 13 +++++++++---- 7 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 src/static/nava.gif diff --git a/common.php b/common.php index c505660..cba823a 100644 --- a/common.php +++ b/common.php @@ -2,19 +2,19 @@ define("SRCDIR", realpath(__DIR__ . "/src/")); -function hzcom_expand(string $__page): string { - $title = ""; - $__page = preg_replace_callback( - ';(.*?);i', - function(array $matches) use(&$title): string { - $title = $matches[1]; +function hzcom_expand(string $pageContents): string { + $params = []; + $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; + file_put_contents($page, preg_replace_callback( + "/" . + "(?'paramValue'.*?)<\/param:\\1\s*>/s", + function(array $matches) use (&$params) { + $params[$matches['paramName']] = $matches['paramValue']; return ""; }, - $__page - ); - $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; - file_put_contents($page, $__page); - unset($__page); + $pageContents + )); + unset($pageContents); ob_start(); include SRCDIR . "/template.php"; diff --git a/src/pages/about.php b/src/pages/about.php index 99d8e25..9e7b31b 100644 --- a/src/pages/about.php +++ b/src/pages/about.php @@ -9,7 +9,8 @@ $age = date_diff( ?> -About me +About me +about

About me

diff --git a/src/pages/index.php b/src/pages/index.php index 3b15088..cb9b417 100644 --- a/src/pages/index.php +++ b/src/pages/index.php @@ -1,3 +1,4 @@ -hozyro's site +hozyro's site +home diff --git a/src/pages/not_found.php b/src/pages/not_found.php index b71d6c3..abe4c3f 100644 --- a/src/pages/not_found.php +++ b/src/pages/not_found.php @@ -1,2 +1,2 @@ -Not found +Not found

The requested page could not be found.

diff --git a/src/static/nava.gif b/src/static/nava.gif new file mode 100644 index 0000000..005f34b Binary files /dev/null and b/src/static/nava.gif differ diff --git a/src/static/style.css b/src/static/style.css index 0b94ca4..1c1cd5e 100644 --- a/src/static/style.css +++ b/src/static/style.css @@ -53,6 +53,14 @@ a { color: #05456a; background: url("navh.gif"); } +.navCell.active { + border-left-color: #000; + border-right-color: #7d9cb0; +} +.navCell.active a { + color: #fffca2; + background: url("nava.gif"); +} #mainCell { border: 1px solid #000; border-top: none; diff --git a/src/template.php b/src/template.php index 6e2ad0c..ca781b9 100644 --- a/src/template.php +++ b/src/template.php @@ -1,9 +1,14 @@ - + (($params["active-link"] ?? null) === $ln) ? ' active' : ''; + +?> - <?= htmlentities($title) ?> + <?= htmlentities($params["title"] ?? "") ?> @@ -27,7 +32,7 @@ - -