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 {
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 {

View File

@ -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');

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)
{
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 "<html>\n" . $page;
exit;
}

View File

@ -1,77 +1,46 @@
<?php
$template = <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{title}}</title>
<style type="text/css">
body {
color: black;
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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $title ?></title>
<link rel="stylesheet" href="/css/admin.css">
</head>
<body><center>
<table width="90%"><tr>
<td width="150" style="border-right: solid 1px black;">
<b><u>DK Administration</u></b><br><br>
<b>Links:</b><br>
<a href="/admina">Admin Home</a><br>
<a href="/">Game Home</a><br><br>
<b>Primary Data:</b><br>
<a href="/admin/main">Main Settings</a><br>
<a href="/admin/news">Add News Post</a><br>
<a href="/admin/users">Edit Users</a><br><br>
<b>Game Data:</b><br>
<a href="/admin/items">Edit Items</a><br>
<a href="/admin/drops">Edit Drops</a><br>
<a href="/admin/towns">Edit Towns</a><br>
<a href="/admin/monsters">Edit Monsters</a><br>
<a href="/admin/levels">Edit Levels</a><br>
<a href="/admin/spells">Edit Spells</a><br>
</td><td>
{{content}}
</td></tr></table>
<br>
<table class="copyright" width="90%"><tr>
<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>
</center></body>
<body>
<div id="admin-container">
<main>
<nav>
<h1>Admin Panel</h1>
<b>Links:</b><br>
<a href="/admin">Admin Home</a><br>
<a href="/">Game Home</a><br><br>
<b>Primary Data:</b><br>
<a href="/admin/main">Main Settings</a><br>
<a href="/admin/news">Add News Post</a><br>
<a href="/admin/users">Edit Users</a><br><br>
<b>Game Data:</b><br>
<a href="/admin/items">Edit Items</a><br>
<a href="/admin/drops">Edit Drops</a><br>
<a href="/admin/towns">Edit Towns</a><br>
<a href="/admin/monsters">Edit Monsters</a><br>
<a href="/admin/level">Edit Levels</a><br>
<a href="/admin/spells">Edit Spells</a><br>
</nav>
<section>
<?= $content ?>
</section>
</main>
<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;