flounder

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

commit 1429d073ba5d02bc8b20b3b9cea99a76956de427
parent a748ebeb6a8fdb2e3c36307af3144e5bd815b1a3
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun, 27 Dec 2020 12:57:15 -0800

Add all feeds links

Diffstat:
Mgemfeed.go | 12+++++++-----
Mhttp.go | 5+++--
Mtemplates/feed.html | 4++++
3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gemfeed.go b/gemfeed.go @@ -30,10 +30,11 @@ type FeedEntry struct { } // TODO definitely cache this function -- it reads EVERY gemini file on flounder. -func getAllGemfeedEntries() ([]*FeedEntry, error) { +func getAllGemfeedEntries() ([]*FeedEntry, []*Gemfeed, error) { maxUserItems := 25 - maxItems := 100 + maxItems := 50 var feedEntries []*FeedEntry + var feeds []*Gemfeed err := filepath.Walk(c.FilesDirectory, func(thepath string, info os.FileInfo, err error) error { if isGemini(info.Name()) { f, err := os.Open(thepath) @@ -51,20 +52,21 @@ func getAllGemfeedEntries() ([]*FeedEntry, error) { } feed.Url = &baseUrl feedEntries = append(feedEntries, feed.Entries...) + feeds = append(feeds, feed) } } return nil }) if err != nil { - return nil, err + return nil, nil, err } else { sort.Slice(feedEntries, func(i, j int) bool { return feedEntries[i].Date.After(feedEntries[j].Date) }) if len(feedEntries) > maxItems { - return feedEntries[:maxItems], nil + return feedEntries[:maxItems], feeds, nil } - return feedEntries, nil + return feedEntries, feeds, nil } } diff --git a/http.go b/http.go @@ -80,7 +80,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { func feedHandler(w http.ResponseWriter, r *http.Request) { user := newGetAuthUser(r) - feedEntries, err := getAllGemfeedEntries() + feedEntries, feeds, err := getAllGemfeedEntries() if err != nil { panic(err) } @@ -88,8 +88,9 @@ func feedHandler(w http.ResponseWriter, r *http.Request) { Host string PageTitle string FeedEntries []*FeedEntry + Feeds []*Gemfeed AuthUser AuthUser - }{c.Host, c.SiteTitle, feedEntries, user} + }{c.Host, c.SiteTitle, feedEntries, feeds, user} err = t.ExecuteTemplate(w, "feed.html", data) if err != nil { panic(err) diff --git a/templates/feed.html b/templates/feed.html @@ -12,4 +12,8 @@ For more information on how to format your site to show up here, see <a href="ht {{ if .Feed.Title }}<em><a href="{{.Feed.Url}}" class='person-link'>{{.Feed.Title}}</a></em>{{end}} <a href="{{.Url}}">{{.Title}}</a> </p> {{end}} +<h2>All Feeds:</h2> +{{ range .Feeds}} +<a href="{{.Url}}" class='person-link'>{{.Url}}</a> +{{ end}} {{template "footer" .}}