From 812891a205fab43d6e537e8000f192b8bbffc034 Mon Sep 17 00:00:00 2001 From: schreifuchs Date: Tue, 29 Sep 2026 10:46:45 +0200 Subject: [PATCH] fix(gallery): use component template --- .gitea/workflows/release.yaml | 8 ++++++++ internal/handlers/restgallery/controller.go | 4 ++-- internal/handlers/restgallery/resource.go | 3 ++- internal/handlers/resthome/controller.go | 4 ++-- internal/handlers/resthome/resource.go | 2 +- web/layouts/base.templ | 10 ++++++++-- web/layouts/render.go | 20 +++++++++++++------- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index e7500cb..4b079f6 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -27,3 +27,11 @@ jobs: file: ./Dockerfile push: true tags: "git.schreifuchs.ch/schreifuchs/schreifuchs.ch:${{ github.ref_name }},git.schreifuchs.ch/schreifuchs/schreifuchs.ch:latest" + - name: Create Gitea Release + uses: https://gitea.com/actions/gitea-release-action@v1 + with: + state: "published" + title: "Release ${{ github.ref_name }}" + notes: "Automated release for tag ${{ github.ref_name }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/internal/handlers/restgallery/controller.go b/internal/handlers/restgallery/controller.go index 91b25a8..2e3762a 100644 --- a/internal/handlers/restgallery/controller.go +++ b/internal/handlers/restgallery/controller.go @@ -27,7 +27,7 @@ func (h *Handler) gallery(w http.ResponseWriter, r *http.Request) { ctx = templer.AppendHeader(ctx, fmt.Sprintf(``, image.URL())) } - h.r.Render(ctx, w, r, pages.GallerySet(imgs)) + h.r.RenderPage(ctx, w, r, pages.GallerySet(imgs)) } func (h *Handler) image(w http.ResponseWriter, r *http.Request) { @@ -41,5 +41,5 @@ func (h *Handler) image(w http.ResponseWriter, r *http.Request) { return } - h.r.Render(r.Context(), w, r, pages.GalleryImage(uid, next, prev)) + h.r.RenderComponent(r.Context(), w, r, pages.GalleryImage(uid, next, prev)) } diff --git a/internal/handlers/restgallery/resource.go b/internal/handlers/restgallery/resource.go index 35d5d2b..35fb053 100644 --- a/internal/handlers/restgallery/resource.go +++ b/internal/handlers/restgallery/resource.go @@ -40,5 +40,6 @@ type galleryService interface { GetPrevAndNext(ctx context.Context, uid string) (previous *gallery.Image, next *gallery.Image, err error) } type renderer interface { - Render(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) + RenderPage(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) + RenderComponent(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) } diff --git a/internal/handlers/resthome/controller.go b/internal/handlers/resthome/controller.go index 9a5afa2..9e20367 100644 --- a/internal/handlers/resthome/controller.go +++ b/internal/handlers/resthome/controller.go @@ -17,7 +17,7 @@ func (h *Handler) home(w http.ResponseWriter, r *http.Request) { return } - h.r.Render(r.Context(), w, r, pages.Home(pageHeaders)) + h.r.RenderPage(r.Context(), w, r, pages.Home(pageHeaders)) } func (h *Handler) page(w http.ResponseWriter, r *http.Request) { @@ -43,5 +43,5 @@ func (h *Handler) page(w http.ResponseWriter, r *http.Request) { ctx = templer.PageTitle(ctx, page.Title) - h.r.Render(ctx, w, r, pages.ContentPage(page)) + h.r.RenderPage(ctx, w, r, pages.ContentPage(page)) } diff --git a/internal/handlers/resthome/resource.go b/internal/handlers/resthome/resource.go index ee5fb28..6ca4efb 100644 --- a/internal/handlers/resthome/resource.go +++ b/internal/handlers/resthome/resource.go @@ -33,5 +33,5 @@ type pageService interface { GetPage(ctx context.Context, uid string) (page.Page, error) } type renderer interface { - Render(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) + RenderPage(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) } diff --git a/web/layouts/base.templ b/web/layouts/base.templ index 13fb5a7..1180953 100644 --- a/web/layouts/base.templ +++ b/web/layouts/base.templ @@ -23,7 +23,6 @@ templ head(cfg config.Cfg, title string) { @templ.Raw(h) } - { children... } } templ Base(cfg config.Cfg, title string) { @@ -38,13 +37,20 @@ templ Base(cfg config.Cfg, title string) { } -templ Content(cfg config.Cfg, title string) { +templ Page(cfg config.Cfg, title string) { @head(cfg, title) @body() { { children... } } } +templ Component() { + for _, h := range templer.GetHeader(ctx) { + @templ.Raw(h) + } + { children... } +} + templ body() {