diff --git a/api/album.go b/api/album.go index fbf4124..9beb3b4 100644 --- a/api/album.go +++ b/api/album.go @@ -35,6 +35,8 @@ func FetchAlbum(albumID string) (types.Album, error) { media = append(media, types.Media{ Id: value.Get("id").String(), Name: value.Get("name").String(), + MimeType: value.Get("mime_type").String(), + Type: value.Get("type").String(), Title: value.Get("metadata.title").String(), Description: value.Get("metadata.description").String(), Url: url, diff --git a/pages/f.ts b/api/f.ts similarity index 100% rename from pages/f.ts rename to api/f.ts diff --git a/main.go b/main.go index b1d7198..7bbcbc9 100644 --- a/main.go +++ b/main.go @@ -48,8 +48,8 @@ func main() { app.Get("/a/:albumID", pages.HandleAlbum) app.Get("/t/:tagID", pages.HandleAlbum) /*app.Get("/user/:userID", pages.HandleUser) - app.Get("/user/:userID/cover", pages.HandleUserCover) - app.Get("/gallery/:galleryID", pages.HandleGallery)*/ + app.Get("/user/:userID/cover", pages.HandleUserCover)*/ + app.Get("/gallery/:galleryID", pages.HandleGallery) app.Listen(":" + viper.GetString("RIMGU_PORT")) } diff --git a/pages/gallery.go b/pages/gallery.go new file mode 100644 index 0000000..99fffbe --- /dev/null +++ b/pages/gallery.go @@ -0,0 +1,27 @@ +package pages + +import ( + "codeberg.org/video-prize-ranch/rimgo/api" + "github.com/gofiber/fiber/v2" +) + +func HandleGallery(c *fiber.Ctx) error { + c.Set("Cache-Control", "public,max-age=604800") + c.Set("X-Frame-Options", "DENY") + c.Set("Referrer-Policy", "no-referrer") + c.Set("X-Content-Type-Options", "nosniff") + c.Set("X-Robots-Tag", "noindex, noimageindex, nofollow") + c.Set("Strict-Transport-Security", "max-age=31557600") + c.Set("Permissions-Policy", "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), interest-cohort=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()") + c.Set("Content-Security-Policy", "default-src 'none'; media-src 'self'; style-src 'self'; script-src 'none'; img-src 'self'; font-src 'self'; block-all-mixed-content; manifest-src 'self'") + + album, err := api.FetchAlbum(c.Params("galleryID")) + if err != nil { + return err + } + + return c.Render("gallery", fiber.Map{ + "album": album, + "isAlbum": false, + }) +} diff --git a/static/css/album.css b/static/css/album.css index f334694..95e378c 100644 --- a/static/css/album.css +++ b/static/css/album.css @@ -6,6 +6,7 @@ p { margin: 0.5em 0; } +video, img { max-width: 100%; } diff --git a/types/Media.go b/types/Media.go index dc7cef8..6dfe614 100644 --- a/types/Media.go +++ b/types/Media.go @@ -6,4 +6,6 @@ type Media struct { Title string Description string Url string + Type string + MimeType string } diff --git a/views/frontpage.hbs b/views/frontpage.hbs index 1723845..5782035 100644 --- a/views/frontpage.hbs +++ b/views/frontpage.hbs @@ -18,7 +18,11 @@

Try it!

- Album +

Features

diff --git a/views/gallery.hbs b/views/gallery.hbs index 1f91c5e..c5bbc13 100644 --- a/views/gallery.hbs +++ b/views/gallery.hbs @@ -42,6 +42,8 @@ --> +
+ {{#each album.Media}} {{#if this.Title}}

{{this.Title}}

@@ -51,7 +53,14 @@ {{/if}}
+ {{#equal this.Type "image"}} + {{/equal}} + {{#equal this.Type "video"}} + + {{/equal}}