Browse Source

Improve Open Graph Meta tags (#3664)

pull/3809/merge
Unknwon 8 years ago
parent
commit
0958fe5a4e
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 4
      models/user.go
  2. 2
      modules/context/repo.go
  3. 2
      routers/repo/release.go
  4. 24
      templates/base/head.tmpl

4
models/user.go

@ -197,6 +197,10 @@ func (u *User) HomeLink() string {
return setting.AppSubUrl + "/" + u.Name return setting.AppSubUrl + "/" + u.Name
} }
func (u *User) HTMLURL() string {
return setting.AppUrl + u.Name
}
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail. // GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
func (u *User) GenerateEmailActivateCode(email string) string { func (u *User) GenerateEmailActivateCode(email string) string {
code := base.CreateTimeLimitCode( code := base.CreateTimeLimitCode(

2
modules/context/repo.go

@ -242,7 +242,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
tags, err := ctx.Repo.GitRepo.GetTags() tags, err := ctx.Repo.GitRepo.GetTags()
if err != nil { if err != nil {
ctx.Handle(500, fmt.Sprintf("GetTags '%d'", ctx.Repo.Repository.RepoPath()), err) ctx.Handle(500, fmt.Sprintf("GetTags '%s'", ctx.Repo.Repository.RepoPath()), err)
return return
} }
ctx.Data["Tags"] = tags ctx.Data["Tags"] = tags

2
routers/repo/release.go

@ -55,7 +55,7 @@ func Releases(ctx *context.Context) {
rawTags, err := ctx.Repo.GitRepo.GetTags() rawTags, err := ctx.Repo.GitRepo.GetTags()
if err != nil { if err != nil {
ctx.Handle(500, fmt.Sprintf("GetTags '%d'", ctx.Repo.Repository.RepoPath()), err) ctx.Handle(500, fmt.Sprintf("GetTags '%s'", ctx.Repo.Repository.RepoPath()), err)
return return
} }

24
templates/base/head.tmpl

@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}Gogs - Go Git Service{{end}}" /> <meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}Gogs - Go Git Service{{end}}" />
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}Gogs (Go Git Service) is a painless self-hosted Git service written in Go{{end}}" /> <meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}Gogs (Go Git Service) is a painless self-hosted Git service{{end}}" />
<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}}" />
@ -15,11 +15,25 @@
{{end}} {{end}}
<!-- Open Graph Tags --> <!-- Open Graph Tags -->
{{if .PageIsUserProfile}}
<meta property="og:url" content="{{.Owner.HTMLURL}}" />
<meta property="og:type" content="profile" />
<meta property="og:title" content="{{.Owner.Name}}{{if .Owner.FullName}} ({{.Owner.FullName}}){{end}}">
<meta property="og:description" content="{{.Owner.Name}} has {{.Owner.NumFollowers}} followers and is following {{.Owner.NumFollowing}} people.">
<meta property="og:image" content="{{.Owner.AvatarLink}}" />
{{else if .Repository}}
<meta property="og:url" content="{{.Repository.HTMLURL}}" />
<meta property="og:type" content="object" />
<meta property="og:title" content="{{.Repository.FullName}}">
<meta property="og:description" content="{{.Repository.Description}}">
{{else}}
<meta property="og:url" content="{{AppUrl}}" />
<meta property="og:type" content="website" />
<meta property="og:title" content="{{AppName}}">
<meta property="og:description" content="Gogs (Go Git Service) is a painless self-hosted Git service.">
<meta property="og:image" content="{{AppUrl}}img/gogs-lg.png" /> <meta property="og:image" content="{{AppUrl}}img/gogs-lg.png" />
<meta property="og:image" content="{{AppUrl}}img/gogs-large-resize.png" /> <meta property="og:site_name" content="Gogs - Go Git Service">
<meta property="og:title" content="{{if .Title}}{{.Title}} - {{end}}{{AppName}}"> {{end}}
<meta property="og:site_name" content="{{AppName}}">
<meta property="og:description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}Gogs (Go Git Service) is a painless self-hosted Git service written in Go{{end}}">
<link rel="shortcut icon" href="{{AppSubUrl}}/img/favicon.png" /> <link rel="shortcut icon" href="{{AppSubUrl}}/img/favicon.png" />

Loading…
Cancel
Save