diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-18 20:00:19 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-18 20:00:19 +0530 |
commit | d0d636aa89bf194185abf01e05b190386d0e8b23 (patch) | |
tree | 53f44e98b081e8fbd6823f9e7329fa3f7185ad82 /routes/routes.go | |
parent | 2e3c3103c48c748ccc8fa6b3607d51f112a9400f (diff) | |
download | legit-d0d636aa89bf194185abf01e05b190386d0e8b23.tar.gz legit-d0d636aa89bf194185abf01e05b190386d0e8b23.tar.bz2 legit-d0d636aa89bf194185abf01e05b190386d0e8b23.zip |
all: go-import, clone url
Diffstat (limited to 'routes/routes.go')
-rw-r--r-- | routes/routes.go | 12 |
1 files changed, 12 insertions, 0 deletions
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(`<meta name="go-import" content="%s git %s">`, + 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) |