From 10fa8e423a051df25421712072e4384feb420e82 Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Sat, 14 Dec 2024 13:31:23 -0600 Subject: [PATCH] Admin now uses new renderer and has it's own CSS and layout. --- public/css/admin.css | 66 ++++++++++++++++++++++++ public/css/dk.css | 6 +-- src/actions/admin.php | 2 +- src/lib.php | 12 ++--- templates/admin.php | 117 ++++++++++++++++-------------------------- 5 files changed, 116 insertions(+), 87 deletions(-) create mode 100644 public/css/admin.css diff --git a/public/css/admin.css b/public/css/admin.css new file mode 100644 index 0000000..7202e9b --- /dev/null +++ b/public/css/admin.css @@ -0,0 +1,66 @@ +:root { + --font-size: 12px; +} + +html { + font-size: var(--font-size); + font-family: sans-serif; +} + +div#admin-container { + max-width: 1280px; + margin: 0 auto; + padding: 1rem; +} + +main { + display: flex; + gap: 2rem; + margin-bottom: 2rem; +} + +main > nav { + flex: 0 0 auto; +} + +main > section { + flex: 1; +} + +table { + width: 100%; +} + +a { + color: #663300; + text-decoration: none; + font-weight: bold; +} +a:hover { + color: #330000; +} +.small { + font: 10px verdana; +} +.highlight { + color: red; +} +.light { + color: #999999; +} +.title { + border: solid 1px black; + background-color: #eeeeee; + font-weight: bold; + padding: 5px; + margin: 3px; +} + +footer { + display: flex; + justify-content: space-around; + border: solid 1px black; + background-color: #eeeeee; + font-size: 0.8rem; + padding: 0.5rem; +} diff --git a/public/css/dk.css b/public/css/dk.css index 76d3131..b699a30 100644 --- a/public/css/dk.css +++ b/public/css/dk.css @@ -4,7 +4,7 @@ html { font-size: var(--font-size); - font-family: Verdana, Geneva, Tahoma, sans-serif; + font-family: sans-serif; } body { @@ -99,7 +99,7 @@ a:hover { } .small { - font: 10px verdana; + font-size: 0.8rem; } .highlight { @@ -116,7 +116,7 @@ a:hover { font-weight: bold; padding: 5px; font-size: 1.2rem; - font-family: 'Times New Roman', Times, serif; + font-family: serif; } .copyright { diff --git a/src/actions/admin.php b/src/actions/admin.php index 2dac18b..c0c30af 100644 --- a/src/actions/admin.php +++ b/src/actions/admin.php @@ -26,7 +26,7 @@ function register_routes(Router $r): Router $r->get('/admin/monsters', 'Admin\monsters'); $r->form('/admin/monsters/:id', 'Admin\editmonster'); - $r->get('/admin/level', 'Admin\levels'); + $r->form('/admin/level', 'Admin\levels'); $r->form('/admin/level/:id', 'Admin\editlevel'); $r->get('/admin/spells', 'Admin\spells'); diff --git a/src/lib.php b/src/lib.php index 0bfa07b..5355ec5 100644 --- a/src/lib.php +++ b/src/lib.php @@ -95,17 +95,13 @@ function make_safe(string $content): string } /** - * Finalize page and output to browser. + * Finalize admin page and output to browser. */ function admindisplay($content, $title) { - global $userrow, $controlrow; - if (!isset($controlrow)) { - $query = db()->query('SELECT * FROM control WHERE id=1 LIMIT 1;'); - $controlrow = $query->fetchArray(SQLITE3_ASSOC); - } + global $controlrow; - $page = parsetemplate(gettemplate("admin"), [ + echo render('admin', [ "title" => $title, "content" => $content, "totaltime" => round(getmicrotime() - START, 4), @@ -114,8 +110,6 @@ function admindisplay($content, $title) "build" => BUILD ]); - echo "\n" . $page; - exit; } diff --git a/templates/admin.php b/templates/admin.php index c5f3807..061d76f 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -1,77 +1,46 @@ - + -{{title}} - + + + <?= $title ?> + -
- -
-DK Administration

-Links:
-Admin Home
-Game Home

-Primary Data:
-Main Settings
-Add News Post
-Edit Users

-Game Data:
-Edit Items
-Edit Drops
-Edit Towns
-Edit Monsters
-Edit Levels
-Edit Spells
-
-{{content}} -
-
- - - + +
+
+ + +
+ +
+
+ +
+
Powered by Dragon Knight
+
© 2024 Sharkk
+
Seconds, Queries
+
Version
+
+
+ -HTML;