Adamw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/81043
Change subject: (FR #1014) Disable banner preview and rough out new method
......................................................................
(FR #1014) Disable banner preview and rough out new method
We will load screenshots from an archive. If no screenshot provider is
configured, do not display previews.
Change-Id: I185fa242c1b4347c00c7b281eab32c621479f742
---
M CentralNotice.hooks.php
M CentralNotice.i18n.php
M CentralNotice.modules.php
M CentralNotice.php
M includes/BannerRenderer.php
M includes/HtmlFormElements/HTMLCentralNoticeBanner.php
D modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.css
D modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.js
M modules/ext.centralNotice.adminUi/adminui.common.css
D special/SpecialBannerPreview.php
10 files changed, 37 insertions(+), 153 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/43/81043/1
diff --git a/CentralNotice.hooks.php b/CentralNotice.hooks.php
index 191703d..a694f02 100644
--- a/CentralNotice.hooks.php
+++ b/CentralNotice.hooks.php
@@ -54,7 +54,6 @@
// Register files
$wgAutoloadClasses[ 'CentralNotice' ] = $specialDir .
'SpecialCentralNotice.php';
$wgAutoloadClasses[ 'SpecialBannerLoader' ] = $specialDir .
'SpecialBannerLoader.php';
- $wgAutoloadClasses[ 'SpecialBannerPreview' ] = $specialDir .
'SpecialBannerPreview.php';
$wgAutoloadClasses[ 'SpecialBannerRandom' ] = $specialDir .
'SpecialBannerRandom.php';
$wgAutoloadClasses[ 'SpecialRecordImpression' ] = $specialDir .
'SpecialRecordImpression.php';
$wgAutoloadClasses[ 'SpecialHideBanners' ] = $specialDir .
'SpecialHideBanners.php';
@@ -104,7 +103,6 @@
// Register special pages
$wgSpecialPages[ 'BannerLoader' ] = 'SpecialBannerLoader';
- $wgSpecialPages[ 'BannerPreview' ] = 'SpecialBannerPreview';
$wgSpecialPages[ 'BannerRandom' ] = 'SpecialBannerRandom';
$wgSpecialPages[ 'RecordImpression' ] = 'SpecialRecordImpression';
$wgSpecialPages[ 'HideBanners' ] = 'SpecialHideBanners';
@@ -341,4 +339,4 @@
);
$out->addModules( $names );
return true;
-}
\ No newline at end of file
+}
diff --git a/CentralNotice.i18n.php b/CentralNotice.i18n.php
index 48857a2..45baf4d 100644
--- a/CentralNotice.i18n.php
+++ b/CentralNotice.i18n.php
@@ -231,7 +231,6 @@
'centralnotice-delete-banner-confirm' => 'Deletion removes all settings
and messages. This action cannot be reversed. Consider archiving instead.',
'centralnotice-delete-banner-cancel' => 'Cancel',
- 'centralnotice-noiframe' => 'This element cannot be displayed without
iframes.',
'centralnotice-messages-pending-approval' => 'Languages with messages
currently pending approval',
'centralnotice-devices' => 'Display on devices',
@@ -686,7 +685,6 @@
* $1 - number of banners',
'centralnotice-delete-banner-confirm' => 'Used as confirmation message
in the dialog box which has the title
{{msg-mw|Centralnotice-delete-banner-title}}.',
'centralnotice-delete-banner-cancel' => '{{Identical|Cancel}}',
- 'centralnotice-noiframe' => 'Inform the user that banner previewing has
failed because their browser does not support iframes.',
'centralnotice-messages-pending-approval' => 'Label for a list of
languages in which banner messages are pending approval',
'centralnotice-devices' => 'Log line label for showing a list of
devices (e.g. iphone, desktop) that the banner will display on.
diff --git a/CentralNotice.modules.php b/CentralNotice.modules.php
index ab575cf..ae89cc3 100644
--- a/CentralNotice.modules.php
+++ b/CentralNotice.modules.php
@@ -107,13 +107,6 @@
'centralnotice-delete-banner-cancel',
)
);
-$wgResourceModules[ 'ext.centralNotice.adminUi.bannerPreview' ] = array(
- 'localBasePath' => $dir .
'/modules/ext.centralNotice.adminUi.bannerPreview',
- 'remoteExtPath' =>
'CentralNotice/modules/ext.centralNotice.adminUi.bannerPreview',
- 'styles' => 'bannerPreview.css',
- 'scripts' => 'bannerPreview.js',
- 'dependencies' => 'ext.centralNotice.bannerController',
-);
$wgResourceModules[ 'ext.centralNotice.bannerStats' ] = array(
'localBasePath' => $dir . '/modules',
'remoteExtPath' => 'CentralNotice/modules',
diff --git a/CentralNotice.php b/CentralNotice.php
index 47f1aab..cd4662d 100644
--- a/CentralNotice.php
+++ b/CentralNotice.php
@@ -99,6 +99,10 @@
// URL for a banner close button
$wgNoticeCloseButton =
'//upload.wikimedia.org/wikipedia/foundation/2/20/CloseWindow19x19.png';
+// URL prefix where banner screenshots are stored. False if this feature is
disabled.
+// meta.wikimedia.org CentralNotice banners are archived at
'http://fundraising-archive.wmflabs.org/banner/'
+$wgNoticeBannerPreview = false;
+
// Domain to set global cookies for.
// Example: '.wikipedia.org'
$wgNoticeCookieDomain = '';
@@ -211,4 +215,4 @@
// Register user rights
$wgAvailableRights[] = 'centralnotice-admin';
-$wgGroupPermissions[ 'sysop' ][ 'centralnotice-admin' ] = true; // Only sysops
can make change
\ No newline at end of file
+$wgGroupPermissions[ 'sysop' ][ 'centralnotice-admin' ] = true; // Only sysops
can make change
diff --git a/includes/BannerRenderer.php b/includes/BannerRenderer.php
index 8eb9a1b..0f00e81 100644
--- a/includes/BannerRenderer.php
+++ b/includes/BannerRenderer.php
@@ -54,29 +54,26 @@
/**
* Render the banner as an html fieldset
- * This actually renders a fieldset with an iframe inside of it
*/
function previewFieldSet() {
- $previewUrl = SpecialPage::getTitleFor( 'BannerPreview'
)->getLocalURL(
- '',
- array(
- 'banner' => $this->banner->getName(),
- 'uselang' =>
$this->allocContext->getLanguage(),
- 'force' => '1'
- )
- );
- $preview = Xml::tags(
- 'iframe',
+ global $wgNoticeBannerPreview;
+
+ if ( !$wgNoticeBannerPreview ) {
+ return '';
+ }
+
+ $bannerName = $this->banner->getName();
+ $lang = $this->context->getLanguage()->getCode();
+
+ $previewUrl = $wgNoticeBannerPreview .
"{$bannerName}/{$bannerName}_{$lang}.png";
+ $preview = Html::element(
+ 'img',
array(
'src' => $previewUrl,
- 'width' => "100%",
- 'seamless' => 'seamless',
- 'frameborder' => 0,
- ),
- wfMessage( 'centralnotice-noiframe' )
+ 'alt' => $bannerName,
+ )
);
- $lang = $this->context->getLanguage()->getCode();
$label = $this->context->msg( 'centralnotice-preview', $lang
)->text();
return Xml::fieldset(
diff --git a/includes/HtmlFormElements/HTMLCentralNoticeBanner.php
b/includes/HtmlFormElements/HTMLCentralNoticeBanner.php
index 87ebe8c..8cd2fdd 100644
--- a/includes/HtmlFormElements/HTMLCentralNoticeBanner.php
+++ b/includes/HtmlFormElements/HTMLCentralNoticeBanner.php
@@ -36,7 +36,8 @@
/** Get a preview of the banner */
public function getInputHTML( $value ) {
- global $wgOut;
+ global $wgOut,
+ $wgNoticeBannerPreview;
$bannerName = $this->mParams['banner'];
if ( array_key_exists( 'language', $this->mParams ) ) {
@@ -45,22 +46,13 @@
$language =
$wgOut->getContext()->getLanguage()->getCode();
}
- $previewUrl = SpecialPage::getTitleFor( 'BannerPreview'
)->getLocalURL(
- array(
- 'banner' => $bannerName,
- 'uselang' => $language,
- 'force' => '1'
- )
- );
- $preview = Xml::tags(
- 'iframe',
+ $previewUrl = $wgNoticeBannerPreview .
"/{$bannerName}/{$bannerName}_{$language}.png";
+ $preview = Html::Element(
+ 'img',
array(
'src' => $previewUrl,
- 'width' => "100%",
- 'seamless' => 'seamless',
- 'frameborder' => 0,
- ),
- $this->msg( 'centralnotice-noiframe' )
+ 'alt' => $bannerName,
+ )
);
return Xml::tags(
@@ -82,7 +74,9 @@
}
public function getDiv( $value ) {
- global $wgOut;
+ global $wgOut,
+ $wgNoticeBannerPreview;
+
if ( array_key_exists( 'language', $this->mParams ) ) {
$language = $this->mParams['language'];
} else {
@@ -122,7 +116,9 @@
}
// Add the banner preview
- $html .= $this->getInputHTML( null );
+ if ( $wgNoticeBannerPreview ) {
+ $html .= $this->getInputHTML( null );
+ }
$html .= Xml::closeElement( 'div' );
return $html;
diff --git a/modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.css
b/modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.css
deleted file mode 100644
index 39557e6..0000000
--- a/modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.css
+++ /dev/null
@@ -1,23 +0,0 @@
-#mw-navigation,
-#footer,
-#content a#top,
-#firstHeading,
-div#bodyContent {
- display: none;
-}
-
-body,
-#mw-head-base,
-#mw-page-base,
-div#content {
- height: auto;
- margin: 0;
- margin-left: 0;
- padding: 0;
- background: #FFFFFF;
- border: none;
-}
-
-.vector-animateLayout {
- transition: none;
-}
diff --git a/modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.js
b/modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.js
deleted file mode 100644
index cb40fa2..0000000
--- a/modules/ext.centralNotice.adminUi.bannerPreview/bannerPreview.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * JS that is loaded onto every MW page to load banners.
- *
- * Requires the Geo global object; e.g. from geoiplookup.wikimedia.org
- *
- * This file is part of the CentralNotice Extension to MediaWiki
- * https://www.mediawiki.org/wiki/Extension:CentralNotice
- *
- * @section LICENSE
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-( function ( $, mw ) {
- mw.centralNotice.events.bannerLoaded.done( function() {
- setTimeout( function() {
- window.parent.postMessage(
- JSON.stringify( {
- banner:
mw.centralNotice.bannerData.bannerName,
- height: $( '#centralNotice' ).prop(
'offsetHeight' ) | 1
- } ),
- '*'
- );
- }, 100 );
- } );
-} )( jQuery, mediaWiki );
diff --git a/modules/ext.centralNotice.adminUi/adminui.common.css
b/modules/ext.centralNotice.adminUi/adminui.common.css
index 442f073..c06df03 100644
--- a/modules/ext.centralNotice.adminUi/adminui.common.css
+++ b/modules/ext.centralNotice.adminUi/adminui.common.css
@@ -47,13 +47,14 @@
margin-top: 0.5em;
}
#mw-htmlform-banner-list .mw-htmlform-field-HTMLCheckField {
+ display: inline-block;
float: left;
}
-#mw-htmlform-banner-list .cn-banner-list-element {
- display: inline;
+#mw-htmlform-banner-list .mw-label {
+ display: none;
}
/* --- Archival --- */
.cn-archived-item {
display: none;
-}
\ No newline at end of file
+}
diff --git a/special/SpecialBannerPreview.php b/special/SpecialBannerPreview.php
deleted file mode 100644
index 8e6e835..0000000
--- a/special/SpecialBannerPreview.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-/**
- * This file is part of the CentralNotice Extension to MediaWiki
- * https://www.mediawiki.org/wiki/Extension:CentralNotice
- *
- * @section LICENSE
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-/**
- * Renders banner in a stripped-down MediaWiki environment
- */
-class SpecialBannerPreview extends SpecialBannerLoader {
- function __construct() {
- // Register special page
- UnlistedSpecialPage::__construct( "BannerPreview" );
- }
-
- function execute( $par ) {
- $this->getOutput()->allowClickJacking();
-
- $this->getOutput()->addModules(
'ext.centralNotice.adminUi.bannerPreview' );
-
- // Let the controller do its thing.
- }
-}
--
To view, visit https://gerrit.wikimedia.org/r/81043
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I185fa242c1b4347c00c7b281eab32c621479f742
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits