From: Vladimir Panteleev Date: Sat, 13 Feb 2021 17:15:44 +0000 (+0000) Subject: De-hardcode OpenGraph social image (og:image URL) (#78) X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=d10bbddfb78e9ef186b555c43178bf9ffe136f4e;p=thirdparty%2Fbugzilla.git De-hardcode OpenGraph social image (og:image URL) (#78) Add a configuration panel for the OpenGraph extension where users can configure a desired image instead. If none is configured (default), don't emit an og:image tag. --- diff --git a/extensions/OpenGraph/Extension.pm b/extensions/OpenGraph/Extension.pm index 18ee2c22f..eee0ffc5e 100644 --- a/extensions/OpenGraph/Extension.pm +++ b/extensions/OpenGraph/Extension.pm @@ -17,4 +17,10 @@ use base qw(Bugzilla::Extension); our $VERSION = '1'; +sub config_add_panels { + my ($self, $args) = @_; + my $modules = $args->{panel_modules}; + $modules->{OpenGraph} = "Bugzilla::Extension::OpenGraph::Config"; +} + __PACKAGE__->NAME; diff --git a/extensions/OpenGraph/lib/Config.pm b/extensions/OpenGraph/lib/Config.pm new file mode 100644 index 000000000..514a55680 --- /dev/null +++ b/extensions/OpenGraph/lib/Config.pm @@ -0,0 +1,24 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::OpenGraph::Config; + +use 5.10.1; +use strict; +use warnings; + +use Bugzilla::Config::Common; + +use constant get_param_list => ( + { + name => 'opengraph_image', + type => 't', + default => '' + }, +); + +1; diff --git a/extensions/OpenGraph/template/en/default/admin/params/opengraph.html.tmpl b/extensions/OpenGraph/template/en/default/admin/params/opengraph.html.tmpl new file mode 100644 index 000000000..4a195aeff --- /dev/null +++ b/extensions/OpenGraph/template/en/default/admin/params/opengraph.html.tmpl @@ -0,0 +1,18 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% + title = "OpenGraph" + desc = "Configure OpenGraph support" +%] + +[% + param_descs = { + opengraph_image => 'URL to the social image for OpenGraph data', + } +%] diff --git a/extensions/OpenGraph/template/en/default/hook/global/header-start.html.tmpl b/extensions/OpenGraph/template/en/default/hook/global/header-start.html.tmpl index a8024caba..e74524e2b 100644 --- a/extensions/OpenGraph/template/en/default/hook/global/header-start.html.tmpl +++ b/extensions/OpenGraph/template/en/default/hook/global/header-start.html.tmpl @@ -20,6 +20,6 @@ [% ELSIF error_message %] [% END %] -[% IF og_image %] - +[% IF Bugzilla.params.opengraph_image %] + [% END %] diff --git a/extensions/OpenGraph/web/moz-social-bw-rgb-1200x1200.png b/extensions/OpenGraph/web/moz-social-bw-rgb-1200x1200.png deleted file mode 100644 index 9d701750e..000000000 Binary files a/extensions/OpenGraph/web/moz-social-bw-rgb-1200x1200.png and /dev/null differ diff --git a/template/en/default/index.html.tmpl b/template/en/default/index.html.tmpl index 8696d7137..e6a8032f0 100644 --- a/template/en/default/index.html.tmpl +++ b/template/en/default/index.html.tmpl @@ -30,7 +30,6 @@ header = "Main Page" style_urls = [ 'skins/standard/index.css' ] no_yui = 1 - og_image = "extensions/OpenGraph/web/moz-social-bw-rgb-1200x1200.png" %]