mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Add go-source directive to repo pages
This makes Gogs repos work with godoc.org: https://github.com/golang/gddo/wiki/Source-Code-Links
This commit is contained in:
		| @@ -347,6 +347,8 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { | |||||||
|  |  | ||||||
| 		if ctx.Query("go-get") == "1" { | 		if ctx.Query("go-get") == "1" { | ||||||
| 			ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, u.Name, repo.Name) | 			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 { | 		if ctx.IsSigned { | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ | |||||||
| 	<meta name="_suburl" content="{{AppSubUrl}}" /> | 	<meta name="_suburl" content="{{AppSubUrl}}" /> | ||||||
| 	{{if .GoGetImport}} | 	{{if .GoGetImport}} | ||||||
| 	<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}"> | 	<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}"> | ||||||
|  | 	<meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}"> | ||||||
| 	{{end}} | 	{{end}} | ||||||
|  |  | ||||||
| 	<link rel="shortcut icon" href="{{AppSubUrl}}/img/favicon.png" /> | 	<link rel="shortcut icon" href="{{AppSubUrl}}/img/favicon.png" /> | ||||||
|   | |||||||
| @@ -8,7 +8,10 @@ | |||||||
| 		<meta name="keywords" content="go, git, self-hosted, gogs"> | 		<meta name="keywords" content="go, git, self-hosted, gogs"> | ||||||
| 		<meta name="referrer" content="no-referrer" /> | 		<meta name="referrer" content="no-referrer" /> | ||||||
| 		<meta name="_csrf" content="{{.CsrfToken}}" /> | 		<meta name="_csrf" content="{{.CsrfToken}}" /> | ||||||
| 		{{if .GoGetImport}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}} | 		{{if .GoGetImport}} | ||||||
|  | 		<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}"> | ||||||
|  | 		<meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}"> | ||||||
|  | 		{{end}} | ||||||
|  |  | ||||||
| 		<link rel="shortcut icon" href="{{AppSubUrl}}/img/favicon.png" /> | 		<link rel="shortcut icon" href="{{AppSubUrl}}/img/favicon.png" /> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user