summaryrefslogtreecommitdiffstats
path: root/routes/routes.go
diff options
context:
space:
mode:
authorLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-18 20:00:19 +0530
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-18 20:00:19 +0530
commitd0d636aa89bf194185abf01e05b190386d0e8b23 (patch)
tree53f44e98b081e8fbd6823f9e7329fa3f7185ad82 /routes/routes.go
parent2e3c3103c48c748ccc8fa6b3607d51f112a9400f (diff)
downloadlegit-d0d636aa89bf194185abf01e05b190386d0e8b23.tar.gz
legit-d0d636aa89bf194185abf01e05b190386d0e8b23.tar.bz2
legit-d0d636aa89bf194185abf01e05b190386d0e8b23.zip
all: go-import, clone url
Diffstat (limited to '')
-rw-r--r--routes/routes.go12
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)