diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-18 11:19:14 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-18 11:19:14 +0530 |
commit | 85d1bf73559536405d4eb22a6249a1e8d9030be3 (patch) | |
tree | eb50040626531ba313ad149381e0a22a375ccbea /routes/routes.go | |
parent | 7fe98772b079cca83b854e8f8a6be5dc55c10483 (diff) | |
download | legit-85d1bf73559536405d4eb22a6249a1e8d9030be3.tar.gz legit-85d1bf73559536405d4eb22a6249a1e8d9030be3.tar.bz2 legit-85d1bf73559536405d4eb22a6249a1e8d9030be3.zip |
routes: sort repo index by last idle
Diffstat (limited to 'routes/routes.go')
-rw-r--r-- | routes/routes.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/routes/routes.go b/routes/routes.go index 9d165e7..0cd3308 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -6,6 +6,8 @@ import ( "net/http" "os" "path/filepath" + "sort" + "time" "github.com/alexedwards/flow" "github.com/dustin/go-humanize" @@ -25,7 +27,10 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) { return } - type info struct{ Name, Desc, Idle string } + type info struct { + Name, Desc, Idle string + d time.Time + } infos := []info{} @@ -51,9 +56,14 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) { Name: dir.Name(), Desc: desc, Idle: humanize.Time(c.Author.When), + d: c.Author.When, }) } + sort.Slice(infos, func(i, j int) bool { + return infos[j].d.Before(infos[i].d) + }) + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) |