sort users by mtime
parent
623d411b88
commit
b43e94c2ed
9
main.go
9
main.go
|
@ -21,6 +21,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -235,7 +236,11 @@ func getDefaultHTML() ([]byte, error) {
|
||||||
return defaultIndexHTML, nil
|
return defaultIndexHTML, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type usersByMtime []*user
|
type byMtime []*user
|
||||||
|
|
||||||
|
func (x byMtime) Len() int { return len(x) }
|
||||||
|
func (x byMtime) Less(i, j int) bool { return x[i].Mtime > x[j].Mtime } // because we want DESC
|
||||||
|
func (x byMtime) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
||||||
|
|
||||||
func getUsers() (users []*user, err error) {
|
func getUsers() (users []*user, err error) {
|
||||||
// TODO sort by mtime
|
// TODO sort by mtime
|
||||||
|
@ -332,6 +337,8 @@ func tdp() (tildeData, error) {
|
||||||
return tildeData{}, fmt.Errorf("could not determine uptime: %s", err)
|
return tildeData{}, fmt.Errorf("could not determine uptime: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Sort(byMtime(users))
|
||||||
|
|
||||||
return tildeData{
|
return tildeData{
|
||||||
Name: "tilde.town",
|
Name: "tilde.town",
|
||||||
URL: "https://tilde.town",
|
URL: "https://tilde.town",
|
||||||
|
|
Loading…
Reference in New Issue