Compare commits

...

2 Commits

Author SHA1 Message Date
Chris Sexton d9342f184e web: make cards display in grid 2024-05-21 12:36:33 -04:00
Chris Sexton 87bf26e039 web: refactor site into picocss from foundation 2024-05-21 08:54:12 -04:00
14 changed files with 371 additions and 352 deletions

View File

@ -4,8 +4,24 @@ 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" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.min.css" type="text/css" />
<style>
.navTitle {
text-style: none;
color: var(--pico-h1-color);
}
input:invalid {
border: 2px dashed red;
}
button {
padding: 5px;
}
</style>
<meta charset="UTF-8" />
if title != "" {
<title>{ w.botName() } - { title }</title>
@ -17,8 +33,6 @@ templ (w *Web) Header(title string) {
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) {
@ -29,41 +43,42 @@ templ (w *Web) Index(title string, contents templ.Component) {
@w.Nav(title)
if contents != nil {
@contents
}
<main class="container-fluid">
if contents != nil {
@contents
}
</main>
@w.Footer()
<footer>
@w.Footer()
</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>
<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>
}
</ul>
</div>
</div>
</li>
}
</ul>
</nav>
</header>
}
templ (w *Web) showStats() {
<div class="grid-container">
<div class="cell">
<h2>Stats</h2>
</div>
<div class="cell">
<table>
<tr>
@ -79,6 +94,4 @@ templ (w *Web) showStats() {
<td>{ w.stats.Uptime() }</td>
</tr>
</table>
</div>
</div>
}

View File

@ -25,7 +25,7 @@ func (w *Web) Header(title string) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<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\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css\"><link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.min.css\" type=\"text/css\"><style>\n .navTitle {\n text-style: none;\n color: var(--pico-h1-color);\n }\n input:invalid {\n border: 2px dashed red;\n }\n button {\n padding: 5px;\n }\n </style><meta charset=\"UTF-8\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -37,7 +37,7 @@ func (w *Web) Header(title string) templ.Component {
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(w.botName())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 10, Col: 32}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 26, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
@ -50,7 +50,7 @@ func (w *Web) Header(title string) templ.Component {
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 10, Col: 44}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 26, Col: 44}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
@ -68,7 +68,7 @@ func (w *Web) Header(title string) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(w.botName())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 12, Col: 32}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 28, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@ -103,7 +103,7 @@ func (w *Web) Footer() templ.Component {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<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_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"//unpkg.com/htmx.org@1.9.10\" integrity=\"sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC\" crossorigin=\"anonymous\"></script>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -143,17 +143,25 @@ func (w *Web) Index(title string, contents templ.Component) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<main class=\"container-fluid\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if contents != nil {
templ_7745c5c3_Err = contents.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main><footer>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = w.Footer().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></html>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</footer></body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -177,20 +185,20 @@ func (w *Web) Nav(currentPage string) templ.Component {
templ_7745c5c3_Var7 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"top-bar\"><div class=\"top-bar-left\"><ul class=\"menu\"><li><a style=\"color: black; font-weight: bold;\" href=\"/\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><nav style=\"margin-right: 2em; margin-left: 2em\"><ul><li><strong><a href=\"/\" class=\"navTitle\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(w.botName())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 45, Col: 86}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 62, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></li>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></strong></li></ul><ul>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -216,7 +224,7 @@ func (w *Web) Nav(currentPage string) templ.Component {
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(item.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 49, Col: 109}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 68, Col: 101}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
if templ_7745c5c3_Err != nil {
@ -243,7 +251,7 @@ func (w *Web) Nav(currentPage string) templ.Component {
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(item.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 51, Col: 71}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 70, Col: 63}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
@ -259,7 +267,7 @@ func (w *Web) Nav(currentPage string) templ.Component {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul></div></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul></nav></header>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -283,14 +291,14 @@ func (w *Web) showStats() templ.Component {
templ_7745c5c3_Var13 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-container\"><div class=\"cell\"><h2>Stats</h2></div><div class=\"cell\"><table><tr><td>Messages Seen</td><td>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>Stats</h2><table><tr><td>Messages Seen</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", w.stats.MessagesRcv))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 70, Col: 56}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 85, Col: 56}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
@ -303,7 +311,7 @@ func (w *Web) showStats() templ.Component {
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", w.stats.MessagesSent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 74, Col: 57}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 89, Col: 57}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
@ -316,13 +324,13 @@ func (w *Web) showStats() templ.Component {
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(w.stats.Uptime())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 78, Col: 34}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 93, Col: 34}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr></table></div></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr></table>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@ -3,60 +3,46 @@ package admin
import "fmt"
templ (a *AdminPlugin) page() {
<div class="grid-container">
<form>
<div class="grid-x grid-margin-x align-bottom">
<h2>App Pass</h2>
</div>
<div class="grid-x grid-margin-x align-bottom">
<div class="cell auto">
<label for="password">Password:
<input type="text" name="password"></input>
</label>
</div>
<div class="cell auto">
<label for="secret">Secret:
<input type="text" name="secret"></input>
</label>
</div>
<div class="cell auto">
<button hx-post="/apppass/api" hx-target="#data" class="button">List</button>
<button hx-put="/apppass/api" hx-target="#data" class="submit success button">New</button>
</div>
</div>
<form>
<h2>App Pass</h2>
<label for="password">Password:
<input type="text" name="password"></input>
</label>
<label for="secret">Secret:
<input type="text" name="secret"></input>
</label>
<button hx-post="/apppass/api" hx-target="#data" class="button">List</button>
<button hx-put="/apppass/api" hx-target="#data" class="submit success button">New</button>
<div class="grid-x">
<div class="cell" id="data"></div>
</div>
</form>
</div>
<div style="margin-top: 2em" class="cell" id="data"></div>
</form>
}
templ (a *AdminPlugin) showPassword(entry PassEntry) {
<div><span style="margin-right: 2em">ID</span><span>{ fmt.Sprintf(" %d", entry.ID) }</span></div>
<div><span style="margin-right: 2em">Password</span><span> { entry.Secret }:{ entry.Pass }</span></div>
<h2>New Entry</h2>
<p>ID: { fmt.Sprintf(" %d", entry.ID) }</p>
<p>Password: { entry.Secret }:{ entry.Pass }</p>
}
templ (a *AdminPlugin) entries(items []PassEntry) {
<div>
if len(items) == 0 {
<span>No items</span>
}
<ul>
for _, entry := range items {
<li>
<button href="#"
class="button alert tiny"
style="vertical-align: baseline"
hx-delete="/apppass/api"
hx-confirm={ fmt.Sprintf("Are you sure you want to delete %d?", entry.ID) }
hx-target="#data"
name="id" value={ fmt.Sprintf("%d", entry.ID) }>X</button>
{ fmt.Sprintf("%d", entry.ID) }
</li>
}
</ul>
</div>
<h2>Entry List</h2>
if len(items) == 0 {
<p>No items</p>
}
<ul>
for _, entry := range items {
<li>
<button href="#"
class="button alert tiny"
style="vertical-align: baseline"
hx-delete="/apppass/api"
hx-confirm={ fmt.Sprintf("Are you sure you want to delete %d?", entry.ID) }
hx-target="#data"
name="id" value={ fmt.Sprintf("%d", entry.ID) }>X</button>
{ fmt.Sprintf("%d", entry.ID) }
</li>
}
</ul>
}
templ renderError(err error) {
@ -64,27 +50,25 @@ templ renderError(err error) {
}
templ vars(items []configEntry) {
<div class="container">
<h2>Variables</h2>
<table class="hover striped">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
for _, item := range items {
<tr>
<td>{ item.Key }</td><td>{ item.Value }</td>
</tr>
}
if len(items) == 0 {
<tr>
<td colspan="2">No data</td>
</tr>
}
</tbody>
</table>
</div>
<h2>Variables</h2>
<table class="hover striped">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
for _, item := range items {
<tr>
<td>{ item.Key }</td><td>{ item.Value }</td>
</tr>
}
if len(items) == 0 {
<tr>
<td colspan="2">No data</td>
</tr>
}
</tbody>
</table>
}

View File

@ -25,7 +25,7 @@ func (a *AdminPlugin) page() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-container\"><form><div class=\"grid-x grid-margin-x align-bottom\"><h2>App Pass</h2></div><div class=\"grid-x grid-margin-x align-bottom\"><div class=\"cell auto\"><label for=\"password\">Password: <input type=\"text\" name=\"password\"></label></div><div class=\"cell auto\"><label for=\"secret\">Secret: <input type=\"text\" name=\"secret\"></label></div><div class=\"cell auto\"><button hx-post=\"/apppass/api\" hx-target=\"#data\" class=\"button\">List</button> <button hx-put=\"/apppass/api\" hx-target=\"#data\" class=\"submit success button\">New</button></div></div><div class=\"grid-x\"><div class=\"cell\" id=\"data\"></div></div></form></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form><h2>App Pass</h2><label for=\"password\">Password: <input type=\"text\" name=\"password\"></label> <label for=\"secret\">Secret: <input type=\"text\" name=\"secret\"></label> <button hx-post=\"/apppass/api\" hx-target=\"#data\" class=\"button\">List</button> <button hx-put=\"/apppass/api\" hx-target=\"#data\" class=\"submit success button\">New</button><div style=\"margin-top: 2em\" class=\"cell\" id=\"data\"></div></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -49,27 +49,27 @@ func (a *AdminPlugin) showPassword(entry PassEntry) templ.Component {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div><span style=\"margin-right: 2em\">ID</span><span>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>New Entry</h2><p>ID: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(" %d", entry.ID))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 35, Col: 86}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 22, Col: 41}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div><div><span style=\"margin-right: 2em\">Password</span><span>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>Password: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(entry.Secret)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 36, Col: 77}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 23, Col: 31}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@ -82,13 +82,13 @@ func (a *AdminPlugin) showPassword(entry PassEntry) templ.Component {
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(entry.Pass)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 36, Col: 92}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 23, Col: 46}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -112,12 +112,12 @@ func (a *AdminPlugin) entries(items []PassEntry) templ.Component {
templ_7745c5c3_Var6 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>Entry List</h2>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if len(items) == 0 {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<span>No items</span>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p>No items</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -150,7 +150,7 @@ func (a *AdminPlugin) entries(items []PassEntry) templ.Component {
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", entry.ID))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 54, Col: 57}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 41, Col: 49}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
@ -161,7 +161,7 @@ func (a *AdminPlugin) entries(items []PassEntry) templ.Component {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -192,7 +192,7 @@ func renderError(err error) templ.Component {
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(err.Error())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 62, Col: 22}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 48, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
@ -222,7 +222,7 @@ func vars(items []configEntry) templ.Component {
templ_7745c5c3_Var10 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"container\"><h2>Variables</h2><table class=\"hover striped\"><thead><tr><th>Key</th><th>Value</th></tr></thead> <tbody>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>Variables</h2><table class=\"hover striped\"><thead><tr><th>Key</th><th>Value</th></tr></thead> <tbody>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -234,7 +234,7 @@ func vars(items []configEntry) templ.Component {
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(item.Key)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 78, Col: 38}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 63, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
if templ_7745c5c3_Err != nil {
@ -247,7 +247,7 @@ func vars(items []configEntry) templ.Component {
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(item.Value)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 78, Col: 61}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/admin/admin.templ`, Line: 63, Col: 53}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
@ -264,7 +264,7 @@ func vars(items []configEntry) templ.Component {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tbody></table></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tbody></table>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@ -9,31 +9,26 @@ func urlFor(who, what, dir string) string {
func (p *CounterPlugin) allItems() map[string][]Item {
items, err := GetAllItemsByUser(p.db)
if err != nil {
return map[string][]Item{"error": []Item{}}
return map[string][]Item{"error": {}}
}
return items
}
templ (p *CounterPlugin) index() {
<div class="grid-container">
<div class="grid-x">
<h2>Counter</h2>
</div>
<div class="grid-x">
<div class="input-group">
<span class="input-group-label">Password</span>
<input class="input-group-field" type="text" name="password" />
</div>
</div>
<table>
for user, items := range p.allItems() {
<h2>Counter</h2>
<label>Password
<input class="input-group-field" type="text" name="password" />
</label>
<table class="striped">
for user, items := range p.allItems() {
<thead>
<tr><th class="text-left" colspan="3">{ user }</th></tr>
for _, thing := range items {
@p.renderItem(user, thing)
}
</thead>
for _, thing := range items {
@p.renderItem(user, thing)
}
</table>
</div>
}
</table>
}
templ (p *CounterPlugin) renderItem(user string, item Item) {

View File

@ -19,7 +19,7 @@ func urlFor(who, what, dir string) string {
func (p *CounterPlugin) allItems() map[string][]Item {
items, err := GetAllItemsByUser(p.db)
if err != nil {
return map[string][]Item{"error": []Item{}}
return map[string][]Item{"error": {}}
}
return items
}
@ -37,25 +37,25 @@ func (p *CounterPlugin) index() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-container\"><div class=\"grid-x\"><h2>Counter</h2></div><div class=\"grid-x\"><div class=\"input-group\"><span class=\"input-group-label\">Password</span> <input class=\"input-group-field\" type=\"text\" name=\"password\"></div></div><table>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>Counter</h2><label>Password <input class=\"input-group-field\" type=\"text\" name=\"password\"></label><table class=\"striped\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for user, items := range p.allItems() {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr><th class=\"text-left\" colspan=\"3\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<thead><tr><th class=\"text-left\" colspan=\"3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/counter/counter.templ`, Line: 29, Col: 60}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/counter/counter.templ`, Line: 24, Col: 60}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th></tr>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th></tr></thead> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -66,7 +66,7 @@ func (p *CounterPlugin) index() templ.Component {
}
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</table></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</table>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -105,7 +105,7 @@ func (p *CounterPlugin) renderItem(user string, item Item) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(item.Item)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/counter/counter.templ`, Line: 41, Col: 23}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/counter/counter.templ`, Line: 36, Col: 23}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@ -118,7 +118,7 @@ func (p *CounterPlugin) renderItem(user string, item Item) templ.Component {
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", item.Count))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/counter/counter.templ`, Line: 44, Col: 43}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/counter/counter.templ`, Line: 39, Col: 43}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {

View File

@ -207,6 +207,18 @@ func InvertEmojyList(emojy map[string]string) map[string]string {
return out
}
func (p *EmojyPlugin) allCountsFlat(threshold int) ([]EmojyCount, error) {
emoji, err := p.allCounts(threshold)
if err != nil {
return nil, err
}
output := []EmojyCount{}
for _, v := range emoji {
output = append(output, v...)
}
return output, nil
}
func (p *EmojyPlugin) allCounts(threshold int) (map[string][]EmojyCount, error) {
out := map[string][]EmojyCount{}
onServerList := InvertEmojyList(p.b.GetEmojiList(true))

View File

@ -1,35 +1,29 @@
package emojy
templ (p *EmojyPlugin) listTempl(emojy emojyMap) {
<div class="grid-container">
<div class="grid-x">
<div class="cell">
<h2>Emojy</h2>
</div>
</div>
<div class="grid-x">
<div class="cell">
@p.emojyNav()
</div>
</div>
<div class="grid-x grid-margin-x small-up-3 medium-up-6 large-up-8">
for _, v := range emojy {
for _, c := range v {
<div class="cell">
<div class="card"
style="max-width: 100px">
<img src={ c.URL }
style="max-height: 100px"
style="max-width: 100px"
alt={ c.Emojy }
/>
<div class="card-divider">
{ c.Emojy }
</div>
</div>
</div>
}
}
templ (p *EmojyPlugin) listTempl(emojy []EmojyCount) {
<h1>Emojy</h1>
@p.emojyNav()
<div class="row">
for _, e := range emojy {
<div class="col-xs">
<div class="box">@p.listItem(e)</div>
</div>
}
</div>
}
}
templ (p *EmojyPlugin) listItem(e EmojyCount) {
<article
style="width: 100px">
<img src={ e.URL }
style="max-height: 100px"
style="max-width: 100px"
alt={ e.Emojy }
/>
<footer>
{ e.Emojy }
</footer>
</article>
}

View File

@ -10,7 +10,7 @@ import "context"
import "io"
import "bytes"
func (p *EmojyPlugin) listTempl(emojy emojyMap) templ.Component {
func (p *EmojyPlugin) listTempl(emojy []EmojyCount) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
@ -23,7 +23,7 @@ func (p *EmojyPlugin) listTempl(emojy emojyMap) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-container\"><div class=\"grid-x\"><div class=\"cell\"><h2>Emojy</h2></div></div><div class=\"grid-x\"><div class=\"cell\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h1>Emojy</h1>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -31,48 +31,78 @@ func (p *EmojyPlugin) listTempl(emojy emojyMap) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div><div class=\"grid-x grid-margin-x small-up-3 medium-up-6 large-up-8\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"row\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, v := range emojy {
for _, c := range v {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"cell\"><div class=\"card\" style=\"max-width: 100px\"><img src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(c.URL))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" style=\"max-height: 100px\" style=\"max-width: 100px\" alt=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(c.Emojy))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div class=\"card-divider\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(c.Emojy)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/emojy/list.templ`, Line: 26, Col: 33}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, e := range emojy {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"col-xs\"><div class=\"box\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = p.listItem(e).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func (p *EmojyPlugin) listItem(e EmojyCount) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var2 := templ.GetChildren(ctx)
if templ_7745c5c3_Var2 == nil {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<article style=\"width: 100px\"><img src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(e.URL))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" style=\"max-height: 100px\" style=\"max-width: 100px\" alt=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(e.Emojy))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><footer>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(e.Emojy)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/emojy/list.templ`, Line: 25, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</footer></article>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@ -43,7 +43,7 @@ func (p *EmojyPlugin) handleUploadForm(w http.ResponseWriter, r *http.Request) {
func (p *EmojyPlugin) handleList(w http.ResponseWriter, r *http.Request) {
threshold := p.c.GetInt("emojy.statthreshold", 1)
emojy, err := p.allCounts(threshold)
emojy, err := p.allCountsFlat(threshold)
if err != nil {
fmt.Fprintf(w, "Error: %s", err)
return

View File

@ -1,94 +1,81 @@
package meme
templ (p *MemePlugin) index(all webResps) {
<div class="grid-container">
<h2>Meme</h2>
<h2>New Meme</h2>
<form>
<div class="grid-x grid-margin-x">
<div class="cell auto">
<input type="text" name="name" placeholder="Name..." />
</div>
<div class="cell auto">
<input type="text" name="url" placeholder="URL..." />
</div>
<div class="cell auto">
<textarea name="config">
</textarea>
</div>
<div class="cell small-2">
<button class="button"
hx-post="/meme/add"
hx-target="#newMemes"
>Save</button>
</div>
</div>
<input type="text" name="name" placeholder="Name..." />
<input type="text" name="url" placeholder="URL..." />
<textarea name="config">
</textarea>
<button class="button"
hx-post="/meme/add"
hx-target="#newMemes"
>Save</button>
</form>
<h2>Current Memes</h2>
<div id="newMemes">
</div>
<div class="row">
for _, meme := range all {
@p.Show(meme)
<div class="col-xs">
<div class="box">@p.Show(meme)</div>
</div>
}
</div>
}
templ (p *MemePlugin) Show(meme webResp) {
<div class="grid-x grid-margin-x" id={ meme.Name }>
<div class="cell small-3">
<div class="card"
style="max-width: 200px">
<img
class="thumbnail"
style="max-height: 250px; max-width: 250px;"
alt={ meme.Name }
src={ meme.URL } />
<div class="card-divider">
<p>{ meme.Name }</p>
</div>
</div>
</div>
<div class="cell small-7">
<pre>
{ meme.Config }
</pre>
</div>
<div class="cell small-2">
<button class="button"
hx-get={ "/meme/edit/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Edit</button>
</div>
</div>
<article id={ meme.Name } style="width: 300px">
<header>
<img
class="thumbnail"
style="max-height: 300px; max-width: 300px;"
alt={ meme.Name }
src={ meme.URL } />
<p>{ meme.Name }</p>
</header>
<pre style="max-width: 300px; overflow: auto">
{ meme.Config }
</pre>
<footer>
<button class="button"
hx-get={ "/meme/edit/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Edit</button>
</footer>
</article>
}
templ (p *MemePlugin) Edit(meme webResp) {
<form>
<div class="grid-x grid-margin-x" id={ meme.Name }>
<div class="cell-small-3">
<img
class="thumbnail"
style="max-height: 150px"
alt={ meme.Name }
src={ meme.URL } />
</div>
<div class="cell small-7">
<textarea name="config" rows="10">
{ meme.Config }
</textarea>
<input type="text" name="url" value={ meme.URL } />
</div>
<div class="cell small-2">
<button class="button"
hx-put={ "/meme/save/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Save</button>
<button class="button alert"
hx-delete={ "/meme/rm/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Delete</button>
</div>
</div>
<form style="width: 300px">
<article id={ meme.Name }>
<header>
<img
class="thumbnail"
style="max-height: 250px"
alt={ meme.Name }
src={ meme.URL } />
</header>
<textarea name="config" rows="10">
{ meme.Config }
</textarea>
<input type="text" name="url" value={ meme.URL } />
<footer>
<button class="button"
hx-put={ "/meme/save/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Save</button>
<button class="button alert"
hx-delete={ "/meme/rm/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Delete</button>
</footer>
</article>
</form>
}

View File

@ -23,15 +23,23 @@ func (p *MemePlugin) index(all webResps) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-container\"><h2>Meme</h2><form><div class=\"grid-x grid-margin-x\"><div class=\"cell auto\"><input type=\"text\" name=\"name\" placeholder=\"Name...\"></div><div class=\"cell auto\"><input type=\"text\" name=\"url\" placeholder=\"URL...\"></div><div class=\"cell auto\"><textarea name=\"config\"></textarea></div><div class=\"cell small-2\"><button class=\"button\" hx-post=\"/meme/add\" hx-target=\"#newMemes\">Save</button></div></div></form><div id=\"newMemes\"></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>New Meme</h2><form><input type=\"text\" name=\"name\" placeholder=\"Name...\"> <input type=\"text\" name=\"url\" placeholder=\"URL...\"> <textarea name=\"config\"></textarea> <button class=\"button\" hx-post=\"/meme/add\" hx-target=\"#newMemes\">Save</button></form><h2>Current Memes</h2><div id=\"newMemes\"></div><div class=\"row\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, meme := range all {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"col-xs\"><div class=\"box\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = p.Show(meme).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
@ -57,7 +65,7 @@ func (p *MemePlugin) Show(meme webResp) templ.Component {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-x grid-margin-x\" id=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<article id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -65,7 +73,7 @@ func (p *MemePlugin) Show(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div class=\"cell small-3\"><div class=\"card\" style=\"max-width: 200px\"><img class=\"thumbnail\" style=\"max-height: 250px; max-width: 250px;\" alt=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" style=\"width: 300px\"><header><img class=\"thumbnail\" style=\"max-height: 300px; max-width: 300px;\" alt=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -81,33 +89,33 @@ func (p *MemePlugin) Show(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div class=\"card-divider\"><p>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(meme.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/meme/meme.templ`, Line: 44, Col: 34}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/meme/meme.templ`, Line: 37, Col: 26}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div></div></div><div class=\"cell small-7\"><pre>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></header><pre style=\"max-width: 300px; overflow: auto\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(meme.Config)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/meme/meme.templ`, Line: 50, Col: 29}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/meme/meme.templ`, Line: 40, Col: 25}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre></div><div class=\"cell small-2\"><button class=\"button\" hx-get=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre><footer><button class=\"button\" hx-get=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -123,7 +131,7 @@ func (p *MemePlugin) Show(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Edit</button></div></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Edit</button></footer></article>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -147,7 +155,7 @@ func (p *MemePlugin) Edit(meme webResp) templ.Component {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form><div class=\"grid-x grid-margin-x\" id=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form style=\"width: 300px\"><article id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -155,7 +163,7 @@ func (p *MemePlugin) Edit(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div class=\"cell-small-3\"><img class=\"thumbnail\" style=\"max-height: 150px\" alt=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><header><img class=\"thumbnail\" style=\"max-height: 250px\" alt=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -171,14 +179,14 @@ func (p *MemePlugin) Edit(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><div class=\"cell small-7\"><textarea name=\"config\" rows=\"10\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></header><textarea name=\"config\" rows=\"10\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(meme.Config)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/meme/meme.templ`, Line: 75, Col: 29}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/meme/meme.templ`, Line: 63, Col: 25}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
@ -192,7 +200,7 @@ func (p *MemePlugin) Edit(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><div class=\"cell small-2\"><button class=\"button\" hx-put=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><footer><button class=\"button\" hx-put=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -224,7 +232,7 @@ func (p *MemePlugin) Edit(meme webResp) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Delete</button></div></div></form>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Delete</button></footer></article></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@ -3,38 +3,26 @@ package secrets
import "fmt"
templ (s *SecretsPlugin) index() {
<div class="grid-container">
<form hx-post="/secrets/add" hx-target="#data">
<div class="grid-x">
<h2>Secrets</h2>
</div>
<div class="grid-x">
<div class="cell auto">
<div class="input-group">
<span class="input-group-label">Key</span>
<input class="input-group-field" placeholder="Key..." name="key" />
</div>
</div>
<div class="cell auto">
<div class="input-group">
<span class="input-group-label">Value</span>
<input class="input-group-field" placeholder="Value..." name="value" />
<div class="input-group-button">
<button class="button primary" type="submit">Add Secret</button>
</div>
</div>
</div>
</div>
</form>
<div class="grid-x grid-margin-x">
<div id="data">
@s.keysList()
</div>
</div>
<h2>Secrets</h2>
<form hx-post="/secrets/add" hx-target="#data">
<fieldset>
<label>Key
<input class="input-group-field" placeholder="Key..." name="key" />
</label>
<label>Value
<input class="input-group-field" placeholder="Value..." name="value" />
</label>
</fieldset>
<button class="button primary" type="submit">Add Secret</button>
</form>
<div id="data" style="margin-top: 2em">
@s.keysList()
</div>
}
templ (s *SecretsPlugin) keysList() {
<h2>Keys List</h2>
<ul class="no-bullet">
for _, key := range s.keys() {
<li>

View File

@ -25,7 +25,7 @@ func (s *SecretsPlugin) index() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid-container\"><form hx-post=\"/secrets/add\" hx-target=\"#data\"><div class=\"grid-x\"><h2>Secrets</h2></div><div class=\"grid-x\"><div class=\"cell auto\"><div class=\"input-group\"><span class=\"input-group-label\">Key</span> <input class=\"input-group-field\" placeholder=\"Key...\" name=\"key\"></div></div><div class=\"cell auto\"><div class=\"input-group\"><span class=\"input-group-label\">Value</span> <input class=\"input-group-field\" placeholder=\"Value...\" name=\"value\"><div class=\"input-group-button\"><button class=\"button primary\" type=\"submit\">Add Secret</button></div></div></div></div></form><div class=\"grid-x grid-margin-x\"><div id=\"data\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>Secrets</h2><form hx-post=\"/secrets/add\" hx-target=\"#data\"><fieldset><label>Key <input class=\"input-group-field\" placeholder=\"Key...\" name=\"key\"></label> <label>Value <input class=\"input-group-field\" placeholder=\"Value...\" name=\"value\"></label></fieldset><button class=\"button primary\" type=\"submit\">Add Secret</button></form><div id=\"data\" style=\"margin-top: 2em\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -33,7 +33,7 @@ func (s *SecretsPlugin) index() templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -57,7 +57,7 @@ func (s *SecretsPlugin) keysList() templ.Component {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<ul class=\"no-bullet\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>Keys List</h2><ul class=\"no-bullet\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -85,7 +85,7 @@ func (s *SecretsPlugin) keysList() templ.Component {
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(key)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/secrets/secrets.templ`, Line: 48, Col: 17}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/secrets/secrets.templ`, Line: 36, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {