all repos — legit @ 30683a7ceca293d0a3db54f77ecc82c9ddcba787

legit - simple git web interface in go (fork)

add footer, fix HTML hierarchy
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmPeiQ0ACgkQO3+8IhRO
Y5iZ3w//Y5sEKLfZeA0qKqx4JsZsXsAdH1MOHioYKhClWMS+2N7w/C017sh17QCu
pQRKNmh0qP9fDLMZRSV6X6AkcjCEHgV69qZIS8fH7rdII1oR7h/bCD42Xi2iNfNT
MHXAUgGz+RHh3TD1Y51PDHj2I/8Ge1Y3A+uUG1AchQROBU02ej446Rm5j3l10c8w
oObYSHBjkzeVJFF8iEJ09lLUEQLykO1EuGFVtODAzHl+5cu0CgL9AhYKyzkO5s+9
Qho7BGjTFDfKv1k30smPVOnWTlDhMrMqunL5HlbPAkYmDmhzCKGu+5RCgpoebJGF
1yxgv/T/qtmu6diCx6hwFdXMGQv7XWdpZzkd7D67ONhF9f4O/Hq9RaNgnlCI46yL
vOr3Rb5YDnDWDJCNG3ZsqKysqlMBrDmTDt9udeUAEHeUPhfoRH4X032x/LOrAQzT
O7hc7CFtuQMSIW4hT5dzdp6SGHtGB/XPJvawD/eJqD3VwlLqMP/tnpBaViCcOgsT
lcolLEhuGlXPNUFeL2d/y8woCM0+hAaJZIzrD0+5yalPGOW4nvm/R4irs+0URurS
8F2T3ITaj6CxZOGiyZFPqeKPc55iuHAfWf9MwraZ6+Jm5Bmr+zi/HUN0F4VIIvCU
Q+PQMHD1K1ki0n7xMWs5cD35qmIdkxlGsbDtvCxfugQbtMjDaBM=
=DZV0
-----END PGP SIGNATURE-----
commit

30683a7ceca293d0a3db54f77ecc82c9ddcba787

parent

b0c2a8ee3887fc787d89c93732b02ff3c3304363

M config.yamlconfig.yaml

@@ -1,5 +1,5 @@

repo: - scanPath: /var/www/git + scanPath: /var/www/git/ readme: - readme - README

@@ -14,6 +14,8 @@ static: ./static

meta: title: git good description: i think it's a skill issue + footer: served with legit vVERSION; email patches to MAINTAINER + maintainerEmail: x@icyphox.sh server: name: git.icyphox.sh host: 127.0.0.1
M config/config.goconfig/config.go

@@ -3,6 +3,8 @@

import ( "fmt" "os" + "html/template" + "strings" "gopkg.in/yaml.v3" )

@@ -21,6 +23,9 @@ } `yaml:"dirs"`

