diff --git a/main.go b/main.go
index 8c5ac66..8a23cdc 100644
--- a/main.go
+++ b/main.go
@@ -51,9 +51,11 @@ func main() {
app.Get("/", pages.FrontpageHandler)
app.Get("/:baseName.:extension", pages.HandleMedia)
+ app.Get("/:postID", pages.HandlePost)
app.Get("/a/:galleryID", pages.HandleGallery)
//app.Get("/t/:tagID", pages.HandleAlbum)
app.Get("/user/:userID", pages.HandleUser)
+ app.Get("/r/:sub/:postID", pages.HandlePost)
app.Get("/user/:userID/cover", pages.HandleUserCover)
app.Get("/user/:userID/avatar", pages.HandleUserAvatar)
app.Get("/gallery/:galleryID", pages.HandleGallery)
diff --git a/pages/gallery.go b/pages/gallery.go
index cb0fb98..eb1b8bd 100644
--- a/pages/gallery.go
+++ b/pages/gallery.go
@@ -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,
})
}
diff --git a/pages/post.go b/pages/post.go
new file mode 100644
index 0000000..088fd03
--- /dev/null
+++ b/pages/post.go
@@ -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,
+ })
+}
\ No newline at end of file
diff --git a/views/gallery.hbs b/views/post.hbs
similarity index 74%
rename from views/gallery.hbs
rename to views/post.hbs
index d70e50c..be795bd 100644
--- a/views/gallery.hbs
+++ b/views/post.hbs
@@ -3,8 +3,8 @@
- {{#if album.Title}}
- {{album.Title}} -
+ {{#if post.Title}}
+ {{post.Title}} -
{{/if}}
rimgo
@@ -21,19 +21,19 @@
{{> partials/header }}
- {{album.Title}}
+ {{post.Title}}
- {{album.CreatedAt}}
+ {{post.CreatedAt}}
- {{#each album.Media}}
+ {{#each post.Media}}
{{#if this.Title}}
{{this.Title}}
{{/if}}
@@ -79,7 +79,7 @@