From 77725e02cc964f980465b158bb86c4061e6bfcca Mon Sep 17 00:00:00 2001 From: tjp Date: Tue, 14 Nov 2023 21:53:09 -0700 Subject: support for nex protocol --- templates/branch_list.nex.txt | 8 ++++++++ templates/diff.nex.txt | 1 + templates/diffstat.nex.txt | 1 + templates/ref.nex.txt | 48 +++++++++++++++++++++++++++++++++++++++++++ templates/repo_home.nex.txt | 28 +++++++++++++++++++++++++ templates/repo_root.nex.txt | 6 ++++++ templates/tag_list.nex.txt | 8 ++++++++ templates/tree.nex.txt | 8 ++++++++ 8 files changed, 108 insertions(+) create mode 100644 templates/branch_list.nex.txt create mode 100644 templates/diff.nex.txt create mode 100644 templates/diffstat.nex.txt create mode 100644 templates/ref.nex.txt create mode 100644 templates/repo_home.nex.txt create mode 100644 templates/repo_root.nex.txt create mode 100644 templates/tag_list.nex.txt create mode 100644 templates/tree.nex.txt (limited to 'templates') diff --git a/templates/branch_list.nex.txt b/templates/branch_list.nex.txt new file mode 100644 index 0000000..1e8abf8 --- /dev/null +++ b/templates/branch_list.nex.txt @@ -0,0 +1,8 @@ +{{.Repo.Name}} Branches βŒ₯ +{{range .Repo.NameBytes}}-{{end}}----------- + +{{ range .Repo.Refs .Ctx -}} +{{ if .IsBranch -}} +=> ../refs/{{.Hash}}/ {{.ShortName}} +{{ end -}} +{{ end -}} diff --git a/templates/diff.nex.txt b/templates/diff.nex.txt new file mode 100644 index 0000000..f2b795b --- /dev/null +++ b/templates/diff.nex.txt @@ -0,0 +1 @@ +{{.Repo.Diff .Ctx .Params.fromref .Params.toref}} diff --git a/templates/diffstat.nex.txt b/templates/diffstat.nex.txt new file mode 100644 index 0000000..a51e06b --- /dev/null +++ b/templates/diffstat.nex.txt @@ -0,0 +1 @@ +{{.Repo.Diffstat .Ctx .Params.fromref .Params.toref}} diff --git a/templates/ref.nex.txt b/templates/ref.nex.txt new file mode 100644 index 0000000..d76fa24 --- /dev/null +++ b/templates/ref.nex.txt @@ -0,0 +1,48 @@ +{{ with .Repo.Commit .Ctx .Params.ref -}} +{{.Repo.Name}} {{slice .Hash 0 8}} +{{ range .Repo.NameBytes }}-{{end}}--------- + +{{.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 +-------- +{{.AuthorName}}<{{.AuthorEmail}}> +{{.AuthorDate.Format "Mon Jan _2 15:04:05 MST 2006"}} + +Committed +--------- +{{.CommitterName}}<{{.CommitterEmail}}> +{{.CommitDate.Format "Mon Jan _2 15:04:05 MST 2006"}} + +{{ if eq .Parents nil -}} +{{$.Repo.Diffstat $.Ctx "4b825dc642cb6eb9a060e54bf8d69288fbee4904" $.Params.ref}} +{{ else -}} +{{ with index .Parents 0 -}} +{{$.Repo.Diffstat $.Ctx . $.Params.ref}} +{{ end -}} +{{ end -}} +{{ end -}} diff --git a/templates/repo_home.nex.txt b/templates/repo_home.nex.txt new file mode 100644 index 0000000..86cca62 --- /dev/null +++ b/templates/repo_home.nex.txt @@ -0,0 +1,28 @@ +{{.Repo.Name}} +{{ range .Repo.NameBytes }}={{end}} + +{{.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}} == + +{{.RawContents}} +{{ end -}} +{{ end }} diff --git a/templates/repo_root.nex.txt b/templates/repo_root.nex.txt new file mode 100644 index 0000000..d4ee0b0 --- /dev/null +++ b/templates/repo_root.nex.txt @@ -0,0 +1,6 @@ +Repositories +============ + +{{ range .Repos -}} +=> ./{{.}}/ +{{ end }} diff --git a/templates/tag_list.nex.txt b/templates/tag_list.nex.txt new file mode 100644 index 0000000..df087b2 --- /dev/null +++ b/templates/tag_list.nex.txt @@ -0,0 +1,8 @@ +{{.Repo.Name}} Tags 🏷️ +{{range .Repo.NameBytes}}-{{end}}------- + +{{ range .Repo.Refs .Ctx -}} +{{ if .IsTag -}} +=> ../refs/{{.Hash}}/ {{.ShortName}} +{{ end -}} +{{ end -}} diff --git a/templates/tree.nex.txt b/templates/tree.nex.txt new file mode 100644 index 0000000..676113b --- /dev/null +++ b/templates/tree.nex.txt @@ -0,0 +1,8 @@ +{{ with .Repo.Commit .Ctx .Params.ref -}} +{{slice .Hash 0 8}}:{{ if ne $.Params.path "" }}{{$.Params.path}}{{ else }}/{{ end }} + +{{ 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