Remove post metadata, tags, and comments
This commit is contained in:
		
							parent
							
								
									ecfd9e61d0
								
							
						
					
					
						commit
						826d4fab90
					
				| 
						 | 
				
			
			@ -1,8 +1,6 @@
 | 
			
		|||
package pages
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -58,25 +56,9 @@ func HandlePost(c *fiber.Ctx) error {
 | 
			
		|||
		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'"
 | 
			
		||||
	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)
 | 
			
		||||
 | 
			
		||||
	var next string
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +71,5 @@ func HandlePost(c *fiber.Ctx) error {
 | 
			
		|||
	return c.Render("post", fiber.Map{
 | 
			
		||||
		"post":     post,
 | 
			
		||||
		"next":     next,
 | 
			
		||||
		"comments": comments,
 | 
			
		||||
		"nonce":    nonce,
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -9,19 +9,5 @@
 | 
			
		|||
    <img src="{{Cover.Url}}" loading="lazy" width="100%" height="100%">
 | 
			
		||||
    {{/equal}}
 | 
			
		||||
    <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>
 | 
			
		||||
</a>
 | 
			
		||||
</a>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,32 +26,6 @@
 | 
			
		|||
 | 
			
		||||
  <main>
 | 
			
		||||
    <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 ""}}
 | 
			
		||||
      <a href="{{next}}" class="self-end">
 | 
			
		||||
        <button class="p-2 rounded-lg bg-slate-600">Next ></button>
 | 
			
		||||
| 
						 | 
				
			
			@ -79,50 +53,9 @@
 | 
			
		|||
      {{/if}}
 | 
			
		||||
      {{/each}}
 | 
			
		||||
    </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>
 | 
			
		||||
 | 
			
		||||
  <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 }}
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue