Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
812891a205 |
No files matched your search
@@ -27,3 +27,11 @@ jobs:
|
|||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: "git.schreifuchs.ch/schreifuchs/schreifuchs.ch:${{ github.ref_name }},git.schreifuchs.ch/schreifuchs/schreifuchs.ch:latest"
|
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 }}
|
||||||
@@ -27,7 +27,7 @@ func (h *Handler) gallery(w http.ResponseWriter, r *http.Request) {
|
|||||||
ctx = templer.AppendHeader(ctx, fmt.Sprintf(`<link rel="preload" href="%s?w=800" as="image" />`, image.URL()))
|
ctx = templer.AppendHeader(ctx, fmt.Sprintf(`<link rel="preload" href="%s?w=800" as="image" />`, 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) {
|
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
|
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))
|
||||||
}
|
}
|
||||||
@@ -40,5 +40,6 @@ type galleryService interface {
|
|||||||
GetPrevAndNext(ctx context.Context, uid string) (previous *gallery.Image, next *gallery.Image, err error)
|
GetPrevAndNext(ctx context.Context, uid string) (previous *gallery.Image, next *gallery.Image, err error)
|
||||||
}
|
}
|
||||||
type renderer interface {
|
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)
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ func (h *Handler) home(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
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) {
|
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)
|
ctx = templer.PageTitle(ctx, page.Title)
|
||||||
|
|
||||||
h.r.Render(ctx, w, r, pages.ContentPage(page))
|
h.r.RenderPage(ctx, w, r, pages.ContentPage(page))
|
||||||
}
|
}
|
||||||
@@ -33,5 +33,5 @@ type pageService interface {
|
|||||||
GetPage(ctx context.Context, uid string) (page.Page, error)
|
GetPage(ctx context.Context, uid string) (page.Page, error)
|
||||||
}
|
}
|
||||||
type renderer interface {
|
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)
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,6 @@ templ head(cfg config.Cfg, title string) {
|
|||||||
@templ.Raw(h)
|
@templ.Raw(h)
|
||||||
}
|
}
|
||||||
</head>
|
</head>
|
||||||
{ children... }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
templ Base(cfg config.Cfg, title string) {
|
templ Base(cfg config.Cfg, title string) {
|
||||||
@@ -38,13 +37,20 @@ templ Base(cfg config.Cfg, title string) {
|
|||||||
</html>
|
</html>
|
||||||
}
|
}
|
||||||
|
|
||||||
templ Content(cfg config.Cfg, title string) {
|
templ Page(cfg config.Cfg, title string) {
|
||||||
@head(cfg, title)
|
@head(cfg, title)
|
||||||
@body() {
|
@body() {
|
||||||
{ children... }
|
{ children... }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templ Component() {
|
||||||
|
for _, h := range templer.GetHeader(ctx) {
|
||||||
|
@templ.Raw(h)
|
||||||
|
}
|
||||||
|
{ children... }
|
||||||
|
}
|
||||||
|
|
||||||
templ body() {
|
templ body() {
|
||||||
<header
|
<header
|
||||||
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
|
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
|
||||||
|
|||||||
+13
-7
@@ -2,7 +2,6 @@ package layouts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -22,12 +21,9 @@ func New(cfg config.Cfg) *Layouts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render renders a page. If the query paramenter "c" is set
|
// RenderPage renders a page. If the query paramenter HX-Request is set
|
||||||
// the component gets rendered without the layout
|
// the component gets rendered without the layout
|
||||||
func (l *Layouts) Render(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) {
|
func (l *Layouts) RenderPage(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) {
|
||||||
withLayout := !r.URL.Query().Has("c")
|
|
||||||
fmt.Println("layout: ", withLayout)
|
|
||||||
|
|
||||||
title := templer.GetTitle(ctx, "Schreifuchs")
|
title := templer.GetTitle(ctx, "Schreifuchs")
|
||||||
|
|
||||||
slog.Debug("HX-Request", "value", r.Header.Get("HX-Request"))
|
slog.Debug("HX-Request", "value", r.Header.Get("HX-Request"))
|
||||||
@@ -36,10 +32,20 @@ func (l *Layouts) Render(ctx context.Context, w io.Writer, r *http.Request, comp
|
|||||||
component = Base(l.cfg, title)
|
component = Base(l.cfg, title)
|
||||||
} else {
|
} else {
|
||||||
ctx = templ.WithChildren(ctx, component)
|
ctx = templ.WithChildren(ctx, component)
|
||||||
component = Content(l.cfg, title)
|
component = Page(l.cfg, title)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := component.Render(ctx, w); err != nil {
|
if err := component.Render(ctx, w); err != nil {
|
||||||
slog.Error("error while rendering component", "err", err, "ctx", ctx)
|
slog.Error("error while rendering component", "err", err, "ctx", ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RenderComponent renders a component alone.
|
||||||
|
func (l *Layouts) RenderComponent(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) {
|
||||||
|
ctx = templ.WithChildren(ctx, component)
|
||||||
|
component = Component()
|
||||||
|
|
||||||
|
if err := component.Render(ctx, w); err != nil {
|
||||||
|
slog.Error("error while rendering component", "err", err, "ctx", ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user