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 NextLink string
} }
//For Pleroma reactions
type ReactedByData struct {
*CommonData
Reactions []*mastodon.ReactionsPleroma
}
type RetweetedByData struct { type RetweetedByData struct {
*CommonData *CommonData
Users []*mastodon.Account Users []*mastodon.Account

View file

@ -30,6 +30,7 @@ const (
AboutInstance = "aboutinstance.tmpl" AboutInstance = "aboutinstance.tmpl"
EmojiPage = "emoji.tmpl" EmojiPage = "emoji.tmpl"
LikedByPage = "likedby.tmpl" LikedByPage = "likedby.tmpl"
ReactedByPage = "reactionspage.tmpl"
RetweetedByPage = "retweetedby.tmpl" RetweetedByPage = "retweetedby.tmpl"
SearchPage = "search.tmpl" SearchPage = "search.tmpl"
SettingsPage = "settings.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) 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) { func (s *service) RetweetedByPage(c *client, id string) (err error) {
retweeters, err := c.GetRebloggedBy(c.ctx, id, nil) retweeters, err := c.GetRebloggedBy(c.ctx, id, nil)
if err != 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"] id, _ := mux.Vars(c.r)["id"]
return s.LikedByPage(c, id) return s.LikedByPage(c, id)
}, SESSION, HTML) }, 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 { retweetedByPage := handle(func(c *client) error {
id, _ := mux.Vars(c.r)["id"] 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("/thread/{id}", threadPage).Methods(http.MethodGet)
r.HandleFunc("/quickreply/{id}", quickReplyPage).Methods(http.MethodGet) r.HandleFunc("/quickreply/{id}", quickReplyPage).Methods(http.MethodGet)
r.HandleFunc("/likedby/{id}", likedByPage).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("/retweetedby/{id}", retweetedByPage).Methods(http.MethodGet)
r.HandleFunc("/notifications", notificationsPage).Methods(http.MethodGet) r.HandleFunc("/notifications", notificationsPage).Methods(http.MethodGet)
r.HandleFunc("/user/{id}", userPage).Methods(http.MethodGet) r.HandleFunc("/user/{id}", userPage).Methods(http.MethodGet)

View file

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