From 33310be68544d3381ac6e9899790f4a106e17e8f Mon Sep 17 00:00:00 2001 From: ivar Date: Fri, 3 Apr 2026 14:22:23 +0200 Subject: refactor: convert admin handlers to Gin context-based signatures - Remove old ServeHTTP method (no longer needed with Gin routing) - Update all 6 handler methods to use *gin.Context instead of http.ResponseWriter, *http.Request - Convert handler signatures: handleList, handleNew, handleNewPost, handleEdit, handleDelete - Remove render() helper (use c.HTML() directly) - Update renderError() to accept gin.Context instead of http.ResponseWriter - Update postFromForm() to extract form data from gin.Context using c.PostForm() - Update main.go to use adminSrv.NewServer() and adminSrv.Engine() - All handlers now use Gin methods: c.HTML(), c.PostForm(), c.Param(), c.Redirect() - Path parameters now extracted via c.Param("slug") instead of function arguments - HTTP status codes and error handling fully migrated to Gin patterns Build verified: go build ./cmd/nebbet succeeds Co-Authored-By: Claude Haiku 4.5 --- templates/admin/base.html | 34 +++++++++++++++++++++++++ templates/admin/error.html | 7 ++++++ templates/admin/form.html | 62 ++++++++++++++++++++++++++++++++++++++++++++++ templates/admin/list.html | 40 ++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 templates/admin/base.html create mode 100644 templates/admin/error.html create mode 100644 templates/admin/form.html create mode 100644 templates/admin/list.html (limited to 'templates/admin') diff --git a/templates/admin/base.html b/templates/admin/base.html new file mode 100644 index 0000000..f88bba6 --- /dev/null +++ b/templates/admin/base.html @@ -0,0 +1,34 @@ +{{define "base"}} + + + + + + + Admin — {{.Title}} + + + + + + + +
+ {{if eq .ContentTemplate "list-content"}}{{template "list-content" .}}{{end}} + {{if eq .ContentTemplate "form-content"}}{{template "form-content" .}}{{end}} + {{if eq .ContentTemplate "error-content"}}{{template "error-content" .}}{{end}} +
+ + + +{{end}} \ No newline at end of file diff --git a/templates/admin/error.html b/templates/admin/error.html new file mode 100644 index 0000000..36a4a8a --- /dev/null +++ b/templates/admin/error.html @@ -0,0 +1,7 @@ +{{define "error-content"}} +
+

Error

+

{{.Message}}

+

Go back

+
+{{end}} diff --git a/templates/admin/form.html b/templates/admin/form.html new file mode 100644 index 0000000..1b577c9 --- /dev/null +++ b/templates/admin/form.html @@ -0,0 +1,62 @@ +{{define "form-content"}} +

{{.Title}}

+
+ + + + + + + + +

Comma-separated list of tags.

+ + + +
+ +
+ + Cancel +
+
+ + + + +{{end}} diff --git a/templates/admin/list.html b/templates/admin/list.html new file mode 100644 index 0000000..561e317 --- /dev/null +++ b/templates/admin/list.html @@ -0,0 +1,40 @@ +{{define "list-content"}} +

Posts

+ {{if .Posts}} + + + + + + + + + + + {{range .Posts}} + + + + + + + {{end}} + +
TitleDateTags
{{.Title}}{{.Date}} + {{if .Tags}} +
+ {{range (splitTags .Tags)}}{{.}}{{end}} +
+ {{end}} +
+
+ Edit +
+ +
+
+
+ {{else}} +
No posts yet. Create one.
+ {{end}} +{{end}} -- cgit v1.3