From d0d636aa89bf194185abf01e05b190386d0e8b23 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Sun, 18 Dec 2022 20:00:19 +0530 Subject: all: go-import, clone url --- routes/routes.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'routes/routes.go') diff --git a/routes/routes.go b/routes/routes.go index 12225ef..bb0d247 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -1,6 +1,7 @@ package routes import ( + "fmt" "html/template" "log" "net/http" @@ -112,6 +113,15 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) { return } + cloneURL := fmt.Sprintf("https://%s/%s", d.c.Server.FQDN, name) + + if d.c.Misc.GoImport.PrettyURL == "" { + d.c.Misc.GoImport.PrettyURL = cloneURL + } + + goImport := fmt.Sprintf(``, + d.c.Misc.GoImport.PrettyURL, cloneURL) + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) @@ -125,6 +135,8 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) { data["readme"] = readmeContent data["commits"] = commits data["desc"] = getDescription(path) + data["clone"] = cloneURL + data["goimport"] = template.HTML(goImport) if err := t.ExecuteTemplate(w, "repo", data); err != nil { log.Println(err) -- cgit