]> source.dussan.org Git - gitea.git/commitdiff
Improve OGP (#8637)
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>
Wed, 23 Oct 2019 17:54:13 +0000 (12:54 -0500)
committerzeripath <art27@cantab.net>
Wed, 23 Oct 2019 17:54:13 +0000 (18:54 +0100)
* Improve OGP
* Ensure Repo is loaded when checking Pull info

Signed-off-by: jolheiser <john.olheiser@gmail.com>
routers/repo/pull.go
templates/base/head.tmpl

index 4001e3a4f80e7bc705c11607a99f6b10ceeeba0a..4b73571e663522c45113fe0462a5c181aae4edf4 100644 (file)
@@ -242,6 +242,10 @@ func checkPullInfo(ctx *context.Context) *models.Issue {
                ctx.ServerError("LoadPoster", err)
                return nil
        }
+       if err := issue.LoadRepo(); err != nil {
+               ctx.ServerError("LoadRepo", err)
+               return nil
+       }
        ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
        ctx.Data["Issue"] = issue
 
index ae2b6b954d601fb58a7706bbc0c8f57f7746309d..c0686ca93e08581aaa323f9eabde0f97c9880e11 100644 (file)
        <meta property="og:type" content="profile" />
        <meta property="og:image" content="{{.Owner.AvatarLink}}" />
        <meta property="og:url" content="{{.Owner.HTMLURL}}" />
-       <meta property="og:site_name" content="{{AppName}}" />
+       {{if .Owner.Description}}
+               <meta property="og:description" content="{{.Owner.Description}}">
+       {{end}}
 {{else if .Repository}}
-       <meta property="og:title" content="{{.Repository.Name}}" />
+       {{if .Issue}}
+               <meta property="og:title" content="{{.Issue.Title}}" />
+               <meta property="og:url" content="{{.Issue.HTMLURL}}" />
+               {{if .Issue.Content}}
+                       <meta property="og:description" content="{{.Issue.Content}}" />
+               {{end}}
+       {{else}}
+               <meta property="og:title" content="{{.Repository.Name}}" />
+               <meta property="og:url" content="{{.Repository.HTMLURL}}" />
+               {{if .Repository.Description}}
+                       <meta property="og:description" content="{{.Repository.Description}}" />
+               {{end}}
+       {{end}}
        <meta property="og:type" content="object" />
        <meta property="og:image" content="{{.Repository.Owner.AvatarLink}}" />
-       <meta property="og:url" content="{{.Repository.HTMLURL}}" />
-       {{if .Repository.Description}}
-       <meta property="og:description" content="{{.Repository.Description}}" />
-       {{end}}
-       <meta property="og:site_name" content="{{AppName}}" />
 {{else}}
        <meta property="og:title" content="{{AppName}}">
        <meta property="og:type" content="website" />
        <meta property="og:url" content="{{AppUrl}}" />
        <meta property="og:description" content="{{MetaDescription}}">
 {{end}}
+<meta property="og:site_name" content="{{AppName}}" />
 {{if .IsSigned }}
        {{ if ne .SignedUser.Theme "gitea" }}
                <link rel="stylesheet" href="{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css">