all repos — legit @ 8a0ebe220af6aa7e7138def83b7cd2ebbc8418b2

web frontend for git, written in go

git: hide .git extension

Marco Andronaco andronacomarco@gmail.com
Fri, 05 Jul 2024 16:32:34 +0000
commit

8a0ebe220af6aa7e7138def83b7cd2ebbc8418b2

parent

9d1d6aaeb8295e489274446a9683b9680a99044c

4 files changed, 25 insertions(+), 8 deletions(-)

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

@@ -33,8 +33,8 @@ return

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

@@ -58,13 +58,16 @@ log.Println(err)

return } + name := dir.Name() + desc := getDescription(path) infos = append(infos, info{ - Name: dir.Name(), - Desc: desc, - Idle: humanize.Time(c.Author.When), - d: c.Author.When, + DisplayName: getDisplayName(name), + Name: name, + Desc: desc, + Idle: humanize.Time(c.Author.When), + d: c.Author.When, }) }

@@ -149,6 +152,7 @@ }

data := make(map[string]any) data["name"] = name + data["displayname"] = getDisplayName(name) data["ref"] = mainBranch data["readme"] = readmeContent data["commits"] = commits

@@ -191,6 +195,7 @@ }

data := make(map[string]any) data["name"] = name + data["displayname"] = getDisplayName(name) data["ref"] = ref data["parent"] = treePath data["desc"] = getDescription(path)

@@ -225,6 +230,7 @@

contents, err := gr.FileContent(treePath) data := make(map[string]any) data["name"] = name + data["displayname"] = getDisplayName(name) data["ref"] = ref data["desc"] = getDescription(path) data["path"] = treePath

@@ -317,6 +323,7 @@ data := make(map[string]interface{})

data["commits"] = commits data["meta"] = d.c.Meta data["name"] = name + data["displayname"] = getDisplayName(name) data["ref"] = ref data["desc"] = getDescription(path) data["log"] = true

@@ -359,6 +366,7 @@ data["stat"] = diff.Stat

data["diff"] = diff.Diff data["meta"] = d.c.Meta data["name"] = name + data["displayname"] = getDisplayName(name) data["ref"] = ref data["desc"] = getDescription(path)

@@ -402,6 +410,7 @@ data := make(map[string]interface{})

data["meta"] = d.c.Meta data["name"] = name + data["displayname"] = getDisplayName(name) data["branches"] = branches data["tags"] = tags data["desc"] = getDescription(path)
M routes/util.goroutes/util.go

@@ -16,6 +16,14 @@ _, err := gr.FileContent("go.mod")

return err == nil } +func getDisplayName(name string) string { + l := len(name) - 4 + if name[l:] == ".git" { + name = name[:l] + } + return name +} + func getDescription(path string) (desc string) { db, err := os.ReadFile(filepath.Join(path, "description")) if err == nil {
M templates/index.htmltemplates/index.html

@@ -10,7 +10,7 @@ <body>

<main> <div class="index"> {{ range .info }} - <div class="index-name"><a href="/{{ .Name }}">{{ .Name }}</a></div> + <div class="index-name"><a href="/{{ .Name }}">{{ .DisplayName }}</a></div> <div class="desc">{{ .Desc }}</div> <div>{{ .Idle }}</div> {{ end }}
M templates/repo-header.htmltemplates/repo-header.html

@@ -2,7 +2,7 @@ {{ define "repoheader" }}

<header> <h2> <a href="/">all repos</a> - &mdash; {{ .name }} + &mdash; {{ .displayname }} {{ if .ref }} <span class="ref">@ {{ .ref }}</span> {{ end }}