aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/service.go28
-rw-r--r--service/transport.go4
2 files changed, 24 insertions, 8 deletions
diff --git a/service/service.go b/service/service.go
index f376fde..ce689fd 100644
--- a/service/service.go
+++ b/service/service.go
@@ -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,
diff --git a/service/transport.go b/service/transport.go
index 882a351..096b44e 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -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 {