diff --git a/app/src/main.go b/app/src/main.go index 407fba0..6fabc32 100644 --- a/app/src/main.go +++ b/app/src/main.go @@ -9,6 +9,8 @@ import ( "mime" "net/http" "os" + + "github.com/a-h/templ" ) // bundled static assets + admin UI (served under /web/) @@ -47,6 +49,9 @@ func main() { http.HandleFunc("/admin/media/upload", func(w http.ResponseWriter, r *http.Request) { s.mediaUpload(w, r) }) + http.HandleFunc("/admin/media", func(w http.ResponseWriter, r *http.Request) { + templ.Handler(AdminMediaPage()).ServeHTTP(w, r) + }) http.HandleFunc("/subjects/{slug}", func(w http.ResponseWriter, r *http.Request) { s.subject(w, r, r.PathValue("slug")) }) diff --git a/app/src/templates.templ b/app/src/templates.templ index fc89718..13fbc99 100644 --- a/app/src/templates.templ +++ b/app/src/templates.templ @@ -299,4 +299,40 @@ templ NewsletterCard() { templ AdminRedirect() { +} + +// AdminMediaPage is a browser-based media uploader that posts to +// /admin/media/upload (which stores into Garage S3 via minio-go) and +// returns the {{media:...}} snippet to paste into an article. +templ AdminMediaPage() { + + + + + + Kontra — Media Library + + + +
+
+ + +
+
+
+
+

Media Library

+
+ Upload an image — it is stored in Garage S3 and served at /media/<file>. + A {{media:...}} snippet is shown to paste into an article. +
+ +
+
+ + } \ No newline at end of file