mirror of https://github.com/velour/catbase.git
84 lines
2.3 KiB
Plaintext
84 lines
2.3 KiB
Plaintext
package web
|
|
|
|
import "fmt"
|
|
|
|
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" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<meta charset="UTF-8" />
|
|
if title != "" {
|
|
<title>{ w.botName() } - { title }</title>
|
|
} else {
|
|
<title>{ w.botName() }</title>
|
|
}
|
|
</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>
|
|
}
|
|
|
|
templ (w *Web) Index(title string, contents templ.Component) {
|
|
<!DOCTYPE html>
|
|
<html lang="en" class="no-js">
|
|
@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">
|
|
<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>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
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>
|
|
<td>{ fmt.Sprintf("%v", w.stats.Uptime()) }</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
} |