From 32f84de36c9da1da47b718cb942afa36d1b23922 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 23 Sep 2023 13:10:27 -0600 Subject: use .gmi, .gmi.txt, .gph, .gph.txt everywhere for templates --- gemini.go | 22 ++++++++--------- gopher.go | 52 ++++++++++++++++++++--------------------- templates.go | 14 +++++++---- templates/branch_list.gophermap | 9 ------- templates/branch_list.gph | 9 +++++++ templates/diff.gmi | 1 - templates/diff.gmi.txt | 1 + templates/diff.gophertext | 1 - templates/diff.gph.txt | 1 + templates/diffstat.gmi | 1 - templates/diffstat.gmi.txt | 1 + templates/diffstat.gophertext | 1 - templates/diffstat.gph.txt | 1 + templates/ref.gophermap | 42 --------------------------------- templates/ref.gph | 42 +++++++++++++++++++++++++++++++++ templates/repo_home.gophermap | 24 ------------------- templates/repo_home.gph | 24 +++++++++++++++++++ templates/repo_root.gophermap | 7 ------ templates/repo_root.gph | 7 ++++++ templates/tag_list.gophermap | 9 ------- templates/tag_list.gph | 9 +++++++ templates/tree.gophermap | 9 ------- templates/tree.gph | 9 +++++++ 23 files changed, 150 insertions(+), 146 deletions(-) delete mode 100644 templates/branch_list.gophermap create mode 100644 templates/branch_list.gph delete mode 100644 templates/diff.gmi create mode 100644 templates/diff.gmi.txt delete mode 100644 templates/diff.gophertext create mode 100644 templates/diff.gph.txt delete mode 100644 templates/diffstat.gmi create mode 100644 templates/diffstat.gmi.txt delete mode 100644 templates/diffstat.gophertext create mode 100644 templates/diffstat.gph.txt delete mode 100644 templates/ref.gophermap create mode 100644 templates/ref.gph delete mode 100644 templates/repo_home.gophermap create mode 100644 templates/repo_home.gph delete mode 100644 templates/repo_root.gophermap create mode 100644 templates/repo_root.gph delete mode 100644 templates/tag_list.gophermap create mode 100644 templates/tag_list.gph delete mode 100644 templates/tree.gophermap create mode 100644 templates/tree.gph diff --git a/gemini.go b/gemini.go index cf7db73..91de5aa 100644 --- a/gemini.go +++ b/gemini.go @@ -34,15 +34,15 @@ const ( // The overrides argument can provide templates to define the behavior of nearly all of the above // routes. All of them have default implementations so the argument can even be nil, but otherwise // the template names used are: -// repo_root.gmi gemtext at / -// repo_home.gmi gemtext at /:repository/ -// branch_list.gmi gemtext at /:repository/branches -// tag_list.gmi gemtext at /:repository/tags -// ref.gmi gemtext at /:repository/refs/:ref/ -// tree.gmi gemtext for directories requested under /:repository/refs/:ref/tree/*path -// (file paths return the raw files without any template involved) -// diffstat.gmi the plaintext diffstat at /:repository/diffstat/:fromref/:toref -// diff.gmi the text/x-diff at /:repository/diff/:fromref/:toref +// repo_root.gmi gemtext at / +// repo_home.gmi gemtext at /:repository/ +// branch_list.gmi gemtext at /:repository/branches +// tag_list.gmi gemtext at /:repository/tags +// ref.gmi gemtext at /:repository/refs/:ref/ +// tree.gmi gemtext for directories requested under /:repository/refs/:ref/tree/*path +// (file paths return the raw files without any template involved) +// diffstat.gmi.txt the plaintext diffstat at /:repository/diffstat/:fromref/:toref +// diff.gmi.txt the text/x-diff at /:repository/diff/:fromref/:toref // // Most of the templates above are rendered with an object with 3 fields: // Ctx: the context.Context from the request @@ -63,8 +63,8 @@ func GeminiRouter(repodir string, overrides *template.Template) *sliderule.Route repoRouter.Route("/tags", gmiTemplate(tmpl, "tag_list.gmi")) repoRouter.Route("/refs/:ref/", gmiTemplate(tmpl, "ref.gmi")) repoRouter.Route("/refs/:ref/tree/*path", geminiTreePath(tmpl)) - repoRouter.Route("/diffstat/:fromref/:toref", runGemiTemplate(tmpl, "diffstat.gmi", "text/plain")) - repoRouter.Route("/diff/:fromref/:toref", runGemiTemplate(tmpl, "diff.gmi", "text/x-diff")) + repoRouter.Route("/diffstat/:fromref/:toref", runGemiTemplate(tmpl, "diffstat.gmi.txt", "text/plain")) + repoRouter.Route("/diff/:fromref/:toref", runGemiTemplate(tmpl, "diff.gmi.txt", "text/x-diff")) router := &sliderule.Router{} router.Route("/", geminiRoot(repodir, tmpl)) diff --git a/gopher.go b/gopher.go index 369bc29..196c1d0 100644 --- a/gopher.go +++ b/gopher.go @@ -17,13 +17,13 @@ import ( // GopherRouter builds a router that will handle gopher requests in a directory of git repositories. // // The routes it defines are: -// / gophermap listing of the repositories in the directory -// /:repository gophermap overview of the repository -// /:repository/branches gophermap list of branches/head -// /:repository/tags gophermap listing of tags -// /:repository/refs/:ref gophermap overview of a ref -// /:repository/refs/:ref/tree gophermap listing of a ref's root directory -// /:repository/refs/:ref/tree/*path for directories: gophermap list of contents +// / .gph listing of the repositories in the directory +// /:repository .gph overview of the repository +// /:repository/branches .gph list of branches/head +// /:repository/tags .gph listing of tags +// /:repository/refs/:ref .gph overview of a ref +// /:repository/refs/:ref/tree .gph listing of a ref's root directory +// /:repository/refs/:ref/tree/*path for directories:.gph list of contents // for files: raw files (guessed item type text/binary/image/etc) // /:repository/diffstat/:fromref/:toref text diffstat between two refs // /:repository/diff/:fromref/:toref text diff between two refs @@ -31,15 +31,15 @@ import ( // The overrides argument can provide templates to define the behavior of nearly all of the above routes. // All of them have default implementations, so the argument can be nil, but otherwise the template names // used are: -// repo_root.gophermap gophermap at / -// repo_home.gophermap gophermap at /:repository -// branch_list.gophermap gophermap at /:repository/branches -// tag_list.gophermap gophermap at /:repository/tags -// ref.gophermap gophermap at /:repository/refs/:ref -// tree.gophermap gophermap at direcotry paths under /:repository/refs/:ref/tree/*path -// (file paths return the raw files without any template involved) -// diffstat.gophertext plain text diffstat at /:repository/diffstat/:fromref/:toref -// diff.gophertext plain text diff at /:repository/diff/:fromref/:toref +// repo_root.gph gophermap at / +// repo_home.gph gophermap at /:repository +// branch_list.gph gophermap at /:repository/branches +// tag_list.gph gophermap at /:repository/tags +// ref.gph gophermap at /:repository/refs/:ref +// tree.gph gophermap at direcotry paths under /:repository/refs/:ref/tree/*path +// (file paths return the raw files without any template involved) +// diffstat.gph.txt plain text diffstat at /:repository/diffstat/:fromref/:toref +// diff.gph.txt plain text diff at /:repository/diff/:fromref/:toref // // Most of the templates above are rendered with an object with 6 fields: // Ctx: the context.Context from the request @@ -49,7 +49,7 @@ import ( // Port: the port number of the running server // Selector: the selector in the current request // -// The only exception is repo_root.gophermap, which is instead rendered with a slice of the repo names. +// The only exception is repo_root.gph, which is instead rendered with a slice of the repo names. // // All templates have 3 additional functions made available to them: // combine: func(string, ...string) string - successively combines paths using url.URL.ResolveReference @@ -63,17 +63,17 @@ func GopherRouter(repodir string, overrides *template.Template) *sliderule.Route repoRouter := &sliderule.Router{} repoRouter.Use(assignRepo(repodir)) - repoRouter.Route("/branches", runGopherTemplate(tmpl, "branch_list.gophermap", gopher.MenuType)) - repoRouter.Route("/tags", runGopherTemplate(tmpl, "tag_list.gophermap", gopher.MenuType)) - repoRouter.Route("/refs/:ref", runGopherTemplate(tmpl, "ref.gophermap", gopher.MenuType)) + repoRouter.Route("/branches", runGopherTemplate(tmpl, "branch_list.gph", gopher.MenuType)) + repoRouter.Route("/tags", runGopherTemplate(tmpl, "tag_list.gph", gopher.MenuType)) + repoRouter.Route("/refs/:ref", runGopherTemplate(tmpl, "ref.gph", gopher.MenuType)) repoRouter.Route("/refs/:ref/tree", gopherTreePath(tmpl, false)) repoRouter.Route("/refs/:ref/tree/*path", gopherTreePath(tmpl, true)) - repoRouter.Route("/diffstat/:fromref/:toref", runGopherTemplate(tmpl, "diffstat.gophertext", gopher.TextFileType)) - repoRouter.Route("/diff/:fromref/:toref", runGopherTemplate(tmpl, "diff.gophertext", gopher.TextFileType)) + repoRouter.Route("/diffstat/:fromref/:toref", runGopherTemplate(tmpl, "diffstat.gph.txt", gopher.TextFileType)) + repoRouter.Route("/diff/:fromref/:toref", runGopherTemplate(tmpl, "diff.gph.txt", gopher.TextFileType)) router := &sliderule.Router{} router.Route("/", gopherRoot(repodir, tmpl)) - router.Route("/:"+reponamekey, assignRepo(repodir)(runGopherTemplate(tmpl, "repo_home.gophermap", gopher.MenuType))) + router.Route("/:"+reponamekey, assignRepo(repodir)(runGopherTemplate(tmpl, "repo_home.gph", gopher.MenuType))) router.Mount("/:"+reponamekey, repoRouter) return router @@ -100,7 +100,7 @@ func gopherRoot(repodir string, tmpl *template.Template) sliderule.Handler { "Port": request.Port(), "Selector": request.Path, } - if err := tmpl.ExecuteTemplate(buf, "repo_root.gophermap", obj); err != nil { + if err := tmpl.ExecuteTemplate(buf, "repo_root.gph", obj); err != nil { return gopher.Error(err).Response() } @@ -126,7 +126,7 @@ func gopherTreePath(tmpl *template.Template, haspath bool) sliderule.Handler { if !haspath { params["path"] = "" } - return runGopherTemplate(tmpl, "tree.gophermap", gopher.MenuType).Handle(ctx, request) + return runGopherTemplate(tmpl, "tree.gph", gopher.MenuType).Handle(ctx, request) } body, err := repo.Blob(ctx, params["ref"], params["path"]) @@ -136,7 +136,7 @@ func gopherTreePath(tmpl *template.Template, haspath bool) sliderule.Handler { filetype := gopher.MenuType ext := path.Ext(params["path"]) - if ext != ".gophermap" && params["path"] != "gophermap" { + if ext != ".gph" && params["path"] != "gophermap" { mtype := mime.TypeByExtension(ext) if strings.HasPrefix(mtype, "text/") { filetype = gopher.TextFileType diff --git a/templates.go b/templates.go index ff45997..c90cb09 100644 --- a/templates.go +++ b/templates.go @@ -9,13 +9,17 @@ import ( ) var ( - //go:embed templates/*.gmi + //go:embed templates/*.gmi templates/*.gmi.txt geminiTemplateFS embed.FS - geminiTemplate = template.Must(template.ParseFS(geminiTemplateFS, "templates/*.gmi")) + geminiTemplate = template.Must(template.ParseFS( + geminiTemplateFS, + "templates/*.gmi", + "templates/*.gmi.txt", + )) ) var ( - //go:embed templates/*.gophermap templates/*.gophertext + //go:embed templates/*.gph templates/*.gph.txt gopherTemplateFS embed.FS gopherTemplate = template.Must( template.New("gopher").Funcs(template.FuncMap{ @@ -24,8 +28,8 @@ var ( "rawtext": gopherRawtext, }).ParseFS( gopherTemplateFS, - "templates/*.gophermap", - "templates/*.gophertext", + "templates/*.gph", + "templates/*.gph.txt", ), ) ) diff --git a/templates/branch_list.gophermap b/templates/branch_list.gophermap deleted file mode 100644 index cd238ad..0000000 --- a/templates/branch_list.gophermap +++ /dev/null @@ -1,9 +0,0 @@ -i{{.Repo.Name}} Branches ⌥ {{.Selector}} {{.Host}} {{.Port}} -i{{ range .Repo.NameBytes }}-{{ end }}----------- {{.Selector}} {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -{{ range .Repo.Refs .Ctx -}} -{{ if .IsBranch -}} -1{{.ShortName}} {{combine $.Selector "refs/" .Hash}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ end -}} -. diff --git a/templates/branch_list.gph b/templates/branch_list.gph new file mode 100644 index 0000000..cd238ad --- /dev/null +++ b/templates/branch_list.gph @@ -0,0 +1,9 @@ +i{{.Repo.Name}} Branches ⌥ {{.Selector}} {{.Host}} {{.Port}} +i{{ range .Repo.NameBytes }}-{{ end }}----------- {{.Selector}} {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +{{ range .Repo.Refs .Ctx -}} +{{ if .IsBranch -}} +1{{.ShortName}} {{combine $.Selector "refs/" .Hash}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ end -}} +. diff --git a/templates/diff.gmi b/templates/diff.gmi deleted file mode 100644 index f2b795b..0000000 --- a/templates/diff.gmi +++ /dev/null @@ -1 +0,0 @@ -{{.Repo.Diff .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diff.gmi.txt b/templates/diff.gmi.txt new file mode 100644 index 0000000..f2b795b --- /dev/null +++ b/templates/diff.gmi.txt @@ -0,0 +1 @@ +{{.Repo.Diff .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diff.gophertext b/templates/diff.gophertext deleted file mode 100644 index f2b795b..0000000 --- a/templates/diff.gophertext +++ /dev/null @@ -1 +0,0 @@ -{{.Repo.Diff .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diff.gph.txt b/templates/diff.gph.txt new file mode 100644 index 0000000..f2b795b --- /dev/null +++ b/templates/diff.gph.txt @@ -0,0 +1 @@ +{{.Repo.Diff .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diffstat.gmi b/templates/diffstat.gmi deleted file mode 100644 index a51e06b..0000000 --- a/templates/diffstat.gmi +++ /dev/null @@ -1 +0,0 @@ -{{.Repo.Diffstat .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diffstat.gmi.txt b/templates/diffstat.gmi.txt new file mode 100644 index 0000000..a51e06b --- /dev/null +++ b/templates/diffstat.gmi.txt @@ -0,0 +1 @@ +{{.Repo.Diffstat .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diffstat.gophertext b/templates/diffstat.gophertext deleted file mode 100644 index a51e06b..0000000 --- a/templates/diffstat.gophertext +++ /dev/null @@ -1 +0,0 @@ -{{.Repo.Diffstat .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diffstat.gph.txt b/templates/diffstat.gph.txt new file mode 100644 index 0000000..a51e06b --- /dev/null +++ b/templates/diffstat.gph.txt @@ -0,0 +1 @@ +{{.Repo.Diffstat .Ctx .Params.fromref .Params.toref}} diff --git a/templates/ref.gophermap b/templates/ref.gophermap deleted file mode 100644 index c7de102..0000000 --- a/templates/ref.gophermap +++ /dev/null @@ -1,42 +0,0 @@ -{{ with .Repo.Commit .Ctx .Params.ref -}} -i{{.Repo.Name}} {{slice .Hash 0 8}} {{$.Selector}} {{$.Host}} {{$.Port}} -i{{ range .Repo.NameBytes }}-{{ end }}--------- {{$.Selector}} {{$.Host}} {{$.Port}} -i {{$.Selector}} {{$.Host}} {{$.Port}} -i{{.ShortMessage}} {{$.Selector}} {{$.Host}} {{$.Port}} -i {{$.Selector}} {{$.Host}} {{$.Port}} -{{ with .RestOfMessage -}} -{{ if ne . "" -}} -i{{.}} {{$.Selector}} {{$.Host}} {{$.Port}} -i {{$.Selector}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ end -}} -1🗂️ Repository {{combine $.Selector ".."}} {{$.Host}} {{$.Port}} -1📄 Files {{$.Selector}}/tree {{$.Host}} {{$.Port}} -{{ if ne .Parents nil -}} -0🔩 Full Diff {{join $.Selector "../../diff" .ParentHash .Hash}} {{$.Host}} {{$.Port}} -{{ else -}} -0🔩 Full Diff {{join $.Selector ".." ".." "diff" "4b825dc642cb6eb9a060e54bf8d69288fbee4904" .Hash}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ range .Parents -}} -1👤 Parent {{slice . 0 8}} {{combine $.Selector .}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ range .Repo.Refs $.Ctx -}} -{{ if .IsTag -}} -{{ if eq $.Params.ref .Hash -}} -1🏷️ {{.ShortName}} ../{{.Hash}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ end -}} -{{ end -}} -i {{$.Selector}} {{$.Host}} {{$.Port}} -iAuthored by {{.AuthorName}}<{{.AuthorEmail}}> on {{.AuthorDate.Format "Mon Jan _2 15:04:05 MST 2006"}} {{$.Selector}} {{$.Host}} {{$.Port}} -iCommitted by {{.CommitterName}}<{{.CommitterEmail}}> on {{.CommitDate.Format "Mon Jan _2 15:04:05 MST 2006"}} {{$.Selector}} {{$.Host}} {{$.Port}} -i {{$.Selector}} {{$.Host}} {{$.Port}} -{{ if eq .Parents nil -}} -{{.Repo.Diffstat $.Ctx "4b825dc642cb6eb9a060e54bf8d69288fbee4904" .Hash | rawtext $.Selector $.Host $.Port }} -{{ else -}} -{{ with index .Parents 0 -}} -{{$.Repo.Diffstat $.Ctx . $.Params.ref | rawtext $.Selector $.Host $.Port }} -{{ end -}} -{{ end -}} -{{ end -}} -. diff --git a/templates/ref.gph b/templates/ref.gph new file mode 100644 index 0000000..c7de102 --- /dev/null +++ b/templates/ref.gph @@ -0,0 +1,42 @@ +{{ with .Repo.Commit .Ctx .Params.ref -}} +i{{.Repo.Name}} {{slice .Hash 0 8}} {{$.Selector}} {{$.Host}} {{$.Port}} +i{{ range .Repo.NameBytes }}-{{ end }}--------- {{$.Selector}} {{$.Host}} {{$.Port}} +i {{$.Selector}} {{$.Host}} {{$.Port}} +i{{.ShortMessage}} {{$.Selector}} {{$.Host}} {{$.Port}} +i {{$.Selector}} {{$.Host}} {{$.Port}} +{{ with .RestOfMessage -}} +{{ if ne . "" -}} +i{{.}} {{$.Selector}} {{$.Host}} {{$.Port}} +i {{$.Selector}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ end -}} +1🗂️ Repository {{combine $.Selector ".."}} {{$.Host}} {{$.Port}} +1📄 Files {{$.Selector}}/tree {{$.Host}} {{$.Port}} +{{ if ne .Parents nil -}} +0🔩 Full Diff {{join $.Selector "../../diff" .ParentHash .Hash}} {{$.Host}} {{$.Port}} +{{ else -}} +0🔩 Full Diff {{join $.Selector ".." ".." "diff" "4b825dc642cb6eb9a060e54bf8d69288fbee4904" .Hash}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ range .Parents -}} +1👤 Parent {{slice . 0 8}} {{combine $.Selector .}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ range .Repo.Refs $.Ctx -}} +{{ if .IsTag -}} +{{ if eq $.Params.ref .Hash -}} +1🏷️ {{.ShortName}} ../{{.Hash}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ end -}} +{{ end -}} +i {{$.Selector}} {{$.Host}} {{$.Port}} +iAuthored by {{.AuthorName}}<{{.AuthorEmail}}> on {{.AuthorDate.Format "Mon Jan _2 15:04:05 MST 2006"}} {{$.Selector}} {{$.Host}} {{$.Port}} +iCommitted by {{.CommitterName}}<{{.CommitterEmail}}> on {{.CommitDate.Format "Mon Jan _2 15:04:05 MST 2006"}} {{$.Selector}} {{$.Host}} {{$.Port}} +i {{$.Selector}} {{$.Host}} {{$.Port}} +{{ if eq .Parents nil -}} +{{.Repo.Diffstat $.Ctx "4b825dc642cb6eb9a060e54bf8d69288fbee4904" .Hash | rawtext $.Selector $.Host $.Port }} +{{ else -}} +{{ with index .Parents 0 -}} +{{$.Repo.Diffstat $.Ctx . $.Params.ref | rawtext $.Selector $.Host $.Port }} +{{ end -}} +{{ end -}} +{{ end -}} +. diff --git a/templates/repo_home.gophermap b/templates/repo_home.gophermap deleted file mode 100644 index 2ab17c2..0000000 --- a/templates/repo_home.gophermap +++ /dev/null @@ -1,24 +0,0 @@ -i{{.Repo.Name}} {{.Selector}} {{.Host}} {{.Port}} -i{{ range .Repo.NameBytes }}-{{ end }} {{.Selector}} {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -i{{.Repo.Description}} {{.Selector}} {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -1⌥ Branches {{.Selector}}/branches {{.Host}} {{.Port}} -1🏷️ Tags {{.Selector}}/tags {{.Host}} {{.Port}} -1📄 Files {{.Selector}}/refs/HEAD/tree {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -iLatest Commits: {{.Selector}} {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -{{ with .Repo.Commits .Ctx "HEAD" 5 -}} -{{ range . -}} -1{{.ShortMessage}} {{$.Selector}}/refs/{{.Hash}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ if len . | eq 0 -}} -i(no commits to show) {{$.Selector}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ end -}} -i {{.Selector}} {{.Host}} {{.Port}} -{{ with .Repo.Readme .Ctx "HEAD" -}} -{{ .GopherEscapedContents $.Selector $.Host $.Port }} -{{ end -}} -. diff --git a/templates/repo_home.gph b/templates/repo_home.gph new file mode 100644 index 0000000..2ab17c2 --- /dev/null +++ b/templates/repo_home.gph @@ -0,0 +1,24 @@ +i{{.Repo.Name}} {{.Selector}} {{.Host}} {{.Port}} +i{{ range .Repo.NameBytes }}-{{ end }} {{.Selector}} {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +i{{.Repo.Description}} {{.Selector}} {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +1⌥ Branches {{.Selector}}/branches {{.Host}} {{.Port}} +1🏷️ Tags {{.Selector}}/tags {{.Host}} {{.Port}} +1📄 Files {{.Selector}}/refs/HEAD/tree {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +iLatest Commits: {{.Selector}} {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +{{ with .Repo.Commits .Ctx "HEAD" 5 -}} +{{ range . -}} +1{{.ShortMessage}} {{$.Selector}}/refs/{{.Hash}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ if len . | eq 0 -}} +i(no commits to show) {{$.Selector}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ end -}} +i {{.Selector}} {{.Host}} {{.Port}} +{{ with .Repo.Readme .Ctx "HEAD" -}} +{{ .GopherEscapedContents $.Selector $.Host $.Port }} +{{ end -}} +. diff --git a/templates/repo_root.gophermap b/templates/repo_root.gophermap deleted file mode 100644 index 35592a4..0000000 --- a/templates/repo_root.gophermap +++ /dev/null @@ -1,7 +0,0 @@ -iRepositories {{.Selector}} {{.Host}} {{.Port}} -i------------ {{.Selector}} {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -{{ range .Repos -}} -1{{.}} {{$.Selector}}/{{.}} {{$.Host}} {{$.Port}} -{{ end -}} -. diff --git a/templates/repo_root.gph b/templates/repo_root.gph new file mode 100644 index 0000000..35592a4 --- /dev/null +++ b/templates/repo_root.gph @@ -0,0 +1,7 @@ +iRepositories {{.Selector}} {{.Host}} {{.Port}} +i------------ {{.Selector}} {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +{{ range .Repos -}} +1{{.}} {{$.Selector}}/{{.}} {{$.Host}} {{$.Port}} +{{ end -}} +. diff --git a/templates/tag_list.gophermap b/templates/tag_list.gophermap deleted file mode 100644 index ea5ee84..0000000 --- a/templates/tag_list.gophermap +++ /dev/null @@ -1,9 +0,0 @@ -i{{.Repo.Name}} Tags 🏷️ {{.Selector}} {{.Host}} {{.Port}} -i{{ range .Repo.NameBytes }}-{{ end }}-------- {{.Selector}} {{.Host}} {{.Port}} -i {{.Selector}} {{.Host}} {{.Port}} -{{ range .Repo.Refs .Ctx -}} -{{ if .IsTag -}} -1{{.ShortName}} {{combine $.Selector "refs/" .Hash}} {{$.Host}} {{$.Port}} -{{ end -}} -{{ end -}} -. diff --git a/templates/tag_list.gph b/templates/tag_list.gph new file mode 100644 index 0000000..ea5ee84 --- /dev/null +++ b/templates/tag_list.gph @@ -0,0 +1,9 @@ +i{{.Repo.Name}} Tags 🏷️ {{.Selector}} {{.Host}} {{.Port}} +i{{ range .Repo.NameBytes }}-{{ end }}-------- {{.Selector}} {{.Host}} {{.Port}} +i {{.Selector}} {{.Host}} {{.Port}} +{{ range .Repo.Refs .Ctx -}} +{{ if .IsTag -}} +1{{.ShortName}} {{combine $.Selector "refs/" .Hash}} {{$.Host}} {{$.Port}} +{{ end -}} +{{ end -}} +. diff --git a/templates/tree.gophermap b/templates/tree.gophermap deleted file mode 100644 index ed9c1e7..0000000 --- a/templates/tree.gophermap +++ /dev/null @@ -1,9 +0,0 @@ -{{ with .Repo.Commit .Ctx .Params.ref -}} -i{{slice .Hash 0 8}}:{{ if ne $.Params.path "" }}{{$.Params.path}}{{ else }}/{{ end }} {{$.Selector}} {{$.Host}} {{$.Port}} -i {{$.Selector}} {{$.Host}} {{$.Port}} -{{ end -}} -1{{ if ne .Params.path "" }}../{{ else }}Commit{{ end }} {{join $.Selector ".."}} {{$.Host}} {{$.Port}} -{{ range .Repo.Tree .Ctx $.Params.ref $.Params.path -}} -{{ if eq .Type "blob" }}0📄 {{ else }}1📂 {{ end }}{{.Path}} {{join $.Selector .Path}} {{$.Host}} {{$.Port}} -{{ end -}} -. diff --git a/templates/tree.gph b/templates/tree.gph new file mode 100644 index 0000000..ed9c1e7 --- /dev/null +++ b/templates/tree.gph @@ -0,0 +1,9 @@ +{{ with .Repo.Commit .Ctx .Params.ref -}} +i{{slice .Hash 0 8}}:{{ if ne $.Params.path "" }}{{$.Params.path}}{{ else }}/{{ end }} {{$.Selector}} {{$.Host}} {{$.Port}} +i {{$.Selector}} {{$.Host}} {{$.Port}} +{{ end -}} +1{{ if ne .Params.path "" }}../{{ else }}Commit{{ end }} {{join $.Selector ".."}} {{$.Host}} {{$.Port}} +{{ range .Repo.Tree .Ctx $.Params.ref $.Params.path -}} +{{ if eq .Type "blob" }}0📄 {{ else }}1📂 {{ end }}{{.Path}} {{join $.Selector .Path}} {{$.Host}} {{$.Port}} +{{ end -}} +. -- cgit v1.2.3