all repos — flounder @ 3fea9763a7096b2cfd756691e68cd017a0c72c12

A small site builder for the Gemini protocol

Quick fixes
alex wennerberg alex@alexwennerberg.com
Sun, 27 Dec 2020 20:08:17 -0800
commit

3fea9763a7096b2cfd756691e68cd017a0c72c12

parent

b4c7e88d90f608c2127995eeffdc3d3820b2b276

2 files changed, 23 insertions(+), 1 deletions(-)

jump to
M gemfeed.gogemfeed.go

@@ -100,7 +100,22 @@ maxUserItems := 25

maxItems := 50 var feedEntries []*FeedEntry var feeds []*Gemfeed - err := filepath.Walk(c.FilesDirectory, func(thepath string, info os.FileInfo, err error) error { + users, err := getActiveUserNames() + if err != nil { + return nil, nil, err + } else { + for _, user := range users { + fe := generateFeedFromUser(user) + if len(fe) > 0 { + feeds = append(feeds, fe[0].Feed) + for _, e := range fe { + feedEntries = append(feedEntries, &e) + } + } + } + } + + err = filepath.Walk(c.FilesDirectory, func(thepath string, info os.FileInfo, err error) error { if isGemini(info.Name()) { f, err := os.Open(thepath) // TODO verify no path bugs here
M gemini.gogemini.go

@@ -5,6 +5,7 @@ "bytes"

"crypto/tls" "crypto/x509/pkix" gmi "git.sr.ht/~adnano/go-gemini" + "io" "io/ioutil" "log" "path"

@@ -86,6 +87,12 @@ w.WriteStatus(gmi.StatusNotFound)

return } log.Println("Request for gemini file", fileName, "for user", userName) + + if fileName == "/gemlog" { // temp hack + w.SetMediaType("text/gemini") + io.Copy(w, strings.NewReader(generateGemfeedPage(userName))) + return + } gmi.ServeFile(w, gmi.Dir(path.Join(c.FilesDirectory, userName)), fileName) }