feat(gallery): image detail view
release.yaml / publish (push) Successful in 4m0s

This commit is contained in:
schreifuchs committed 2026-09-26 19:28:00 +02:00
1 parent 72bc974aa6
commit 9ec2585030
12 files changed
+299 -54

No files matched your search

+4 -4
View File
@@ -20,16 +20,16 @@ type Set struct {
}
func (s *Service) GetGallerySet(ctx context.Context) (gallerySet Set, err error) {
gallerySet.SM, err = s.GetGallery(ctx, 50)
gallerySet.SM, err = s.getGallery(ctx, 50)
if err != nil {
return
}
gallerySet.LG, err = s.GetGallery(ctx, 80)
gallerySet.LG, err = s.getGallery(ctx, 80)
if err != nil {
return
}
gallerySet.XLG, err = s.GetGallery(ctx, 120)
gallerySet.XLG, err = s.getGallery(ctx, 120)
if err != nil {
return
}
@@ -37,7 +37,7 @@ func (s *Service) GetGallerySet(ctx context.Context) (gallerySet Set, err error)
return
}
func (s *Service) GetGallery(ctx context.Context, width int) (gallery Gallery, err error) {
func (s *Service) getGallery(ctx context.Context, width int) (gallery Gallery, err error) {
imgs, err := s.GetImages(ctx)
if err != nil {
return
+30
View File
@@ -12,6 +12,7 @@ import (
"time"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/handlers/rest"
"github.com/valkey-io/valkey-go"
)
@@ -124,3 +125,32 @@ func (s *Service) GetImages(ctx context.Context) (images []Image, err error) {
err = s.cache.Do(ctx, s.cache.B().Get().Key(imagesKey).Build()).DecodeJSON(&images)
return
}
func (s *Service) GetPrevAndNext(ctx context.Context, uid string) (previous *Image, next *Image, err error) {
imgs, err := s.GetImages(ctx)
if err != nil {
return nil, nil, err
}
for i := range imgs {
if imgs[i].UID != uid {
continue
}
if i > 0 {
prevImg := imgs[i-1]
previous = &prevImg
}
if i+1 < len(imgs) {
nextImg := imgs[i+1]
next = &nextImg
}
return previous, next, nil
}
return nil, nil, &rest.Error{
Type: rest.ErrorTypeNotFound,
Message: "could not find image with uid",
}
}