Admin now uses new renderer and has it's own CSS and layout.

This commit is contained in:
Sky Johnson 2024-12-14 13:31:23 -06:00
parent 3152cca51f
commit 10fa8e423a
5 changed files with 116 additions and 87 deletions

66
public/css/admin.css Normal file
View File

@ -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;
}

View File

@ -4,7 +4,7 @@
html { html {
font-size: var(--font-size); font-size: var(--font-size);
font-family: Verdana, Geneva, Tahoma, sans-serif; font-family: sans-serif;
} }
body { body {
@ -99,7 +99,7 @@ a:hover {
} }
.small { .small {
font: 10px verdana; font-size: 0.8rem;
} }
.highlight { .highlight {
@ -116,7 +116,7 @@ a:hover {
font-weight: bold; font-weight: bold;
padding: 5px; padding: 5px;
font-size: 1.2rem; font-size: 1.2rem;
font-family: 'Times New Roman', Times, serif; font-family: serif;
} }
.copyright { .copyright {

View File

@ -26,7 +26,7 @@ function register_routes(Router $r): Router
$r->get('/admin/monsters', 'Admin\monsters'); $r->get('/admin/monsters', 'Admin\monsters');
$r->form('/admin/monsters/:id', 'Admin\editmonster'); $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->form('/admin/level/:id', 'Admin\editlevel');
$r->get('/admin/spells', 'Admin\spells'); $r->get('/admin/spells', 'Admin\spells');

View File

@ -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) function admindisplay($content, $title)
{ {
global $userrow, $controlrow; global $controlrow;
if (!isset($controlrow)) {
$query = db()->query('SELECT * FROM control WHERE id=1 LIMIT 1;');
$controlrow = $query->fetchArray(SQLITE3_ASSOC);
}
$page = parsetemplate(gettemplate("admin"), [ echo render('admin', [
"title" => $title, "title" => $title,
"content" => $content, "content" => $content,
"totaltime" => round(getmicrotime() - START, 4), "totaltime" => round(getmicrotime() - START, 4),
@ -114,8 +110,6 @@ function admindisplay($content, $title)
"build" => BUILD "build" => BUILD
]); ]);
echo "<html>\n" . $page;
exit; exit;
} }

View File

@ -1,77 +1,46 @@
<?php <!DOCTYPE html>
$template = <<<HTML <html lang="en">
<head> <head>
<title>{{title}}</title> <meta charset="UTF-8">
<style type="text/css"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
body { <title><?= $title ?></title>
color: black; <link rel="stylesheet" href="/css/admin.css">
font: 11px verdana;
}
table {
border-style: none;
padding: 0px;
font: 11px verdana;
}
td {
border-style: none;
padding: 3px;
vertical-align: top;
}
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;
}
.copyright {
border: solid 1px black;
background-color: #eeeeee;
font: 10px verdana;
}
</style>
</head> </head>
<body><center> <body>
<table width="90%"><tr> <div id="admin-container">
<td width="150" style="border-right: solid 1px black;"> <main>
<b><u>DK Administration</u></b><br><br> <nav>
<h1>Admin Panel</h1>
<b>Links:</b><br> <b>Links:</b><br>
<a href="/admina">Admin Home</a><br> <a href="/admin">Admin Home</a><br>
<a href="/">Game Home</a><br><br> <a href="/">Game Home</a><br><br>
<b>Primary Data:</b><br> <b>Primary Data:</b><br>
<a href="/admin/main">Main Settings</a><br> <a href="/admin/main">Main Settings</a><br>
<a href="/admin/news">Add News Post</a><br> <a href="/admin/news">Add News Post</a><br>
<a href="/admin/users">Edit Users</a><br><br> <a href="/admin/users">Edit Users</a><br><br>
<b>Game Data:</b><br> <b>Game Data:</b><br>
<a href="/admin/items">Edit Items</a><br> <a href="/admin/items">Edit Items</a><br>
<a href="/admin/drops">Edit Drops</a><br> <a href="/admin/drops">Edit Drops</a><br>
<a href="/admin/towns">Edit Towns</a><br> <a href="/admin/towns">Edit Towns</a><br>
<a href="/admin/monsters">Edit Monsters</a><br> <a href="/admin/monsters">Edit Monsters</a><br>
<a href="/admin/levels">Edit Levels</a><br> <a href="/admin/level">Edit Levels</a><br>
<a href="/admin/spells">Edit Spells</a><br> <a href="/admin/spells">Edit Spells</a><br>
</td><td> </nav>
{{content}}
</td></tr></table> <section>
<br> <?= $content ?>
<table class="copyright" width="90%"><tr> </section>
<td width="25%" align="center">Powered by <a href="http://dragon.se7enet.com/dev.php" target="_new">Dragon Knight</a></td><td width="25%" align="center">&copy; 2003-2006 by renderse7en</td><td width="25%" align="center">{{totaltime}} Seconds, {{numqueries}} Queries</td><td width="25%" align="center">Version {{version}} {{build}}</td> </main>
</center></body>
<footer>
<div>Powered by <a href="/" target="_new">Dragon Knight</a></div>
<div>&copy; 2024 Sharkk</div>
<div><?= $totaltime ?> Seconds, <?= $numqueries ?> Queries</div>
<div>Version <?= $version ?> <?= $build ?></div>
</footer>
</div>
</body>
</html> </html>
HTML;