From 6006194c072dba9f65aa08c6e3be06ea8ead8910 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Tue, 25 Mar 2025 21:20:13 +0100 Subject: feat: Add ref page Now there is page more tailored to a single ref. --- templates/commit.qtpl | 2 +- templates/commit.qtpl.go | 4 +- templates/gititemref.qtpl | 34 +++++++++ templates/gititemref.qtpl.go | 171 +++++++++++++++++++++++++++++++++++++++++++ templates/tags.qtpl | 2 +- templates/tags.qtpl.go | 4 +- 6 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 templates/gititemref.qtpl create mode 100644 templates/gititemref.qtpl.go (limited to 'templates') diff --git a/templates/commit.qtpl b/templates/commit.qtpl index b58b238..4fe92e9 100644 --- a/templates/commit.qtpl +++ b/templates/commit.qtpl @@ -13,7 +13,7 @@ {% if r.Name().IsBranch() %} {%s r.Name().Short() %} {% else %} - {%s r.Name().Short() %} + {%s r.Name().Short() %} {% endif %} {% endfor %} {%endif%} diff --git a/templates/commit.qtpl.go b/templates/commit.qtpl.go index 5017880..0aefbb8 100644 --- a/templates/commit.qtpl.go +++ b/templates/commit.qtpl.go @@ -106,9 +106,9 @@ func StreamCommit(qw422016 *qt422016.Writer, name string, c *git.CommitReference //line templates/commit.qtpl:16 qw422016.E().S(name) //line templates/commit.qtpl:16 - qw422016.N().S(`/commit/`) + qw422016.N().S(`/ref/`) //line templates/commit.qtpl:16 - qw422016.E().S(c.Commit().Hash.String()) + qw422016.E().S(r.Name().Short()) //line templates/commit.qtpl:16 qw422016.N().S(`/">`) //line templates/commit.qtpl:16 diff --git a/templates/gititemref.qtpl b/templates/gititemref.qtpl new file mode 100644 index 0000000..9e1c776 --- /dev/null +++ b/templates/gititemref.qtpl @@ -0,0 +1,34 @@ +{% import "git.gabrielgio.me/cerrado/pkg/git" %} +{% import "git.gabrielgio.me/cerrado/pkg/humanize" %} +{% import "github.com/go-git/go-git/v5/plumbing/object" %} + +{% code +type GitItemRefPage struct { + Reference *git.TagReference + Commit *object.Commit +} +%} + +{% func (g *GitItemRefPage) Nav(name, ref string) %}{%= GitItemNav(name, ref, Refs) %}{% endfunc %} + +{% func (g *GitItemRefPage) GitContent(name, ref string) %} +
+ +
+{% endfunc %} diff --git a/templates/gititemref.qtpl.go b/templates/gititemref.qtpl.go new file mode 100644 index 0000000..53ca1ec --- /dev/null +++ b/templates/gititemref.qtpl.go @@ -0,0 +1,171 @@ +// Code generated by qtc from "gititemref.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +//line templates/gititemref.qtpl:1 +package templates + +//line templates/gititemref.qtpl:1 +import "git.gabrielgio.me/cerrado/pkg/git" + +//line templates/gititemref.qtpl:2 +import "git.gabrielgio.me/cerrado/pkg/humanize" + +//line templates/gititemref.qtpl:3 +import "github.com/go-git/go-git/v5/plumbing/object" + +//line templates/gititemref.qtpl:5 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line templates/gititemref.qtpl:5 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line templates/gititemref.qtpl:6 +type GitItemRefPage struct { + Reference *git.TagReference + Commit *object.Commit +} + +//line templates/gititemref.qtpl:12 +func (g *GitItemRefPage) StreamNav(qw422016 *qt422016.Writer, name, ref string) { +//line templates/gititemref.qtpl:12 + StreamGitItemNav(qw422016, name, ref, Refs) +//line templates/gititemref.qtpl:12 +} + +//line templates/gititemref.qtpl:12 +func (g *GitItemRefPage) WriteNav(qq422016 qtio422016.Writer, name, ref string) { +//line templates/gititemref.qtpl:12 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/gititemref.qtpl:12 + g.StreamNav(qw422016, name, ref) +//line templates/gititemref.qtpl:12 + qt422016.ReleaseWriter(qw422016) +//line templates/gititemref.qtpl:12 +} + +//line templates/gititemref.qtpl:12 +func (g *GitItemRefPage) Nav(name, ref string) string { +//line templates/gititemref.qtpl:12 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/gititemref.qtpl:12 + g.WriteNav(qb422016, name, ref) +//line templates/gititemref.qtpl:12 + qs422016 := string(qb422016.B) +//line templates/gititemref.qtpl:12 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/gititemref.qtpl:12 + return qs422016 +//line templates/gititemref.qtpl:12 +} + +//line templates/gititemref.qtpl:14 +func (g *GitItemRefPage) StreamGitContent(qw422016 *qt422016.Writer, name, ref string) { +//line templates/gititemref.qtpl:14 + qw422016.N().S(` +
+ +
+`) +//line templates/gititemref.qtpl:34 +} + +//line templates/gititemref.qtpl:34 +func (g *GitItemRefPage) WriteGitContent(qq422016 qtio422016.Writer, name, ref string) { +//line templates/gititemref.qtpl:34 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/gititemref.qtpl:34 + g.StreamGitContent(qw422016, name, ref) +//line templates/gititemref.qtpl:34 + qt422016.ReleaseWriter(qw422016) +//line templates/gititemref.qtpl:34 +} + +//line templates/gititemref.qtpl:34 +func (g *GitItemRefPage) GitContent(name, ref string) string { +//line templates/gititemref.qtpl:34 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/gititemref.qtpl:34 + g.WriteGitContent(qb422016, name, ref) +//line templates/gititemref.qtpl:34 + qs422016 := string(qb422016.B) +//line templates/gititemref.qtpl:34 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/gititemref.qtpl:34 + return qs422016 +//line templates/gititemref.qtpl:34 +} diff --git a/templates/tags.qtpl b/templates/tags.qtpl index 5cd617f..5b7c39b 100644 --- a/templates/tags.qtpl +++ b/templates/tags.qtpl @@ -7,7 +7,7 @@
diff --git a/templates/tags.qtpl.go b/templates/tags.qtpl.go index a89ddd3..5aedd78 100644 --- a/templates/tags.qtpl.go +++ b/templates/tags.qtpl.go @@ -46,9 +46,9 @@ func StreamListTags(qw422016 *qt422016.Writer, name string, tags []*git.TagRefer //line templates/tags.qtpl:10 qw422016.E().S(name) //line templates/tags.qtpl:10 - qw422016.N().S(`/commit/`) + qw422016.N().S(`/ref/`) //line templates/tags.qtpl:10 - qw422016.E().S(t.HashString()) + qw422016.E().S(t.ShortName()) //line templates/tags.qtpl:10 qw422016.N().S(`">`) //line templates/tags.qtpl:10 -- cgit v1.2.3