small pixel drawing of a pufferfish j3s.sh

remove cruft, sort entries
Jesse Olson j3s@c3f.net
Sat, 16 Apr 2022 06:18:03 +0000
commit

29dfd5cbd8544cfa00af6d95abec92f470f798f6

parent

1951fa9e8f80a806e9b5a804b3e2070015b6eb1b

2 files changed, 13 insertions(+), 8 deletions(-)

jump to
M atom/atom.goatom/atom.go

@@ -7,11 +7,15 @@ "log"

"net/http" "os" "path/filepath" + "sort" "strings" "time" ) const maxFeed = 10 + +var timeLayoutPost = "2006-01-02" +var timeLayoutAtom = "2006-01-02T15:04:05.000Z" type post struct { title string

@@ -30,7 +34,14 @@ if err != nil {

log.Println(err) } - // TODO: sort them by date, then + sort.Slice(posts, func(i, j int) bool { + // we assume that timeLayoutAtom is correct here because + // it was passed up correctly hopefully + ti, _ := time.Parse(timeLayoutAtom, posts[i].updated) + tj, _ := time.Parse(timeLayoutAtom, posts[j].updated) + return ti.After(tj) + }) + if len(posts) > maxFeed { posts = posts[:maxFeed] }

@@ -40,7 +51,6 @@ if len(posts) > 0 {

updated = posts[0].updated } - // SET HEADER TYPE TBH fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom">

@@ -118,8 +128,3 @@ p.updated = updated.Format(timeLayoutAtom)

p.link = "https://j3s.sh/" + file return p, err } - -type TimeStr string - -var timeLayoutPost = "2006-01-02" -var timeLayoutAtom = "2006-01-02T15:04:05.000Z"
M thought/my-website-is-one-binary.htmlthought/my-website-is-one-binary.html

@@ -1,5 +1,5 @@

my website is one binary - 2022-04-01 + 2022-04-06 ---------------------------- a.k.a. this one weird trick that inspires me to program creatively