mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-07-20 09:58:23 +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 := req.URL.Query()
|
||||||
q.Add("client_id", client.ClientID)
|
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("include", "account,post")
|
||||||
q.Add("sort", "new")
|
q.Add("sort", "new")
|
||||||
|
|
||||||
@ -150,20 +150,30 @@ func (client *Client) FetchUserComments(username string, page string) ([]Comment
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseSubmission(value gjson.Result) Submission {
|
func parseSubmission(value gjson.Result) Submission {
|
||||||
coverData := value.Get("images.#(id==\"" + value.Get("cover").String() + "\")")
|
var cover Media
|
||||||
cover := Media{
|
c := value.Get("cover")
|
||||||
Id: value.Get("id").String(),
|
coverData := value.Get("images.#(id==\"" + c.String() + "\")")
|
||||||
Description: value.Get("description").String(),
|
switch {
|
||||||
Type: strings.Split(value.Get("type").String(), "/")[0],
|
case c.Type == gjson.String && coverData.Exists():
|
||||||
Url: strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
|
|
||||||
}
|
|
||||||
if coverData.Exists() {
|
|
||||||
cover = Media{
|
cover = Media{
|
||||||
Id: coverData.Get("id").String(),
|
Id: coverData.Get("id").String(),
|
||||||
Description: coverData.Get("description").String(),
|
Description: coverData.Get("description").String(),
|
||||||
Type: strings.Split(coverData.Get("type").String(), "/")[0],
|
Type: strings.Split(coverData.Get("type").String(), "/")[0],
|
||||||
Url: strings.ReplaceAll(coverData.Get("link").String(), "https://i.imgur.com", ""),
|
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()
|
id := value.Get("id").String()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package pages
|
package pages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"codeberg.org/rimgo/rimgo/utils"
|
"codeberg.org/rimgo/rimgo/utils"
|
||||||
@ -96,6 +97,8 @@ func HandleUserComments(c *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(comments[0].Post.Cover.Url) //FIXME:debug
|
||||||
|
|
||||||
return c.Render("userComments", fiber.Map{
|
return c.Render("userComments", fiber.Map{
|
||||||
"user": user,
|
"user": user,
|
||||||
"comments": comments,
|
"comments": comments,
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
<!-- TODO: remove post titles and instead use cover images -->
|
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
<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">
|
<div class="flex gap-2 items-center">
|
||||||
{{#noteq this.User.Username "[deleted]"}}
|
{{#noteq this.User.Username "[deleted]"}}
|
||||||
<img src="{{this.User.Avatar}}" class="rounded-full" width="24" height="24" loading="lazy">
|
<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}}">
|
<a href="/user/{{this.User.Username}}">
|
||||||
<b class="underline">{{this.User.Username}}</b></span>
|
<p class="whitespace-nowrap text-ellipsis overflow-hidden"><b>{{this.User.Username}}</b></p>
|
||||||
on <a class="underline" href={{Post.Link}}>post title here {{Post.Title}}</a></p>
|
|
||||||
</a>
|
</a>
|
||||||
{{/noteq}}
|
{{/noteq}}
|
||||||
{{#equal this.User.Username "[deleted]"}}
|
{{#equal this.User.Username "[deleted]"}}
|
||||||
<p class="whitespace-nowrap text-ellipsis overflow-hidden"><b>[deleted]</b>
|
<p class="whitespace-nowrap text-ellipsis overflow-hidden"><b>[deleted]</b></p>
|
||||||
on <a class="underline" href={{Post.Link}}>post title here {{Post.Title}}</a></p>
|
|
||||||
{{/equal}}
|
{{/equal}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>{{user.Username}} - rimgo</title>
|
<title>{{user.Username}}'s comments - rimgo</title>
|
||||||
|
|
||||||
{{> partials/head }}
|
{{> partials/head }}
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user