From 6b8ad143fe12646cd479e6db4876c969893fc9bc Mon Sep 17 00:00:00 2001 From: xuu Date: Wed, 2 Apr 2025 11:17:46 -0600 Subject: [PATCH] chore: reverse twts for html --- http-html.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/http-html.go b/http-html.go index dbe5bc3..09c46ce 100644 --- a/http-html.go +++ b/http-html.go @@ -117,7 +117,7 @@ func (r *HTWriter) WriteTo(w io.Writer) (int64, error) { i, err = fmt.Fprintln(w, "
") output += int64(i) - for _, twt := range r.Twts() { + for _, twt := range reverse(r.Twts()) { twter := twt.Twter() uri, err := url.Parse(twter.URI) if err != nil { @@ -157,7 +157,7 @@ func (r *HTWriter) WriteTo(w io.Writer) (int64, error) { - `, "/?uri="+twter.URI, "https://txt.sour.is/user/xuu/avatar", + `, "/?uri="+twter.URI, twter.Avatar, "/?uri="+twter.URI, twter.Nick, twter.URI, uri.Host, "/conv/"+twt.Hash(), fmt.Sprintf("", twt.Created().Format(time.RFC3339), twt.Created().Format(time.RFC822)), @@ -182,3 +182,10 @@ func mkValue(v string) string { } return v } + +func reverse[T any](s []T) []T { + for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { + s[i], s[j] = s[j], s[i] + } + return s +}