index.tml to namespan

main
bel 2025-05-04 11:36:56 -06:00
parent f2e828a9eb
commit dbfd33f55e
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,11 @@
<html> <html>
<header> <header>
<link rel="stylesheet" href="/experimental/ui/dark.css"> <link rel="stylesheet" href="/experimental/ui/dark.css">
<script>
fill(elem) {
}
</script>
</header> </header>
<body> <body>
<h2>Feeds</h2> <h2>Feeds</h2>
@ -8,7 +13,7 @@
<div> <div>
{{ range feeds }} {{ range feeds }}
<div> <div>
<h4>{{ .Version.URL }}</h4> <h4>(<button onclick="fill(this)">{{ namespan "entry.id" .Entry.ID}}</button>) {{ namespan "version.url" .Version.URL }}</h4>
<div>{{ .Version.Created }} (last {{ .Execution.Executed }})</div> <div>{{ .Version.Created }} (last {{ .Execution.Executed }})</div>
<div>@{{ .Version.Cron }} ~"{{ .Version.Pattern }}"</div> <div>@{{ .Version.Cron }} ~"{{ .Version.Pattern }}"</div>
<div>{{ .Version.WebhookMethod }} {{ .Version.WebhookURL }} | {{ .Version.WebhookBody }}</div> <div>{{ .Version.WebhookMethod }} {{ .Version.WebhookURL }} | {{ .Version.WebhookBody }}</div>

View File

@ -2,12 +2,13 @@ package handler
import ( import (
"encoding/json" "encoding/json"
"html/template" "fmt"
"net/http" "net/http"
"os" "os"
"path" "path"
"show-rss/src/feeds" "show-rss/src/feeds"
"slices" "slices"
"text/template"
) )
var dir = func() string { var dir = func() string {
@ -51,6 +52,9 @@ func (h Handler) uiIndex(w http.ResponseWriter, r *http.Request) error {
slices.Sort(ks) slices.Sort(ks)
return ks return ks
}, },
"namespan": func(k string, v any) string {
return fmt.Sprintf("<span name=%q>%s</span>", k, v)
},
}) })
tmpl, err := tmpl.Parse(string(b)) tmpl, err := tmpl.Parse(string(b))