routes: sort repo index by last idle
This commit is contained in:
parent
7fe98772b0
commit
85d1bf7355
1 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alexedwards/flow"
|
"github.com/alexedwards/flow"
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
@ -25,7 +27,10 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type info struct{ Name, Desc, Idle string }
|
type info struct {
|
||||||
|
Name, Desc, Idle string
|
||||||
|
d time.Time
|
||||||
|
}
|
||||||
|
|
||||||
infos := []info{}
|
infos := []info{}
|
||||||
|
|
||||||
|
@ -51,9 +56,14 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) {
|
||||||
Name: dir.Name(),
|
Name: dir.Name(),
|
||||||
Desc: desc,
|
Desc: desc,
|
||||||
Idle: humanize.Time(c.Author.When),
|
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, "*")
|
tpath := filepath.Join(d.c.Dirs.Templates, "*")
|
||||||
t := template.Must(template.ParseGlob(tpath))
|
t := template.Must(template.ParseGlob(tpath))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue