From d41a05e83ecb44f323e13a64164d8d31d7c0a383 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 31 Aug 2023 23:14:12 +0200 Subject: [PATCH 1/2] Move Open Graph meta tags into a separate template --- templates/base/head.tmpl | 37 +----------------------------- templates/base/head_opengraph.tmpl | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 36 deletions(-) create mode 100644 templates/base/head_opengraph.tmpl diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 8eebaebd704e3..c3645209cd604 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -25,42 +25,7 @@ .ui.secondary.menu .dropdown.item > .menu { margin-top: 0; } -{{if .PageIsUserProfile}} - - - - - {{if .ContextUser.Description}} - - {{end}} -{{else if .Repository}} - {{if .Issue}} - - - {{if .Issue.Content}} - - {{end}} - {{else}} - - - {{if .Repository.Description}} - - {{end}} - {{end}} - - {{if (.Repository.AvatarLink ctx)}} - - {{else}} - - {{end}} -{{else}} - - - - - -{{end}} - + {{template "base/head_opengraph" .}} {{template "base/head_style" .}} {{template "custom/header" .}} diff --git a/templates/base/head_opengraph.tmpl b/templates/base/head_opengraph.tmpl new file mode 100644 index 0000000000000..3eb584bb8df5d --- /dev/null +++ b/templates/base/head_opengraph.tmpl @@ -0,0 +1,36 @@ +{{if .PageIsUserProfile}} + + + + + {{if .ContextUser.Description}} + + {{end}} +{{else if .Repository}} + {{if .Issue}} + + + {{if .Issue.Content}} + + {{end}} + {{else}} + + + {{if .Repository.Description}} + + {{end}} + {{end}} + + {{if (.Repository.AvatarLink ctx)}} + + {{else}} + + {{end}} +{{else}} + + + + + +{{end}} + From 0f3c37bfeca965468a4f4dc51a150ab7c5007d20 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 1 Sep 2023 00:27:59 +0200 Subject: [PATCH 2/2] Customize Open Graph metadata for commit and file URLs --- templates/base/head_opengraph.tmpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/base/head_opengraph.tmpl b/templates/base/head_opengraph.tmpl index 3eb584bb8df5d..fc3958b6b6d55 100644 --- a/templates/base/head_opengraph.tmpl +++ b/templates/base/head_opengraph.tmpl @@ -13,6 +13,12 @@ {{if .Issue.Content}} {{end}} + {{else if or .PageIsDiff .IsViewFile}} + + + {{if and .PageIsDiff (IsMultilineCommitMessage .Commit.Message)}} + + {{end}} {{else}}