Meta struct { Title string `yaml:"title"` Description string `yaml:"description"` + Footer string `yaml:"footer,omitempty"` + MaintainerEmail string `yaml:"maintainerEmail,omitempty"` + CompiledFooter template.HTML `yaml:"thisIsNotSupposedToBeHere,omitempty"` } `yaml:"meta"` Server struct { Name string `yaml:"name,omitempty"`

@@ -29,7 +34,23 @@ Port int `yaml:"port"`

} `yaml:"server"` } -func Read(f string) (*Config, error) { +func compileFooter(c *Config, version string) { + if c.Meta.Footer != "" { + c.Meta.CompiledFooter = template.HTML( + strings.ReplaceAll( + strings.ReplaceAll( + c.Meta.Footer, + "VERSION", + version), + "MAINTAINER", + fmt.Sprintf( + "<a href='mailto:%s'>%s</a>", + c.Meta.MaintainerEmail, + c.Meta.MaintainerEmail))) + } +} + +func Read(f, v string) (*Config, error) { b, err := os.ReadFile(f) if err != nil { return nil, fmt.Errorf("reading config: %w", err)

@@ -39,6 +60,8 @@ c := Config{}

if err := yaml.Unmarshal(b, &c); err != nil { return nil, fmt.Errorf("parsing config: %w", err) } + + compileFooter(&c, v) return &c, nil }
M main.gomain.go

@@ -13,11 +13,12 @@ "git.icyphox.sh/legit/routes"

) func main() { + const version string = "0.2.x" var cfg string flag.StringVar(&cfg, "config", "./config.yaml", "path to config file") flag.Parse() - c, err := config.Read(cfg) + c, err := config.Read(cfg, version) if err != nil { log.Fatal(err) }
M routes/routes.goroutes/routes.go

@@ -148,6 +148,7 @@ data["commits"] = commits

data["desc"] = getDescription(path) data["servername"] = d.c.Server.Name data["gomod"] = isGoModule(gr) + data["meta"] = d.c.Meta if err := d.t.ExecuteTemplate(w, "repo", data); err != nil { log.Println(err)
M static/style.cssstatic/style.css

@@ -45,6 +45,12 @@ padding: 0;

line-height: 160%; } +footer { + font-size: 85%; + padding: 1em; + text-align: center; +} + main h1, h2, h3, strong { font-family: var(--display-font); font-weight: 500;
M templates/commit.htmltemplates/commit.html

@@ -1,9 +1,8 @@

{{ define "commit" }} <html> {{ template "head" . }} - + <body> {{ template "repoheader" . }} - <body> {{ template "nav" . }} <main> <section class="commit">

@@ -104,6 +103,7 @@ </div>

{{ end }} </section> </main> + {{ template "footer" .meta }} </body> </html> {{ end }}
M templates/file.htmltemplates/file.html

@@ -3,8 +3,8 @@ <html>

{{ template "head" . }} <title>{{.name }} &mdash; {{ .path }}</title> - {{ template "repoheader" . }} <body> + {{ template "repoheader" . }} {{ template "nav" . }} <main> <p>{{ .path }} (<a href="{{ .raw }}">raw</a>)</p>

@@ -25,6 +25,7 @@ </td>

</tbody></tr> </table> </main> + {{ template "footer" .meta }} </body> </html> {{ end }}
A templates/footer.html

@@ -0,0 +1,7 @@

+{{ define "footer" }} +{{ if .CompiledFooter }} +<footer> +<span>{{ .CompiledFooter }}</span> +</footer> +{{ end }} +{{ end }}
M templates/index.htmltemplates/index.html

@@ -6,11 +6,12 @@ <title>

{{ .meta.Title }} </title> - <header> - <h1>{{ .meta.Title }}</h1> - <h2>{{ .meta.Description }}</h2> - </header> + <body> + <header> + <h1>{{ .meta.Title }}</h1> + <h2>{{ .meta.Description }}</h2> + </header> <main> <div class="index"> {{ range .info }}

@@ -20,6 +21,8 @@ <div>{{ .Idle }}</div>

{{ end }} </div> </main> + {{ template "footer" .meta }} </body> + </html> {{ end }}
M templates/log.htmltemplates/log.html

@@ -6,8 +6,8 @@ <title>

{{ .name }} &mdash; log </title> - {{ template "repoheader" . }} <body> + {{ template "repoheader" . }} {{ template "nav" . }} <main> {{ $repo := .name }}

@@ -24,6 +24,7 @@ </div>

{{ end }} </div> </main> + {{ template "footer" .meta }} </body> </html> {{ end }}
M templates/refs.htmltemplates/refs.html

@@ -6,8 +6,8 @@ <title>

{{ .name }} &mdash; refs </title> - {{ template "repoheader" . }} <body> + {{ template "repoheader" . }} {{ template "nav" . }} <main> {{ $name := .name }}

@@ -47,6 +47,8 @@ {{ end }}

</div> {{ end }} </main> + {{ template "footer" .meta }} </body> + </html> {{ end }}
M templates/repo.htmltemplates/repo.html

@@ -6,10 +6,8 @@ &mdash; {{ .parent }}

{{ end }} </title> {{ template "head" . }} - -{{ template "repoheader" . }} - <body> + {{ template "repoheader" . }} {{ template "nav" . }} <main> {{ $repo := .name }}

@@ -38,6 +36,8 @@ git clone https://{{ .servername }}/{{ .name }}

</pre> </div> </main> + {{ template "footer" .meta }} </body> + </html> {{ end }}
M templates/tree.htmltemplates/tree.html

@@ -6,9 +6,8 @@ &mdash; {{ .parent }}

{{ end }} </title> {{ template "head" . }} - - {{ template "repoheader" . }} <body> + {{ template "repoheader" . }} {{ template "nav" . }} <main> {{ $repo := .name }}

@@ -53,7 +52,7 @@ </td>

</tr> {{ end }} {{ end }} - </div> + </table> <article> <pre> {{- if .readme }}{{ .readme }}{{- end -}}

@@ -61,5 +60,6 @@ </pre>

</article> </main> </body> + {{ template "footer" .meta }} </html> {{ end }}