From 4323a89c0354e4f25dbffc4b77c1e3f9ba68ba24 Mon Sep 17 00:00:00 2001 From: Nathan Zadoks Date: Fri, 30 Oct 2015 13:52:36 +0100 Subject: [PATCH] Add go-source directive to repo pages This makes Gogs repos work with godoc.org: https://github.com/golang/gddo/wiki/Source-Code-Links --- modules/middleware/repo.go | 2 ++ templates/base/head.tmpl | 1 + templates/ng/base/head.tmpl | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index ba7cbac82..6424018a2 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -347,6 +347,8 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { if ctx.Query("go-get") == "1" { ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, u.Name, repo.Name) + ctx.Data["GoDocDirectory"] = fmt.Sprintf("%s%s/%s/src/master{/dir}", setting.AppUrl, repo.Owner.LowerName, repo.LowerName) + ctx.Data["GoDocFile"] = fmt.Sprintf("%s%s/%s/src/master{/dir}/{file}#L{line}", setting.AppUrl, repo.Owner.LowerName, repo.LowerName) } if ctx.IsSigned { diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 323079f7c..caece3244 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -11,6 +11,7 @@ {{if .GoGetImport}} + {{end}} diff --git a/templates/ng/base/head.tmpl b/templates/ng/base/head.tmpl index 2a13036ec..dbf801c66 100644 --- a/templates/ng/base/head.tmpl +++ b/templates/ng/base/head.tmpl @@ -8,7 +8,10 @@ - {{if .GoGetImport}}{{end}} + {{if .GoGetImport}} + + + {{end}}