true remote timeline fixed

This commit is contained in:
localhost_frssoft 2023-11-11 21:39:00 +03:00
parent 34940a65df
commit eedd9d2c5c
5 changed files with 29 additions and 11 deletions

1
README
View file

@ -9,6 +9,7 @@ Changes (localhost_custom fork):
- Is personal fork, no recommended for public use (use as local frontend)
- Add reactions for pleroma (includes custom emojis input)
- tag timeline
- true remote timeline
- visible edited post time
- visible quoted post (status in status)
- visible profile banner in spoiler

View file

@ -11,8 +11,6 @@ import (
"path/filepath"
"time"
"encoding/json"
"path"
"strings"
"strconv"
)
@ -244,21 +242,22 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, pg *Pa
if pg != nil {
params = pg.setValues(params)
}
u, err := url.Parse("https://" + instance)
if err != nil {
return nil, err
}
u.Path = path.Join(u.Path, "/api/v1/timelines/public")
req, err := http.NewRequest(http.MethodGet, u.String(), strings.NewReader(params.Encode()))
perform := url.URL{
Scheme: "https",
Host: instance,
Path: "api/v1/timelines/public",
RawQuery: params.Encode(),
}
req, err := http.NewRequest(http.MethodGet, perform.String(), nil)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("User-Agent", "Bloat")
resp, err := httpclient.Do(req)
fmt.Println(req)
fmt.Println(resp)
if err != nil {
return nil, err
}
@ -269,10 +268,10 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, pg *Pa
}
err = json.NewDecoder(resp.Body).Decode(&publicstatuses)
fmt.Println(resp.Body)
if err != nil {
return nil, err
}
return publicstatuses, nil
}

View file

@ -163,6 +163,10 @@ func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
if err != nil {
return err
}
v := make(url.Values)
v.Set("max_id", statuses[len(statuses)-1].ID)
v.Set("instance", instance)
nextLink = "/timeline/" + tType + "?" + v.Encode()
}
title = "True Remote Timeline"
case "twkn":
@ -207,6 +211,10 @@ func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
}
statuses[i].Pleroma.Reactions = reactions
}
if tType == "tremote" {
statuses[i].URL = fmt.Sprintf("/search?q=%s&type=statuses", statuses[i].URL)
}
}
if (len(maxID) > 0 || len(minID) > 0) && len(statuses) > 0 {

View file

@ -227,6 +227,11 @@
</form>
{{end}}
<div class="status-action-container">
{{if eq (printf "%.7s" .URL) "/search"}}
<div class="status-action">
<a href="{{.URL}}">Federate!</a>
</div>
{{else}}
<div class="status-action">
<a href="/thread/{{.ID}}?reply=true#status-{{.ID}}">
reply
@ -237,6 +242,7 @@
{{end}}
</a>
</div>
{{end}}
<div class="status-action">
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self">

View file

@ -13,6 +13,10 @@
</span>
<button type="submit"> Submit </button>
</form>
{{if eq .Instance ""}}
{{else}}
<a href="/timeline/tremote?instance={{.Instance}}"> Look via True remote timeline viewer (works with mastodon API compatible instances) </a>
{{end}}
{{end}}
{{if eq .Type "tag"}}
<form class="search-form" action="/timeline/tag" method="GET">