From ed05669e873a2aae11bb587102efdd6aa10148ff Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 28 Apr 2025 03:40:55 +0100 Subject: [PATCH] appview: add pages for tags and branches --- appview/pages/pages.go | 19 +- appview/pages/templates/repo/branches.html | 60 +++- appview/pages/templates/repo/index.html | 357 ++++++++++----------- appview/pages/templates/repo/tags.html | 56 +++- appview/state/repo.go | 71 +++- appview/state/repo_util.go | 34 +- appview/state/signer.go | 58 +++- knotserver/git/git.go | 30 +- knotserver/routes.go | 42 +-- types/repo.go | 2 + 10 files changed, 456 insertions(+), 273 deletions(-) diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 198d6ddf..4ac662c1 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -459,12 +459,13 @@ func (r RepoInfo) TabMetadata() map[string]any { } type RepoIndexParams struct { - LoggedInUser *auth.User - RepoInfo RepoInfo - Active string - TagMap map[string][]string - Tags []*types.TagReference - CommitsTrunc []*object.Commit + LoggedInUser *auth.User + RepoInfo RepoInfo + Active string + TagMap map[string][]string + CommitsTrunc []*object.Commit + TagsTrunc []*types.TagReference + BranchesTrunc []types.Branch types.RepoIndexResponse HTMLReadme template.HTML Raw bool @@ -505,7 +506,7 @@ type RepoLogParams struct { func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error { params.Active = "overview" - return p.execute("repo/log", w, params) + return p.executeRepo("repo/log", w, params) } type RepoCommitParams struct { @@ -561,20 +562,24 @@ func (p *Pages) RepoTree(w io.Writer, params RepoTreeParams) error { type RepoBranchesParams struct { LoggedInUser *auth.User RepoInfo RepoInfo + Active string types.RepoBranchesResponse } func (p *Pages) RepoBranches(w io.Writer, params RepoBranchesParams) error { + params.Active = "overview" return p.executeRepo("repo/branches", w, params) } type RepoTagsParams struct { LoggedInUser *auth.User RepoInfo RepoInfo + Active string types.RepoTagsResponse } func (p *Pages) RepoTags(w io.Writer, params RepoTagsParams) error { + params.Active = "overview" return p.executeRepo("repo/tags", w, params) } diff --git a/appview/pages/templates/repo/branches.html b/appview/pages/templates/repo/branches.html index a10b3193..bf03af60 100644 --- a/appview/pages/templates/repo/branches.html +++ b/appview/pages/templates/repo/branches.html @@ -1,16 +1,56 @@ {{ define "title" }} - branches | {{ .RepoInfo.FullName }} + branches · {{ .RepoInfo.FullName }} {{ end }} {{ define "repoContent" }} -

branches

-
- {{ range .Branches }} -
- {{ .Name }} - browse - log -
- {{ end }} +
+
+ Branches +
+ +
+ + + {{ range .Branches }} + + + + + + + {{ end }} + +
+ + + {{ .Name }} + + {{ if .IsDefault }} + + default + + {{ end }} + + + {{ if .Commit }} + {{ .Commit.Author.When | timeFmt }} + {{ end }} +
+
{{ end }} diff --git a/appview/pages/templates/repo/index.html b/appview/pages/templates/repo/index.html index 87982646..0e17f134 100644 --- a/appview/pages/templates/repo/index.html +++ b/appview/pages/templates/repo/index.html @@ -41,9 +41,9 @@