From 0958fe5a4eddeca1c005f5022c9aaeb61b097a00 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 11 Feb 2017 00:03:10 -0500 Subject: [PATCH] Improve Open Graph Meta tags (#3664) --- models/user.go | 4 ++++ modules/context/repo.go | 2 +- routers/repo/release.go | 2 +- templates/base/head.tmpl | 26 ++++++++++++++++++++------ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/models/user.go b/models/user.go index 6a7365ab7..91aff928f 100644 --- a/models/user.go +++ b/models/user.go @@ -197,6 +197,10 @@ func (u *User) HomeLink() string { 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. func (u *User) GenerateEmailActivateCode(email string) string { code := base.CreateTimeLimitCode( diff --git a/modules/context/repo.go b/modules/context/repo.go index 8320afab1..924898aa8 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -242,7 +242,7 @@ func RepoAssignment(args ...bool) macaron.Handler { tags, err := ctx.Repo.GitRepo.GetTags() 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 } ctx.Data["Tags"] = tags diff --git a/routers/repo/release.go b/routers/repo/release.go index b233116a1..f74fc7b6c 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -55,7 +55,7 @@ func Releases(ctx *context.Context) { rawTags, err := ctx.Repo.GitRepo.GetTags() 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 } diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 3014b6bab..e01801146 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -4,7 +4,7 @@ - + @@ -15,11 +15,25 @@ {{end}} - - - - - + {{if .PageIsUserProfile}} + + + + + + {{else if .Repository}} + + + + + {{else}} + + + + + + + {{end}}