From 90fa2795ad177b9add2fe46382576993e96ece4b Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 16 Sep 2023 20:43:19 -0600 Subject: Initial commit Gemini repository browsing --- templates/branch_list.gmi | 7 +++++++ templates/diff.gmi | 1 + templates/diffstat.gmi | 1 + templates/ref.gmi | 49 +++++++++++++++++++++++++++++++++++++++++++++++ templates/repo_home.gmi | 28 +++++++++++++++++++++++++++ templates/repo_root.gmi | 5 +++++ templates/tag_list.gmi | 7 +++++++ templates/tree.gmi | 6 ++++++ 8 files changed, 104 insertions(+) create mode 100644 templates/branch_list.gmi create mode 100644 templates/diff.gmi create mode 100644 templates/diffstat.gmi create mode 100644 templates/ref.gmi create mode 100644 templates/repo_home.gmi create mode 100644 templates/repo_root.gmi create mode 100644 templates/tag_list.gmi create mode 100644 templates/tree.gmi (limited to 'templates') diff --git a/templates/branch_list.gmi b/templates/branch_list.gmi new file mode 100644 index 0000000..2a2e99e --- /dev/null +++ b/templates/branch_list.gmi @@ -0,0 +1,7 @@ +# {{.Repo.Name}} Branches βŒ₯ + +{{ range .Repo.Refs .Ctx -}} +{{ if .IsBranch -}} +=> ./refs/{{.Hash}}/ {{.ShortName}} +{{ end -}} +{{ end -}} diff --git a/templates/diff.gmi b/templates/diff.gmi new file mode 100644 index 0000000..f2b795b --- /dev/null +++ b/templates/diff.gmi @@ -0,0 +1 @@ +{{.Repo.Diff .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diffstat.gmi b/templates/diffstat.gmi new file mode 100644 index 0000000..a51e06b --- /dev/null +++ b/templates/diffstat.gmi @@ -0,0 +1 @@ +{{.Repo.Diffstat .Ctx .Params.fromref .Params.toref}} diff --git a/templates/ref.gmi b/templates/ref.gmi new file mode 100644 index 0000000..e185ef1 --- /dev/null +++ b/templates/ref.gmi @@ -0,0 +1,49 @@ +# {{.Repo.Name}} {{slice .Params.ref 0 8}} + +{{ with .Repo.Commit .Ctx .Params.ref -}} +## {{.ShortMessage}} + +{{ with .RestOfMessage -}} +{{ if ne . "" -}} +{{.}} + +{{ end -}} +{{ end -}} +=> ../../ πŸ—‚οΈ Repository +=> ./tree/ πŸ“„ Files +{{ if ne .Parents nil -}} +=> ../../diff/{{.Hash}}^/{{.Hash}} πŸ”© Full Diff +{{ else -}} +=> ../../diff/4b825dc642cb6eb9a060e54bf8d69288fbee4904/{{.Hash}} πŸ”© Full Diff +{{ end -}} +{{ range .Parents -}} +=> ../{{.}}/ πŸ‘€ Parent {{slice . 0 8}} +{{ end -}} +{{ range .Repo.Refs $.Ctx -}} +{{ if .IsTag -}} +{{ if eq $.Params.ref .Hash -}} +=> ../{{.Hash}}/ 🏷️ {{.ShortName}} +{{ end -}} +{{ end -}} +{{ end }} + +### Authored +=> mailto:{{.AuthorEmail}} {{.AuthorName}} +{{.AuthorDate.Format "Mon Jan _2 15:04:05 MST 2006"}} + +### Committed +=> mailto:{{.CommitterEmail}} {{.CommitterName}} +{{.CommitDate.Format "Mon Jan _2 15:04:05 MST 2006"}} + +{{ if ne .Parents nil -}} +{{ with index .Parents 0 -}} +```diffstat +{{$.Repo.Diffstat $.Ctx . $.Params.ref}} +``` +{{ end -}} +{{ else -}} +```diffstat +{{$.Repo.Diffstat $.Ctx "4b825dc642cb6eb9a060e54bf8d69288fbee4904" $.Params.ref}} +``` +{{ end -}} +{{ end -}} diff --git a/templates/repo_home.gmi b/templates/repo_home.gmi new file mode 100644 index 0000000..a2af514 --- /dev/null +++ b/templates/repo_home.gmi @@ -0,0 +1,28 @@ +# {{.Repo.Name}} + +{{.Repo.Description}} + +=> ./branches βŒ₯ Branches +=> ./tags 🏷️Tags +=> ./refs/HEAD/tree/ πŸ“„ Files + +## Latest Commits + +{{ with .Repo.Commits .Ctx "HEAD" 5 -}} +{{ range . -}} +=> ./refs/{{.Hash}}/ {{.ShortMessage}} +{{ end -}} +{{ if len . | eq 0 -}} +(no commits to show) +{{ end -}} +{{ end }} + +{{ with .Repo.Readme .Ctx "HEAD" -}} +{{ if len .RawContents | ne 0 -}} +## {{.Filename}} + +```{{.Filename}} contents +{{.EscapedContents}} +``` +{{ end -}} +{{ end }} diff --git a/templates/repo_root.gmi b/templates/repo_root.gmi new file mode 100644 index 0000000..68b230b --- /dev/null +++ b/templates/repo_root.gmi @@ -0,0 +1,5 @@ +# Repositories + +{{ range . -}} +=> ./{{.}}/ {{.}} +{{ end }} diff --git a/templates/tag_list.gmi b/templates/tag_list.gmi new file mode 100644 index 0000000..2fc0fe2 --- /dev/null +++ b/templates/tag_list.gmi @@ -0,0 +1,7 @@ +# {{.Repo.Name}} Tags 🏷️ + +{{ range .Repo.Refs .Ctx -}} +{{ if .IsTag -}} +=> ./refs/{{.Hash}}/ {{.ShortName}} +{{ end -}} +{{ end -}} diff --git a/templates/tree.gmi b/templates/tree.gmi new file mode 100644 index 0000000..35d0d02 --- /dev/null +++ b/templates/tree.gmi @@ -0,0 +1,6 @@ +# {{.Params.ref}}:{{ if ne .Params.path "" }}{{.Params.path}}{{ else }}/{{ end }} + +=> ../ {{ if ne .Params.path "" }}../{{ else }}Commit{{ end }} +{{ range .Repo.Tree .Ctx .Params.ref .Params.path -}} +=> ./{{.Path}}{{if eq .Type "tree"}}/{{end}} {{if eq .Type "blob"}}πŸ“„{{else if eq .Type "tree"}}πŸ“‚{{end}} {{.Path}} +{{ end -}} -- cgit v1.2.3