summaryrefslogtreecommitdiffstats
path: root/internal/admin/templates/list.html
diff options
context:
space:
mode:
authorivar <i@oiee.no>2026-04-03 14:46:05 +0200
committerivar <i@oiee.no>2026-04-03 14:46:05 +0200
commita46309ac64261814d931f538fad373ea8a4f0e95 (patch)
tree6aeb1333071e433fc9e3bc7779b8b41d9e270544 /internal/admin/templates/list.html
parenta21fa502891a6d2f0600485b1b76762ecc178fd0 (diff)
downloadnebbet.no-a46309ac64261814d931f538fad373ea8a4f0e95.tar.xz
nebbet.no-a46309ac64261814d931f538fad373ea8a4f0e95.zip
feat: embed admin templates into binary with //go:embed
Move admin templates from templates/admin/*.html to internal/admin/templates/*.html and embed them using //go:embed directive. This removes the runtime dependency on having template files on disk, allowing the templates to be compiled into the binary. Changes: - Add embed import and //go:embed directive for templates - Change ParseGlob() to ParseFS() to load from embedded filesystem - Copy templates to internal/admin/templates/ for embedding Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/admin/templates/list.html')
-rw-r--r--internal/admin/templates/list.html40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/admin/templates/list.html b/internal/admin/templates/list.html
new file mode 100644
index 0000000..561e317
--- /dev/null
+++ b/internal/admin/templates/list.html
@@ -0,0 +1,40 @@
+{{define "list-content"}}
+ <h1>Posts</h1>
+ {{if .Posts}}
+ <table>
+ <thead>
+ <tr>
+ <th>Title</th>
+ <th>Date</th>
+ <th>Tags</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{range .Posts}}
+ <tr>
+ <td>{{.Title}}</td>
+ <td>{{.Date}}</td>
+ <td>
+ {{if .Tags}}
+ <div class="tags">
+ {{range (splitTags .Tags)}}<span class="tag">{{.}}</span>{{end}}
+ </div>
+ {{end}}
+ </td>
+ <td>
+ <div class="actions">
+ <a href="/admin/{{.Slug}}/edit" class="btn btn-secondary">Edit</a>
+ <form method="POST" action="/admin/{{.Slug}}/delete" onsubmit="return confirm('Delete {{.Title}}?')">
+ <button type="submit" class="btn btn-danger">Delete</button>
+ </form>
+ </div>
+ </td>
+ </tr>
+ {{end}}
+ </tbody>
+ </table>
+ {{else}}
+ <div class="empty">No posts yet. <a href="/admin/new">Create one.</a></div>
+ {{end}}
+{{end}}