web frontend for git (tangled's grandpa)

git: hide .git extension

authored by

Marco Andronaco and committed by
GitHub
8a0ebe22 9d1d6aae

+25 -8
+15 -6
routes/routes.go
··· 33 } 34 35 type info struct { 36 - Name, Desc, Idle string 37 - d time.Time 38 } 39 40 infos := []info{} ··· 58 return 59 } 60 61 desc := getDescription(path) 62 63 infos = append(infos, info{ 64 - Name: dir.Name(), 65 - Desc: desc, 66 - Idle: humanize.Time(c.Author.When), 67 - d: c.Author.When, 68 }) 69 } 70 ··· 149 150 data := make(map[string]any) 151 data["name"] = name 152 data["ref"] = mainBranch 153 data["readme"] = readmeContent 154 data["commits"] = commits ··· 191 192 data := make(map[string]any) 193 data["name"] = name 194 data["ref"] = ref 195 data["parent"] = treePath 196 data["desc"] = getDescription(path) ··· 225 contents, err := gr.FileContent(treePath) 226 data := make(map[string]any) 227 data["name"] = name 228 data["ref"] = ref 229 data["desc"] = getDescription(path) 230 data["path"] = treePath ··· 317 data["commits"] = commits 318 data["meta"] = d.c.Meta 319 data["name"] = name 320 data["ref"] = ref 321 data["desc"] = getDescription(path) 322 data["log"] = true ··· 359 data["diff"] = diff.Diff 360 data["meta"] = d.c.Meta 361 data["name"] = name 362 data["ref"] = ref 363 data["desc"] = getDescription(path) 364 ··· 402 403 data["meta"] = d.c.Meta 404 data["name"] = name 405 data["branches"] = branches 406 data["tags"] = tags 407 data["desc"] = getDescription(path)
··· 33 } 34 35 type info struct { 36 + DisplayName, Name, Desc, Idle string 37 + d time.Time 38 } 39 40 infos := []info{} ··· 58 return 59 } 60 61 + name := dir.Name() 62 + 63 desc := getDescription(path) 64 65 infos = append(infos, info{ 66 + DisplayName: getDisplayName(name), 67 + Name: name, 68 + Desc: desc, 69 + Idle: humanize.Time(c.Author.When), 70 + d: c.Author.When, 71 }) 72 } 73 ··· 152 153 data := make(map[string]any) 154 data["name"] = name 155 + data["displayname"] = getDisplayName(name) 156 data["ref"] = mainBranch 157 data["readme"] = readmeContent 158 data["commits"] = commits ··· 195 196 data := make(map[string]any) 197 data["name"] = name 198 + data["displayname"] = getDisplayName(name) 199 data["ref"] = ref 200 data["parent"] = treePath 201 data["desc"] = getDescription(path) ··· 230 contents, err := gr.FileContent(treePath) 231 data := make(map[string]any) 232 data["name"] = name 233 + data["displayname"] = getDisplayName(name) 234 data["ref"] = ref 235 data["desc"] = getDescription(path) 236 data["path"] = treePath ··· 323 data["commits"] = commits 324 data["meta"] = d.c.Meta 325 data["name"] = name 326 + data["displayname"] = getDisplayName(name) 327 data["ref"] = ref 328 data["desc"] = getDescription(path) 329 data["log"] = true ··· 366 data["diff"] = diff.Diff 367 data["meta"] = d.c.Meta 368 data["name"] = name 369 + data["displayname"] = getDisplayName(name) 370 data["ref"] = ref 371 data["desc"] = getDescription(path) 372 ··· 410 411 data["meta"] = d.c.Meta 412 data["name"] = name 413 + data["displayname"] = getDisplayName(name) 414 data["branches"] = branches 415 data["tags"] = tags 416 data["desc"] = getDescription(path)
+8
routes/util.go
··· 16 return err == nil 17 } 18 19 func getDescription(path string) (desc string) { 20 db, err := os.ReadFile(filepath.Join(path, "description")) 21 if err == nil {
··· 16 return err == nil 17 } 18 19 + func getDisplayName(name string) string { 20 + l := len(name) - 4 21 + if name[l:] == ".git" { 22 + name = name[:l] 23 + } 24 + return name 25 + } 26 + 27 func getDescription(path string) (desc string) { 28 db, err := os.ReadFile(filepath.Join(path, "description")) 29 if err == nil {
+1 -1
templates/index.html
··· 10 <main> 11 <div class="index"> 12 {{ range .info }} 13 - <div class="index-name"><a href="/{{ .Name }}">{{ .Name }}</a></div> 14 <div class="desc">{{ .Desc }}</div> 15 <div>{{ .Idle }}</div> 16 {{ end }}
··· 10 <main> 11 <div class="index"> 12 {{ range .info }} 13 + <div class="index-name"><a href="/{{ .Name }}">{{ .DisplayName }}</a></div> 14 <div class="desc">{{ .Desc }}</div> 15 <div>{{ .Idle }}</div> 16 {{ end }}
+1 -1
templates/repo-header.html
··· 2 <header> 3 <h2> 4 <a href="/">all repos</a> 5 - &mdash; {{ .name }} 6 {{ if .ref }} 7 <span class="ref">@ {{ .ref }}</span> 8 {{ end }}
··· 2 <header> 3 <h2> 4 <a href="/">all repos</a> 5 + &mdash; {{ .displayname }} 6 {{ if .ref }} 7 <span class="ref">@ {{ .ref }}</span> 8 {{ end }}