forked from kevadesu/forgejo
Merge pull request 'Rewrite OpenGraph Header' (#6447) from JakobDev/forgejo:ogrewrite into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6447 Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
b59522f0b3
9 changed files with 49 additions and 59 deletions
|
@ -61,6 +61,9 @@ func Home(ctx *context.Context) {
|
|||
|
||||
ctx.Data["PageIsHome"] = true
|
||||
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||
|
||||
ctx.Data["OpenGraphDescription"] = setting.UI.Meta.Description
|
||||
|
||||
ctx.HTML(http.StatusOK, tplHome)
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,12 @@ func Home(ctx *context.Context) {
|
|||
ctx.Data["PageIsUserProfile"] = true
|
||||
ctx.Data["Title"] = org.DisplayName()
|
||||
|
||||
ctx.Data["OpenGraphTitle"] = ctx.ContextUser.DisplayName()
|
||||
ctx.Data["OpenGraphType"] = "profile"
|
||||
ctx.Data["OpenGraphImageURL"] = ctx.ContextUser.AvatarLink(ctx)
|
||||
ctx.Data["OpenGraphURL"] = ctx.ContextUser.HTMLURL()
|
||||
ctx.Data["OpenGraphDescription"] = ctx.ContextUser.Description
|
||||
|
||||
var orderBy db.SearchOrderBy
|
||||
sortOrder := ctx.FormString("sort")
|
||||
if _, ok := repo_model.OrderByFlatMap[sortOrder]; !ok {
|
||||
|
|
|
@ -419,6 +419,10 @@ func Diff(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.Data["OpenGraphTitle"] = commit.Summary() + " · " + base.ShortSha(commitID)
|
||||
ctx.Data["OpenGraphURL"] = fmt.Sprintf("%s/commit/%s", ctx.Repo.Repository.HTMLURL(), commitID)
|
||||
_, ctx.Data["OpenGraphDescription"], _ = strings.Cut(commit.Message(), "\n")
|
||||
|
||||
ctx.HTML(http.StatusOK, tplCommitPage)
|
||||
}
|
||||
|
||||
|
|
|
@ -2070,6 +2070,9 @@ func ViewIssue(ctx *context.Context) {
|
|||
ctx.Data["RefEndName"] = git.RefName(issue.Ref).ShortName()
|
||||
ctx.Data["NewPinAllowed"] = pinAllowed
|
||||
ctx.Data["PinEnabled"] = setting.Repository.Issue.MaxPinned != 0
|
||||
ctx.Data["OpenGraphTitle"] = issue.Title
|
||||
ctx.Data["OpenGraphURL"] = issue.HTMLURL()
|
||||
ctx.Data["OpenGraphDescription"] = issue.Content
|
||||
ctx.Data["OpenGraphImageURL"] = issue.SummaryCardURL()
|
||||
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("repo.issues.summary_card_alt", issue.Title, issue.Repo.FullName())
|
||||
|
||||
|
|
|
@ -394,6 +394,10 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
|
|||
ctx.Data["FileName"] = blob.Name()
|
||||
ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)
|
||||
|
||||
ctx.Data["OpenGraphTitle"] = ctx.Data["Title"]
|
||||
ctx.Data["OpenGraphURL"] = fmt.Sprintf("%s%s", setting.AppURL, ctx.Data["Link"])
|
||||
ctx.Data["OpenGraphNoDescription"] = true
|
||||
|
||||
if entry.IsLink() {
|
||||
_, link, err := entry.FollowLinks()
|
||||
// Errors should be allowed, because this shouldn't
|
||||
|
|
|
@ -535,6 +535,9 @@ func Wiki(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Author"] = lastCommit.Author
|
||||
|
||||
ctx.Data["OpenGraphTitle"] = ctx.Data["Title"]
|
||||
ctx.Data["OpenGraphURL"] = fmt.Sprintf("%s%s", setting.AppURL, ctx.Data["Link"])
|
||||
|
||||
ctx.HTML(http.StatusOK, tplWikiView)
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,12 @@ func userProfile(ctx *context.Context) {
|
|||
ctx.Data["Title"] = ctx.ContextUser.DisplayName()
|
||||
ctx.Data["PageIsUserProfile"] = true
|
||||
|
||||
ctx.Data["OpenGraphTitle"] = ctx.ContextUser.DisplayName()
|
||||
ctx.Data["OpenGraphType"] = "profile"
|
||||
ctx.Data["OpenGraphImageURL"] = ctx.ContextUser.AvatarLink(ctx)
|
||||
ctx.Data["OpenGraphURL"] = ctx.ContextUser.HTMLURL()
|
||||
ctx.Data["OpenGraphDescription"] = ctx.ContextUser.Description
|
||||
|
||||
// prepare heatmap data
|
||||
if setting.Service.EnableUserHeatmap {
|
||||
data, err := activities_model.GetUserHeatmapDataByUser(ctx, ctx.ContextUser, ctx.Doer)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue