mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-05 03:18:44 +00:00
Add remote timeline
This commit is contained in:
parent
eca0366c21
commit
ac342dde07
7 changed files with 45 additions and 14 deletions
|
@ -158,7 +158,7 @@ func (s *service) NavPage(c *client) (err error) {
|
|||
return s.renderer.Render(rCtx, c, renderer.NavPage, data)
|
||||
}
|
||||
|
||||
func (s *service) TimelinePage(c *client, tType string,
|
||||
func (s *service) TimelinePage(c *client, tType string, instance string,
|
||||
maxID string, minID string) (err error) {
|
||||
|
||||
var nextLink, prevLink, title string
|
||||
|
@ -179,10 +179,15 @@ func (s *service) TimelinePage(c *client, tType string,
|
|||
statuses, err = c.GetTimelineDirect(ctx, &pg)
|
||||
title = "Direct Timeline"
|
||||
case "local":
|
||||
statuses, err = c.GetTimelinePublic(ctx, true, &pg)
|
||||
statuses, err = c.GetTimelinePublic(ctx, true, "", &pg)
|
||||
title = "Local Timeline"
|
||||
case "remote":
|
||||
if len(instance) > 0 {
|
||||
statuses, err = c.GetTimelinePublic(ctx, false, instance, &pg)
|
||||
}
|
||||
title = "Remote Timeline"
|
||||
case "twkn":
|
||||
statuses, err = c.GetTimelinePublic(ctx, false, &pg)
|
||||
statuses, err = c.GetTimelinePublic(ctx, false, "", &pg)
|
||||
title = "The Whole Known Network"
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -196,17 +201,28 @@ func (s *service) TimelinePage(c *client, tType string,
|
|||
}
|
||||
|
||||
if (len(maxID) > 0 || len(minID) > 0) && len(statuses) > 0 {
|
||||
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s", tType,
|
||||
statuses[0].ID)
|
||||
v := make(url.Values)
|
||||
v.Set("min_id", statuses[0].ID)
|
||||
if len(instance) > 0 {
|
||||
v.Set("instance", instance)
|
||||
}
|
||||
prevLink = "/timeline/" + tType + "?" + v.Encode()
|
||||
}
|
||||
|
||||
if len(minID) > 0 || (len(pg.MaxID) > 0 && len(statuses) == 20) {
|
||||
nextLink = fmt.Sprintf("/timeline/%s?max_id=%s", tType, pg.MaxID)
|
||||
v := make(url.Values)
|
||||
v.Set("max_id", pg.MaxID)
|
||||
if len(instance) > 0 {
|
||||
v.Set("instance", instance)
|
||||
}
|
||||
nextLink = "/timeline/" + tType + "?" + v.Encode()
|
||||
}
|
||||
|
||||
commonData := s.getCommonData(c, tType+" timeline ")
|
||||
data := &renderer.TimelineData{
|
||||
Title: title,
|
||||
Type: tType,
|
||||
Instance: instance,
|
||||
Statuses: statuses,
|
||||
NextLink: nextLink,
|
||||
PrevLink: prevLink,
|
||||
|
|
|
@ -190,10 +190,10 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||
timelinePage := handle(func(c *client) error {
|
||||
tType, _ := mux.Vars(c.Req)["type"]
|
||||
q := c.Req.URL.Query()
|
||||
instance := q.Get("instance")
|
||||
maxID := q.Get("max_id")
|
||||
minID := q.Get("min_id")
|
||||
return s.TimelinePage(c, tType, maxID, minID)
|
||||
return nil
|
||||
return s.TimelinePage(c, tType, instance, maxID, minID)
|
||||
}, SESSION, HTML)
|
||||
|
||||
defaultTimelinePage := handle(func(c *client) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue