chore: reverse twts for html
This commit is contained in:
parent
a7009dcb56
commit
6b8ad143fe
11
http-html.go
11
http-html.go
@ -117,7 +117,7 @@ func (r *HTWriter) WriteTo(w io.Writer) (int64, error) {
|
|||||||
i, err = fmt.Fprintln(w, "</pre><main>")
|
i, err = fmt.Fprintln(w, "</pre><main>")
|
||||||
output += int64(i)
|
output += int64(i)
|
||||||
|
|
||||||
for _, twt := range r.Twts() {
|
for _, twt := range reverse(r.Twts()) {
|
||||||
twter := twt.Twter()
|
twter := twt.Twter()
|
||||||
uri, err := url.Parse(twter.URI)
|
uri, err := url.Parse(twter.URI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -157,7 +157,7 @@ func (r *HTWriter) WriteTo(w io.Writer) (int64, error) {
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
`, "/?uri="+twter.URI, "https://txt.sour.is/user/xuu/avatar",
|
`, "/?uri="+twter.URI, twter.Avatar,
|
||||||
"/?uri="+twter.URI, twter.Nick,
|
"/?uri="+twter.URI, twter.Nick,
|
||||||
twter.URI, uri.Host,
|
twter.URI, uri.Host,
|
||||||
"/conv/"+twt.Hash(), fmt.Sprintf("<time datetime='%s'>%s</time>", twt.Created().Format(time.RFC3339), twt.Created().Format(time.RFC822)),
|
"/conv/"+twt.Hash(), fmt.Sprintf("<time datetime='%s'>%s</time>", twt.Created().Format(time.RFC3339), twt.Created().Format(time.RFC822)),
|
||||||
@ -182,3 +182,10 @@ func mkValue(v string) string {
|
|||||||
}
|
}
|
||||||
return v
|
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
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user