flounder

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

commit e67e3ca21c5304603e79362ca65d62fe8237446c
parent 60a52059eba7a22d2fa7d28328e3a296271aeb79
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Mon, 29 Nov 2021 18:01:15 -0800

Truncate consecutive edits on homepage

Diffstat:
Mdb.go | 21++++++++++++++++++++-
Mtemplates/index.html | 2+-
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/db.go b/db.go @@ -185,7 +185,7 @@ func getUpdatedFiles(admin bool, user string) ([]*File, error) { // TODO cache t log.Printf("Failure accessing a path %q: %v\n", thepath, err) return err // think about } - if info.Name() == "bl4kers" || info.Name() == "0gitnick" || info.Name() == "szczezuja" || info.Name() == "singletona082" { + if info.Name() == "bl4kers" { // Lazy hack return filepath.SkipDir } @@ -205,6 +205,25 @@ func getUpdatedFiles(admin bool, user string) ([]*File, error) { // TODO cache t sort.Slice(result, func(i, j int) bool { return result[i].UpdatedTime.After(result[j].UpdatedTime) }) + // if many in a row, truncate + if user == "" { + maxConsecutive := 5 + newResult := []*File{} + var count int + var user string + for _, f := range result { + if user != f.Creator { + user = f.Creator + count = 1 + } + if count <= maxConsecutive { + newResult = append(newResult, f) + } + count += 1 + } + result = newResult + } + if len(result) > 50 { result = result[:50] } diff --git a/templates/index.html b/templates/index.html @@ -7,7 +7,7 @@ Welcome to {{.Config.SiteTitle}}, a <a href="/register">free</a> web interface f <h2>Recently updated files:</h2> {{ range .Files }} <div class="indent-wrap"> - <a href="//{{.Creator}}.{{$.Config.Host}}" class='person-link'> + <a href="//{{$.Config.Host}}/updates/{{.Creator}}" class='person-link'> {{ .Creator }}</a> <em>{{.TimeAgo}}</em> <a href="//{{.Creator}}.{{$.Config.Host}}/{{.Name}}">