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. --- pkg/handler/git/handler.go | 22 ++++++++++++++++++++++ pkg/handler/router.go | 1 + 2 files changed, 23 insertions(+) (limited to 'pkg/handler') diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go index 034d5c2..a9be54c 100644 --- a/pkg/handler/git/handler.go +++ b/pkg/handler/git/handler.go @@ -350,6 +350,28 @@ func (g *GitHandler) Log(w http.ResponseWriter, r *http.Request) error { return nil } +func (g *GitHandler) Ref(w http.ResponseWriter, r *http.Request) error { + ext.SetHTML(w) + name := r.PathValue("name") + ref := r.PathValue("ref") + + commit, tag, err := g.gitService.GetTag(ref, name) + if err != nil { + return err + } + + gitList := &templates.GitItemPage{ + Name: name, + Ref: ref, + GitItemBase: &templates.GitItemRefPage{ + Commit: commit, + Reference: tag, + }, + } + templates.WritePageTemplate(w, gitList, r.Context()) + return nil +} + func (g *GitHandler) Commit(w http.ResponseWriter, r *http.Request) error { ext.SetHTML(w) name := r.PathValue("name") diff --git a/pkg/handler/router.go b/pkg/handler/router.go index 8d27b74..e461922 100644 --- a/pkg/handler/router.go +++ b/pkg/handler/router.go @@ -52,6 +52,7 @@ func MountHandler( mux.HandleFunc("/{name}/blob/{ref}/{rest...}", gitHandler.Blob) mux.HandleFunc("/{name}/log/{ref}/", gitHandler.Log) mux.HandleFunc("/{name}/commit/{ref}/", gitHandler.Commit) + mux.HandleFunc("/{name}/ref/{ref}/", gitHandler.Ref) mux.HandleFunc("/{name}/archive/{file}", gitHandler.Archive) mux.HandleFunc("/about", aboutHandler.About) mux.HandleFunc("/", gitHandler.List) -- cgit v1.2.3