web frontend for git (tangled's grandpa)
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

routes: description and humanized time to index

+26 -7
+1
go.mod
··· 5 5 require ( 6 6 github.com/alexedwards/flow v0.0.0-20220806114457-cf11be9e0e03 7 7 github.com/bluekeyes/go-gitdiff v0.7.0 8 + github.com/dustin/go-humanize v1.0.0 8 9 github.com/go-git/go-git/v5 v5.5.1 9 10 gopkg.in/yaml.v3 v3.0.0 10 11 )
+2
go.sum
··· 21 21 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 22 22 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 23 23 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 24 + github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= 25 + github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 24 26 github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= 25 27 github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= 26 28 github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
+18 -4
routes/routes.go
··· 6 6 "net/http" 7 7 "os" 8 8 "path/filepath" 9 - "time" 10 9 11 10 "github.com/alexedwards/flow" 11 + "github.com/dustin/go-humanize" 12 12 "icyphox.sh/legit/config" 13 13 "icyphox.sh/legit/git" 14 14 ) ··· 25 25 return 26 26 } 27 27 28 - repoInfo := make(map[string]time.Time) 28 + type info struct{ Name, Desc, Idle string } 29 + 30 + infos := []info{} 29 31 30 32 for _, dir := range dirs { 31 33 path := filepath.Join(d.c.Repo.ScanPath, dir.Name()) ··· 42 44 log.Println(err) 43 45 } 44 46 45 - repoInfo[dir.Name()] = c.Author.When 47 + var desc string 48 + db, err := os.ReadFile(filepath.Join(path, "description")) 49 + if err == nil { 50 + desc = string(db) 51 + } else { 52 + desc = "" 53 + } 54 + 55 + infos = append(infos, info{ 56 + Name: dir.Name(), 57 + Desc: desc, 58 + Idle: humanize.Time(c.Author.When), 59 + }) 46 60 } 47 61 48 62 tpath := filepath.Join(d.c.Template.Dir, "*") ··· 50 64 51 65 data := make(map[string]interface{}) 52 66 data["meta"] = d.c.Meta 53 - data["info"] = repoInfo 67 + data["info"] = infos 54 68 55 69 if err := t.ExecuteTemplate(w, "index", data); err != nil { 56 70 log.Println(err)
+5 -3
templates/index.html
··· 12 12 <table> 13 13 <tr> 14 14 <td>repository</td> 15 + <td>description</td> 15 16 <td>last active</td> 16 17 </tr> 17 - {{ range $repo, $lc := .info }} 18 + {{ range .info }} 18 19 <tr> 19 - <td><a href="/{{ $repo }}">{{ $repo }}</a></td> 20 - <td>{{ $lc }}</td> 20 + <td><a href="/{{ .Name }}">{{ .Name }}</a></td> 21 + <td>{{ .Desc }}</td> 22 + <td>{{ .Idle }}</td> 21 23 </tr> 22 24 {{ end }} 23 25 </table>