catbase/bot/web/index.templ

84 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

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>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/css/foundation.min.css" />
2024-02-27 19:29:54 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1" />
<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>
<script src="//cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/js/foundation.min.js"></script>
2024-02-27 19:29:54 +00:00
}
templ (w *Web) Index(title string, contents templ.Component) {
<!DOCTYPE html>
<html lang="en" class="no-js">
2024-02-27 19:29:54 +00:00
@w.Header(title)
<body>
@w.Nav(title)
if contents != nil {
@contents
}
@w.Footer()
</body>
</html>
}
templ (w *Web) Nav(currentPage string) {
<div class="top-bar">
<div class="top-bar-left">
<ul class="menu">
2024-02-28 19:32:28 +00:00
<li><a style="color: black; font-weight: bold;" href="/">{ w.botName() }</a></li>
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>
}
</li>
}
</ul>
2024-02-27 19:29:54 +00:00
</div>
</div>
2024-02-27 19:29:54 +00:00
}
2024-02-28 19:32:28 +00:00
templ (w *Web) showStats() {
<div class="grid-container">
<div class="cell">
<h2>Stats</h2>
</div>
<div class="cell">
<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>
</div>
</div>
}