Quick fixes
alex wennerberg alex@alexwennerberg.com
Sun, 27 Dec 2020 20:08:17 -0800
2 files changed,
23 insertions(+),
1 deletions(-)
M
gemfeed.go
→
gemfeed.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.go
→
gemini.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) }