Remove post metadata, tags, and comments

This commit is contained in:
blankie 2023-05-27 21:42:14 +07:00
parent ecfd9e61d0
commit 826d4fab90
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
4 changed files with 3 additions and 136 deletions

View File

@ -1,8 +1,6 @@
package pages package pages
import ( import (
"crypto/rand"
"fmt"
"strconv" "strconv"
"strings" "strings"
@ -58,25 +56,9 @@ func HandlePost(c *fiber.Ctx) error {
return err return err
} }
comments := []api.Comment{}
if post.SharedWithCommunity {
c.Set("Cache-Control", "public,max-age=604800")
comments, err = ApiClient.FetchComments(c.Params("postID"))
if err != nil {
return err
}
} else {
c.Set("Cache-Control", "public,max-age=31557600") c.Set("Cache-Control", "public,max-age=31557600")
}
nonce := ""
csp := "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content; style-src 'self'" csp := "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content; style-src 'self'"
if len(post.Tags) != 0 {
b := make([]byte, 8)
rand.Read(b)
nonce = fmt.Sprintf("%x", b)
csp = csp + " 'nonce-" + nonce + "'"
}
c.Set("Content-Security-Policy", csp) c.Set("Content-Security-Policy", csp)
var next string var next string
@ -89,7 +71,5 @@ func HandlePost(c *fiber.Ctx) error {
return c.Render("post", fiber.Map{ return c.Render("post", fiber.Map{
"post": post, "post": post,
"next": next, "next": next,
"comments": comments,
"nonce": nonce,
}) })
} }

View File

@ -1,32 +0,0 @@
<div class="flex flex-col gap-2">
<div class="flex gap-2 items-center">
{{#noteq this.User.Username "[deleted]"}}
<img src="{{this.User.Avatar}}" class="rounded-full" width="24" height="24" loading="lazy">
<a href="/user/{{this.User.Username}}">
<p class="whitespace-nowrap text-ellipsis overflow-hidden"><b>{{this.User.Username}}</b></p>
</a>
{{/noteq}}
{{#equal this.User.Username "[deleted]"}}
<p class="whitespace-nowrap text-ellipsis overflow-hidden"><b>[deleted]</b></p>
{{/equal}}
</div>
<div>
<p>{{{this.Comment}}}</p>
<div class="flex gap-2">
<span title="{{this.CreatedAt}}">{{this.RelTime}}</span>
{{#if this.DeletedAt}}
<span class="text-md">(deleted {{this.DeletedAt}})</span>
{{/if}}
|
<img class="invert icon" src="/static/icons/PhArrowFatUp.svg" alt="Likes" width="24px" height="24px"> {{this.Upvotes}}
<img class="invert icon" src="/static/icons/PhArrowFatDown.svg" alt="Dislikes" width="24px" height="24px"> {{this.Downvotes}}
</div>
</div>
{{#if this.Comments}}
<div class="ml-4 p-2 border-solid border-l-2 border-slate-400">
{{#each this.Comments}}
{{> partials/comment }}
{{/each}}
</div>
{{/if}}
</div>

View File

@ -9,19 +9,5 @@
<img src="{{Cover.Url}}" loading="lazy" width="100%" height="100%"> <img src="{{Cover.Url}}" loading="lazy" width="100%" height="100%">
{{/equal}} {{/equal}}
<p class="m-2 text-ellipsis whitespace-nowrap overflow-hidden">{{Title}}</p> <p class="m-2 text-ellipsis whitespace-nowrap overflow-hidden">{{Title}}</p>
<div class="flex gap-2 p-2">
<div class="flex gap-1">
<img class="invert icon" src="/static/icons/PhArrowFatUp.svg" alt="Points" width="18px" height="18px">
{{Points}}
</div>
<div class="flex gap-1">
<img class="invert icon" src="/static/icons/PhChat.svg" alt="Comments" width="18px" height="18px">
{{Comments}}
</div>
<div class="flex gap-1">
<img class="invert icon" src="/static/icons/PhEye.svg" alt="Views" width="18px" height="18px">
{{Views}}
</div>
</div>
</div> </div>
</a> </a>

View File

@ -26,32 +26,6 @@
<main> <main>
<div class="flex flex-col sm:flex-row my-4 w-full justify-between"> <div class="flex flex-col sm:flex-row my-4 w-full justify-between">
<div class="flex flex-col gap-2 md:flex-row md:gap-4 md:items-center">
{{#if post.User.Username}}
<a href="/user/{{post.User.Username}}" class="flex gap-2 items-center">
<img src="{{post.User.Avatar}}" class="rounded-full" width="36" height="36" />
<p>
<b>{{post.User.Username}}</b>
</p>
</a>
{{/if}}
<div class="flex gap-2 items-center">
<div class="flex flex-center gap-2">
<img class="icon invert" src="/static/icons/PhEye.svg" alt="Views" width="24px" height="24px">
<p>{{post.Views}}</p>
</div>
{{#if post.SharedWithCommunity}}
<div class="flex flex-center gap-2">
<img class="icon invert" src="/static/icons/PhArrowFatUp.svg" alt="Likes" width="24px" height="24px">
<p>{{post.Upvotes}}</p>
</div>
<div class="flex flex-center gap-2">
<img class="icon invert" src="/static/icons/PhArrowFatDown.svg" alt="Dislikes" width="24px" height="24px">
<p>{{post.Downvotes}}</p>
</div>
{{/if}}
</div>
</div>
{{#noteq next ""}} {{#noteq next ""}}
<a href="{{next}}" class="self-end"> <a href="{{next}}" class="self-end">
<button class="p-2 rounded-lg bg-slate-600">Next &gt;</button> <button class="p-2 rounded-lg bg-slate-600">Next &gt;</button>
@ -79,49 +53,8 @@
{{/if}} {{/if}}
{{/each}} {{/each}}
</div> </div>
{{#if post.tags}}
<div class="flex gap-2 my-2 flex-wrap">
<style nonce="{{nonce}}">
{{#each post.tags}}
.{{this.BackgroundId}} { background-image: url('{{this.Background}}') }
{{/each}}
</style>
{{#each post.tags}}
<a href="/t/{{this.Tag}}">
<div class="rounded-md p-4 min-w-[110px] bg-slate-500 {{this.BackgroundId}}">
<p class="font-bold text-white text-center">
{{#if tag.Display}}
{{this.Display}}
{{else}}
{{this.Tag}}
{{/if}}
</p>
</div>
</a>
{{/each}}
</div>
{{/if}}
</main> </main>
<section>
{{#if comments}}
<div>
<input id="comments__expandBtn" type="checkbox" checked>
<label class="comments__expandBtn__label my-2 py-4 border-solid border-t-2 border-slate-400"
for="comments__expandBtn">
<h3 class="text-xl font-bold">Comments ({{post.Comments}})</h3>
<span class="text-xl font-bold"></span>
</label>
<div class="comments flex flex-col gap-2">
{{#each comments}}
{{> partials/comment }}
{{/each}}
</div>
</div>
{{/if}}
</section>
{{> partials/footer }} {{> partials/footer }}
</body> </body>