mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 04:39:21 +02:00
Add remote timeline
This commit is contained in:
parent
eca0366c21
commit
ac342dde07
|
@ -191,9 +191,11 @@ func (c *Client) GetTimelineHome(ctx context.Context, pg *Pagination) ([]*Status
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTimelinePublic return statuses from public timeline.
|
// GetTimelinePublic return statuses from public timeline.
|
||||||
func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool, pg *Pagination) ([]*Status, error) {
|
func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool, instance string, pg *Pagination) ([]*Status, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
if isLocal {
|
if len(instance) > 0 {
|
||||||
|
params.Set("instance", instance)
|
||||||
|
} else if isLocal {
|
||||||
params.Set("local", "true")
|
params.Set("local", "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ type RootData struct {
|
||||||
type TimelineData struct {
|
type TimelineData struct {
|
||||||
*CommonData
|
*CommonData
|
||||||
Title string
|
Title string
|
||||||
|
Type string
|
||||||
|
Instance string
|
||||||
Statuses []*mastodon.Status
|
Statuses []*mastodon.Status
|
||||||
NextLink string
|
NextLink string
|
||||||
PrevLink string
|
PrevLink string
|
||||||
|
|
|
@ -158,7 +158,7 @@ func (s *service) NavPage(c *client) (err error) {
|
||||||
return s.renderer.Render(rCtx, c, renderer.NavPage, data)
|
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) {
|
maxID string, minID string) (err error) {
|
||||||
|
|
||||||
var nextLink, prevLink, title string
|
var nextLink, prevLink, title string
|
||||||
|
@ -179,10 +179,15 @@ func (s *service) TimelinePage(c *client, tType string,
|
||||||
statuses, err = c.GetTimelineDirect(ctx, &pg)
|
statuses, err = c.GetTimelineDirect(ctx, &pg)
|
||||||
title = "Direct Timeline"
|
title = "Direct Timeline"
|
||||||
case "local":
|
case "local":
|
||||||
statuses, err = c.GetTimelinePublic(ctx, true, &pg)
|
statuses, err = c.GetTimelinePublic(ctx, true, "", &pg)
|
||||||
title = "Local Timeline"
|
title = "Local Timeline"
|
||||||
|
case "remote":
|
||||||
|
if len(instance) > 0 {
|
||||||
|
statuses, err = c.GetTimelinePublic(ctx, false, instance, &pg)
|
||||||
|
}
|
||||||
|
title = "Remote Timeline"
|
||||||
case "twkn":
|
case "twkn":
|
||||||
statuses, err = c.GetTimelinePublic(ctx, false, &pg)
|
statuses, err = c.GetTimelinePublic(ctx, false, "", &pg)
|
||||||
title = "The Whole Known Network"
|
title = "The Whole Known Network"
|
||||||
}
|
}
|
||||||
if err != nil {
|
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 {
|
if (len(maxID) > 0 || len(minID) > 0) && len(statuses) > 0 {
|
||||||
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s", tType,
|
v := make(url.Values)
|
||||||
statuses[0].ID)
|
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) {
|
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 ")
|
commonData := s.getCommonData(c, tType+" timeline ")
|
||||||
data := &renderer.TimelineData{
|
data := &renderer.TimelineData{
|
||||||
Title: title,
|
Title: title,
|
||||||
|
Type: tType,
|
||||||
|
Instance: instance,
|
||||||
Statuses: statuses,
|
Statuses: statuses,
|
||||||
NextLink: nextLink,
|
NextLink: nextLink,
|
||||||
PrevLink: prevLink,
|
PrevLink: prevLink,
|
||||||
|
|
|
@ -190,10 +190,10 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||||
timelinePage := handle(func(c *client) error {
|
timelinePage := handle(func(c *client) error {
|
||||||
tType, _ := mux.Vars(c.Req)["type"]
|
tType, _ := mux.Vars(c.Req)["type"]
|
||||||
q := c.Req.URL.Query()
|
q := c.Req.URL.Query()
|
||||||
|
instance := q.Get("instance")
|
||||||
maxID := q.Get("max_id")
|
maxID := q.Get("max_id")
|
||||||
minID := q.Get("min_id")
|
minID := q.Get("min_id")
|
||||||
return s.TimelinePage(c, tType, maxID, minID)
|
return s.TimelinePage(c, tType, instance, maxID, minID)
|
||||||
return nil
|
|
||||||
}, SESSION, HTML)
|
}, SESSION, HTML)
|
||||||
|
|
||||||
defaultTimelinePage := handle(func(c *client) error {
|
defaultTimelinePage := handle(func(c *client) error {
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
<a class="nav-link" href="/timeline/home" accesskey="1" title="Home timeline (1)">home</a>
|
<a class="nav-link" href="/timeline/home" accesskey="1" title="Home timeline (1)">home</a>
|
||||||
<a class="nav-link" href="/timeline/direct" accesskey="2" title="Direct timeline (2)">direct</a>
|
<a class="nav-link" href="/timeline/direct" accesskey="2" title="Direct timeline (2)">direct</a>
|
||||||
<a class="nav-link" href="/timeline/local" accesskey="3" title="Local timeline (3)">local</a>
|
<a class="nav-link" href="/timeline/local" accesskey="3" title="Local timeline (3)">local</a>
|
||||||
<a class="nav-link" href="/timeline/twkn" accesskey="4" title="The Whole Known Netwwork (4)">twkn</a>
|
<a class="nav-link" href="/timeline/remote" accesskey="4" title="Remote timeline (4)">remote</a>
|
||||||
<a class="nav-link" href="/search" accesskey="5" title="Search (5)">search</a>
|
<a class="nav-link" href="/timeline/twkn" accesskey="5" title="The Whole Known Netwwork (5)">twkn</a>
|
||||||
<a class="nav-link" href="/about" accesskey="6" title="About (6)">about</a>
|
<a class="nav-link" href="/search" accesskey="6" title="Search (6)">search</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a class="nav-link" href="/settings" target="_top" accesskey="7" title="Settings (7)">settings</a>
|
<a class="nav-link" href="/settings" target="_top" accesskey="7" title="Settings (7)">settings</a>
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="signout" class="btn-link nav-link" accesskey="8" title="Signout (8)">
|
<input type="submit" value="signout" class="btn-link nav-link" accesskey="8" title="Signout (8)">
|
||||||
</form>
|
</form>
|
||||||
|
<a class="nav-link" href="/about" accesskey="9" title="About (9)">about</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<link rel="icon" type="image/png" href="/static/favicon.png">
|
<link rel="icon" type="image/png" href="/static/favicon.png">
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<frameset cols="420px,*">
|
<frameset cols="424px,*">
|
||||||
<frameset rows="316px,*">
|
<frameset rows="316px,*">
|
||||||
<frame name="nav" src="/nav">
|
<frame name="nav" src="/nav">
|
||||||
<frame name="notification" src="/notifications">
|
<frame name="notification" src="/notifications">
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
{{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
|
{{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
|
||||||
<div class="page-title"> {{.Title}} </div>
|
<div class="page-title"> {{.Title}} </div>
|
||||||
|
|
||||||
|
{{if eq .Type "remote"}}
|
||||||
|
<form class="search-form" action="/timeline/remote" method="GET">
|
||||||
|
<span class="post-form-field">
|
||||||
|
<label for="instance"> Instance </label>
|
||||||
|
<input id="instance" name="instance" value="{{.Instance}}">
|
||||||
|
</span>
|
||||||
|
<button type="submit"> Submit </button>
|
||||||
|
</form>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{range .Statuses}}
|
{{range .Statuses}}
|
||||||
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue