flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 3fea9763a7096b2cfd756691e68cd017a0c72c12
parent b4c7e88d90f608c2127995eeffdc3d3820b2b276
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun, 27 Dec 2020 20:08:17 -0800

Quick fixes

Diffstat:
Mgemfeed.go | 17++++++++++++++++-
Mgemini.go | 7+++++++
2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gemfeed.go b/gemfeed.go @@ -100,7 +100,22 @@ func getAllGemfeedEntries() ([]*FeedEntry, []*Gemfeed, error) { 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 diff --git a/gemini.go b/gemini.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "crypto/x509/pkix" gmi "git.sr.ht/~adnano/go-gemini" + "io" "io/ioutil" "log" "path" @@ -87,6 +88,12 @@ func gmiPage(w *gmi.ResponseWriter, r *gmi.Request) { } 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) }