mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-07-17 16:48:24 +00:00
added covers to user comment page
This commit is contained in:
parent
3faef9aeb9
commit
ab95ee5e2b
28
api/user.go
28
api/user.go
@ -111,7 +111,7 @@ func (client *Client) FetchUserComments(username string, page string) ([]Comment
|
||||
|
||||
q := req.URL.Query()
|
||||
q.Add("client_id", client.ClientID)
|
||||
q.Add("filter[account]", "eq:wouldaponybyanyothernamebeasoffencive")
|
||||
q.Add("filter[account]", "eq:"+username)
|
||||
q.Add("include", "account,post")
|
||||
q.Add("sort", "new")
|
||||
|
||||
@ -150,20 +150,30 @@ func (client *Client) FetchUserComments(username string, page string) ([]Comment
|
||||
}
|
||||
|
||||
func parseSubmission(value gjson.Result) Submission {
|
||||
coverData := value.Get("images.#(id==\"" + value.Get("cover").String() + "\")")
|
||||
cover := Media{
|
||||
Id: value.Get("id").String(),
|
||||
Description: value.Get("description").String(),
|
||||
Type: strings.Split(value.Get("type").String(), "/")[0],
|
||||
Url: strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
|
||||
}
|
||||
if coverData.Exists() {
|
||||
var cover Media
|
||||
c := value.Get("cover")
|
||||
coverData := value.Get("images.#(id==\"" + c.String() + "\")")
|
||||
switch {
|
||||
case c.Type == gjson.String && coverData.Exists():
|
||||
cover = Media{
|
||||
Id: coverData.Get("id").String(),
|
||||
Description: coverData.Get("description").String(),
|
||||
Type: strings.Split(coverData.Get("type").String(), "/")[0],
|
||||
Url: strings.ReplaceAll(coverData.Get("link").String(), "https://i.imgur.com", ""),
|
||||
}
|
||||
// This case is when fetching comments
|
||||
case c.Type != gjson.Null:
|
||||
cover = Media{
|
||||
Id: c.Get("id").String(),
|
||||
Url: c.Get("url").String(),
|
||||
}
|
||||
default:
|
||||
cover = Media{
|
||||
Id: value.Get("id").String(),
|
||||
Description: value.Get("description").String(),
|
||||
Type: strings.Split(value.Get("type").String(), "/")[0],
|
||||
Url: strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
|
||||
}
|
||||
}
|
||||
|
||||
id := value.Get("id").String()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"codeberg.org/rimgo/rimgo/utils"
|
||||
@ -96,6 +97,8 @@ func HandleUserComments(c *fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(comments[0].Post.Cover.Url) //FIXME:debug
|
||||
|
||||
return c.Render("userComments", fiber.Map{
|
||||
"user": user,
|
||||
"comments": comments,
|
||||
|
@ -1,38 +1,39 @@
|
||||
<!-- TODO: remove post titles and instead use cover images -->
|
||||
|
||||
<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">
|
||||
<p class="whitespace-nowrap text-ellipsis overflow-hidden"></p><a href="/user/{{this.User.Username}}">
|
||||
<b class="underline">{{this.User.Username}}</b></span>
|
||||
on <a class="underline" href={{Post.Link}}>post title here {{Post.Title}}</a></p>
|
||||
</a>
|
||||
{{/noteq}}
|
||||
{{#equal this.User.Username "[deleted]"}}
|
||||
<p class="whitespace-nowrap text-ellipsis overflow-hidden"><b>[deleted]</b>
|
||||
on <a class="underline" href={{Post.Link}}>post title here {{Post.Title}}</a></p>
|
||||
{{/equal}}
|
||||
<img src="{{this.Post.Cover.Url}}" alt="">
|
||||
<!-- https://codeberg.org/orangix/rimgo/src/branch/main/pages/user.go#L100
|
||||
The URL prints properly here, why doesn't it appear?
|
||||
|
||||
Also TODO, covers can be videos, ???? -->
|
||||
<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>
|
||||
<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>
|
||||
{{#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>
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>{{user.Username}} - rimgo</title>
|
||||
<title>{{user.Username}}'s comments - rimgo</title>
|
||||
|
||||
{{> partials/head }}
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user