2024-02-27 19:29:54 +00:00
|
|
|
package web
|
|
|
|
|
2024-02-28 19:32:28 +00:00
|
|
|
import "fmt"
|
|
|
|
|
2024-02-27 19:29:54 +00:00
|
|
|
templ (w *Web) Header(title string) {
|
|
|
|
<head>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
2024-05-17 15:27:46 +00:00
|
|
|
<link
|
|
|
|
rel="stylesheet"
|
|
|
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
|
|
|
/>
|
|
|
|
<style>
|
|
|
|
.navTitle {
|
|
|
|
text-style: none;
|
|
|
|
color: var(--pico-h1-color);
|
|
|
|
}
|
|
|
|
input:invalid {
|
|
|
|
border: 2px dashed red;
|
|
|
|
}
|
|
|
|
button {
|
|
|
|
padding: 5px;
|
|
|
|
}
|
|
|
|
</style>
|
2024-02-27 19:29:54 +00:00
|
|
|
<meta charset="UTF-8" />
|
|
|
|
if title != "" {
|
2024-02-28 15:43:24 +00:00
|
|
|
<title>{ w.botName() } - { title }</title>
|
2024-02-27 19:29:54 +00:00
|
|
|
} else {
|
2024-02-28 15:43:24 +00:00
|
|
|
<title>{ w.botName() }</title>
|
2024-02-27 19:29:54 +00:00
|
|
|
}
|
|
|
|
</head>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ (w *Web) Footer() {
|
|
|
|
<script src="//unpkg.com/htmx.org@1.9.10" integrity="sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC" crossorigin="anonymous"></script>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ (w *Web) Index(title string, contents templ.Component) {
|
2024-02-28 14:39:38 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en" class="no-js">
|
2024-02-27 19:29:54 +00:00
|
|
|
@w.Header(title)
|
|
|
|
<body>
|
|
|
|
|
|
|
|
@w.Nav(title)
|
|
|
|
|
2024-05-17 15:27:46 +00:00
|
|
|
<main class="container-fluid">
|
|
|
|
if contents != nil {
|
|
|
|
@contents
|
|
|
|
}
|
|
|
|
</main>
|
2024-02-27 19:29:54 +00:00
|
|
|
|
2024-05-17 15:27:46 +00:00
|
|
|
<footer>
|
|
|
|
@w.Footer()
|
|
|
|
</footer>
|
2024-02-27 19:29:54 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ (w *Web) Nav(currentPage string) {
|
2024-05-17 15:27:46 +00:00
|
|
|
<header>
|
|
|
|
<nav style="margin-right: 2em; margin-left: 2em">
|
|
|
|
<ul>
|
|
|
|
<li><strong><a href="/" class="navTitle">{ w.botName() }</a></strong></li>
|
|
|
|
</ul>
|
|
|
|
<ul>
|
|
|
|
for _, item := range w.GetWebNavigation() {
|
|
|
|
<li>
|
|
|
|
if currentPage == item.Name {
|
|
|
|
<a class="is-active" aria-current="page" href={ templ.URL(item.URL) }>{ item.Name }</a>
|
|
|
|
} else {
|
|
|
|
<a href={ templ.URL(item.URL) }>{ item.Name }</a>
|
2024-02-28 14:39:38 +00:00
|
|
|
}
|
2024-05-17 15:27:46 +00:00
|
|
|
</li>
|
|
|
|
}
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</header>
|
2024-02-27 19:29:54 +00:00
|
|
|
}
|
2024-02-28 19:32:28 +00:00
|
|
|
|
|
|
|
templ (w *Web) showStats() {
|
|
|
|
<h2>Stats</h2>
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td>Messages Seen</td>
|
|
|
|
<td>{ fmt.Sprintf("%d", w.stats.MessagesRcv) }</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Messages Sent</td>
|
|
|
|
<td>{ fmt.Sprintf("%d", w.stats.MessagesSent) }</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Uptime</td>
|
2024-02-28 22:05:23 +00:00
|
|
|
<td>{ w.stats.Uptime() }</td>
|
2024-02-28 19:32:28 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
}
|