mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-12-13 19:55:21 +00:00
Single-media posts that are neither albums nor galleries (closes #15)
This commit is contained in:
@@ -27,8 +27,8 @@ func HandleGallery(c *fiber.Ctx) error {
|
||||
c.Set("Cache-Control", "public,max-age=31557600")
|
||||
}
|
||||
|
||||
return c.Render("gallery", fiber.Map{
|
||||
"album": album,
|
||||
return c.Render("post", fiber.Map{
|
||||
"post": album,
|
||||
"comments": comments,
|
||||
})
|
||||
}
|
||||
|
||||
34
pages/post.go
Normal file
34
pages/post.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"codeberg.org/video-prize-ranch/rimgo/api"
|
||||
"codeberg.org/video-prize-ranch/rimgo/types"
|
||||
"codeberg.org/video-prize-ranch/rimgo/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func HandlePost(c *fiber.Ctx) error {
|
||||
utils.SetHeaders(c)
|
||||
c.Set("Content-Security-Policy", "default-src 'none'; media-src 'self'; style-src 'self'; img-src 'self'; font-src 'self'; block-all-mixed-content")
|
||||
|
||||
post, err := api.FetchPosts(c.Params("postID"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
comments := []types.Comment{}
|
||||
if post.SharedWithCommunity {
|
||||
c.Set("Cache-Control", "public,max-age=604800")
|
||||
comments, err = api.FetchComments(c.Params("postID"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
c.Set("Cache-Control", "public,max-age=31557600")
|
||||
}
|
||||
|
||||
return c.Render("post", fiber.Map{
|
||||
"post": post,
|
||||
"comments": comments,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user