Add reactions page

This commit is contained in:
localhost_frssoft 2022-10-19 17:33:43 +03:00
parent 927bd6127c
commit 81a52fe7c6
5 changed files with 31 additions and 0 deletions

View File

@ -136,6 +136,12 @@ type LikedByData struct {
NextLink string
}
//For Pleroma reactions
type ReactedByData struct {
*CommonData
Reactions []*mastodon.ReactionsPleroma
}
type RetweetedByData struct {
*CommonData
Users []*mastodon.Account

View File

@ -30,6 +30,7 @@ const (
AboutInstance = "aboutinstance.tmpl"
EmojiPage = "emoji.tmpl"
LikedByPage = "likedby.tmpl"
ReactedByPage = "reactionspage.tmpl"
RetweetedByPage = "retweetedby.tmpl"
SearchPage = "search.tmpl"
SettingsPage = "settings.tmpl"

View File

@ -505,6 +505,19 @@ func (s *service) LikedByPage(c *client, id string) (err error) {
return s.renderer.Render(c.rctx, c.w, renderer.LikedByPage, data)
}
func (s *service) ReactedByPage(c *client, id string) (err error) {
reactions, err := c.GetReactedBy(c.ctx, id)
if err != nil {
return
}
cdata := s.cdata(c, "reactions", 0, 0, "")
data := &renderer.ReactedByData{
CommonData: cdata,
Reactions: reactions,
}
return s.renderer.Render(c.rctx, c.w, renderer.ReactedByPage, data)
}
func (s *service) RetweetedByPage(c *client, id string) (err error) {
retweeters, err := c.GetRebloggedBy(c.ctx, id, nil)
if err != nil {

View File

@ -188,6 +188,11 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
id, _ := mux.Vars(c.r)["id"]
return s.LikedByPage(c, id)
}, SESSION, HTML)
reactedByPage := handle(func(c *client) error {
id, _ := mux.Vars(c.r)["id"]
return s.ReactedByPage(c, id)
}, SESSION, HTML)
retweetedByPage := handle(func(c *client) error {
id, _ := mux.Vars(c.r)["id"]
@ -746,6 +751,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
r.HandleFunc("/thread/{id}", threadPage).Methods(http.MethodGet)
r.HandleFunc("/quickreply/{id}", quickReplyPage).Methods(http.MethodGet)
r.HandleFunc("/likedby/{id}", likedByPage).Methods(http.MethodGet)
r.HandleFunc("/reactionspage/{id}", reactedByPage).Methods(http.MethodGet)
r.HandleFunc("/retweetedby/{id}", retweetedByPage).Methods(http.MethodGet)
r.HandleFunc("/notifications", notificationsPage).Methods(http.MethodGet)
r.HandleFunc("/user/{id}", userPage).Methods(http.MethodGet)

View File

@ -248,6 +248,11 @@
</a>
</form>
</div>
<div class="status-action">
<a href="/reactionspage/{{.ID}}">
reactions
</a>
</div>
<div class="status-action status-action-last">
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}"
{{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>