all repos — legit @ 85d1bf73559536405d4eb22a6249a1e8d9030be3

legit - simple git web interface in go (fork)

routes: sort repo index by last idle
Anirudh Oppiliappan x@icyphox.sh
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEE/huPz+bBYiLxVxyOipP5b3jF1MQFAmOeqesACgkQipP5b3jF
1MTtLwf/YkmScsShpDmCHVyiP9eqYFB7WX0O9Gq/Q6gOA6rw+HObE6dm0v1t3uyX
3oWyp7VGsjGidzl8I0l0VSP1Oxd2vNEE1XzjgDv4HMmfnhXABGRgXCkQnzVqXqN7
zuEQymAX2xz1BI5iObXQGHkN2FcUjzQXIim2n1bNw3w5vjf3P9wpeGsO/B5fPL7c
P4ohXhHao7npDYaBi9LIOgFTq31EjREQtlMRaySQU9X+b6yxBdDtKizLa7D7ijsk
Inj9W7drlQd1Y6E5O3AUVg2oQY5aUfFqzxh3gGTTAoi3fMGH84jSLvFq+TA+euoH
Z/y3f6X3dEYlLLxKDFDVL0e7d5OaKQ==
=qL8t
-----END PGP SIGNATURE-----
commit

85d1bf73559536405d4eb22a6249a1e8d9030be3

parent

7fe98772b079cca83b854e8f8a6be5dc55c10483

1 files changed, 11 insertions(+), 1 deletions(-)

jump to
M routes/routes.goroutes/routes.go

@@ -6,6 +6,8 @@ "log"

"net/http" "os" "path/filepath" + "sort" + "time" "github.com/alexedwards/flow" "github.com/dustin/go-humanize"

@@ -25,7 +27,10 @@ log.Printf("reading scan path: %s", err)

return } - type info struct{ Name, Desc, Idle string } + type info struct { + Name, Desc, Idle string + d time.Time + } infos := []info{}

@@ -51,8 +56,13 @@ infos = append(infos, info{

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))