]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
De-hardcode OpenGraph social image (og:image URL) (#78)
authorVladimir Panteleev <CyberShadow@users.noreply.github.com>
Sat, 13 Feb 2021 17:15:44 +0000 (17:15 +0000)
committerGitHub <noreply@github.com>
Sat, 13 Feb 2021 17:15:44 +0000 (12:15 -0500)
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.

extensions/OpenGraph/Extension.pm
extensions/OpenGraph/lib/Config.pm [new file with mode: 0644]
extensions/OpenGraph/template/en/default/admin/params/opengraph.html.tmpl [new file with mode: 0644]
extensions/OpenGraph/template/en/default/hook/global/header-start.html.tmpl
extensions/OpenGraph/web/moz-social-bw-rgb-1200x1200.png [deleted file]
template/en/default/index.html.tmpl

index 18ee2c22f1dbaa0677ffd24f3b0dd1f06def16fc..eee0ffc5e2756b916f40a92954bce57136547ad3 100644 (file)
@@ -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 (file)
index 0000000..514a556
--- /dev/null
@@ -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 (file)
index 0000000..4a195ae
--- /dev/null
@@ -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',
+   }
+%]
index a8024caba17c8ebb53ddeaecde3c500e50ec99ef..e74524e2b562204174c8b6124d3c3091caa3949e 100644 (file)
@@ -20,6 +20,6 @@
 [% ELSIF error_message %]
 <meta property="og:description" content="[% error_message FILTER txt FILTER html %]">
 [% END %]
-[% IF og_image %]
-<meta property="og:image" content="[% urlbase FILTER none %][% og_image FILTER html %]">
+[% IF Bugzilla.params.opengraph_image %]
+<meta property="og:image" content="[% Bugzilla.params.opengraph_image FILTER html %]">
 [% 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 (file)
index 9d70175..0000000
Binary files a/extensions/OpenGraph/web/moz-social-bw-rgb-1200x1200.png and /dev/null differ
index 8696d713701f3d0ca6b68df458eab77bad2e0d0d..e6a8032f03fcea2cbcfed5c7888748db1bc6eb53 100644 (file)
@@ -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"
 %]
 
 <div id="page-index">