2022-01-18 21:45:57 +00:00
|
|
|
package pages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"codeberg.org/video-prize-ranch/rimgo/api"
|
2022-01-20 21:09:57 +00:00
|
|
|
"codeberg.org/video-prize-ranch/rimgo/types"
|
2022-01-28 01:41:10 +00:00
|
|
|
"codeberg.org/video-prize-ranch/rimgo/utils"
|
2022-01-18 21:45:57 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func HandleGallery(c *fiber.Ctx) error {
|
2022-01-28 01:41:10 +00:00
|
|
|
utils.SetHeaders(c)
|
2022-02-21 17:14:00 +00:00
|
|
|
c.Set("Content-Security-Policy", "default-src 'none'; media-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self'; font-src 'self'; block-all-mixed-content")
|
2022-01-18 21:45:57 +00:00
|
|
|
|
|
|
|
album, err := api.FetchAlbum(c.Params("galleryID"))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-01-20 21:09:57 +00:00
|
|
|
comments := []types.Comment{}
|
2022-01-24 01:59:29 +00:00
|
|
|
if album.SharedWithCommunity {
|
2022-01-28 01:41:10 +00:00
|
|
|
c.Set("Cache-Control", "public,max-age=604800")
|
2022-01-20 21:09:57 +00:00
|
|
|
comments, err = api.FetchComments(c.Params("galleryID"))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-01-28 01:41:10 +00:00
|
|
|
} else {
|
|
|
|
c.Set("Cache-Control", "public,max-age=31557600")
|
2022-01-18 23:05:06 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 21:07:15 +00:00
|
|
|
return c.Render("post", fiber.Map{
|
|
|
|
"post": album,
|
2022-01-18 23:05:06 +00:00
|
|
|
"comments": comments,
|
2022-01-18 21:45:57 +00:00
|
|
|
})
|
|
|
|
}
|