r96255 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96254‎ | r96255 | r96256 >
Date:21:01, 4 September 2011
Author:ashley
Status:deferred (Comments)
Tags:
Comment:
ShoutWikiAds: add ResourceLoader support, drop backwards compatibility with pre-1.17 MWs and bump version number. Untested.
Modified paths:
  • /trunk/extensions/ShoutWikiAds/ShoutWikiAds.class.php (modified) (history)
  • /trunk/extensions/ShoutWikiAds/ShoutWikiAds.php (modified) (history)
  • /trunk/extensions/ShoutWikiAds/css/monobook-button-ad.css (modified) (history)
  • /trunk/extensions/ShoutWikiAds/css/monobook-skyscraper-ad.css (modified) (history)

Diff [purge]

Index: trunk/extensions/ShoutWikiAds/ShoutWikiAds.php
@@ -4,8 +4,8 @@
55 *
66 * @file
77 * @ingroup Extensions
8 - * @version 0.1
9 - * @date 24 April 2011
 8+ * @version 0.2
 9+ * @date 4 September 2011
1010 * @author Jack Phoenix <jack@countervandalism.net>
1111 * @license http://en.wikipedia.org/wiki/Public_domain Public domain
1212 * @link http://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads Documentation
@@ -18,7 +18,7 @@
1919 // Extension credits that will show up on Special:Version
2020 $wgExtensionCredits['other'][] = array(
2121 'name' => 'ShoutWiki Ads',
22 - 'version' => '0.1',
 22+ 'version' => '0.2',
2323 'author' => 'Jack Phoenix',
2424 'description' => 'Delicious advertisements for everyone!',
2525 'url' => 'http://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads',
@@ -44,6 +44,28 @@
4545 // Truglass
4646 $wgHooks['TruglassInContent'][] = 'ShoutWikiAds::renderTruglassAd';
4747
 48+// ResourceLoader support for MediaWiki 1.17+
 49+$resourceTemplate = array(
 50+ 'localBasePath' => dirname( __FILE__ ),
 51+ 'remoteExtPath' => 'ShoutWikiAds'
 52+);
 53+
 54+$wgResourceModules['ext.ShoutWikiAds.monaco'] = $resourceTemplate + array(
 55+ 'styles' => 'css/monaco-ads.css'
 56+);
 57+
 58+$wgResourceModules['ext.ShoutWikiAds.monobook.button'] = $resourceTemplate + array(
 59+ 'styles' => 'css/monobook-button-ad.css'
 60+);
 61+
 62+$wgResourceModules['ext.ShoutWikiAds.monobook.skyscraper'] = $resourceTemplate + array(
 63+ 'styles' => 'css/monobook-skyscraper-ad.css'
 64+);
 65+
 66+$wgResourceModules['ext.ShoutWikiAds.truglass'] = $resourceTemplate + array(
 67+ 'styles' => 'css/truglass-ads.css'
 68+);
 69+
4870 /* Configuration
4971 $wgAdConfig = array(
5072 'enabled' => true, // enabled or not? :P
Index: trunk/extensions/ShoutWikiAds/ShoutWikiAds.class.php
@@ -281,28 +281,28 @@
282282 {
283283 $title = $out->getTitle();
284284 $namespace = $title->getNamespace();
 285+
285286 // Okay, the variable name sucks but anyway...normal page != not login page
286287 $isNormalPage = $title instanceof Title &&
287288 SpecialPage::resolveAlias( $title->getDBkey() ) !== 'Userlogin';
 289+
288290 // Load ad CSS file when ads are enabled
289291 if(
290292 $isNormalPage &&
291293 in_array( $namespace, $wgAdConfig['namespaces'] )
292294 )
293295 {
294 - global $wgScriptPath;
295 - $cssPath = $wgScriptPath . '/extensions/ShoutWikiAds/css/';
296296 if ( get_class( $sk ) == 'SkinMonaco' ) { // Monaco
297 - $out->addExtensionStyle( $cssPath . 'monaco-ads.css' );
 297+ $out->addModuleStyles( 'ext.ShoutWikiAds.monaco' );
298298 } elseif( get_class( $sk ) == 'SkinMonoBook' ) { // Monobook
299299 if ( $wgAdConfig['right-column'] ) {
300 - $out->addExtensionStyle( $cssPath . 'monobook-skyscraper-ad.css' );
 300+ $out->addModuleStyles( 'ext.ShoutWikiAds.monobook.skyscraper' );
301301 }
302302 if ( $wgAdConfig['toolbox-button'] ) {
303 - $out->addExtensionStyle( $cssPath . 'monobook-button-ad.css' );
 303+ $out->addModuleStyles( 'ext.ShoutWikiAds.monobook.button' );
304304 }
305305 } elseif ( get_class( $sk ) == 'SkinTruglass' ) { // Truglass
306 - $out->addExtensionStyle( $cssPath . 'truglass-ads.css' );
 306+ $out->addModuleStyles( 'ext.ShoutWikiAds.truglass' );
307307 }
308308 }
309309 }
Index: trunk/extensions/ShoutWikiAds/css/monobook-skyscraper-ad.css
@@ -2,7 +2,10 @@
33 * Skyscraper ad styling for Monobook skin
44 */
55 #content {
6 - margin: 2.8em 125px 0 12.2em !important;
 6+ margin-top: 2.8em !important;
 7+ margin-right: 125px !important;
 8+ margin-bottom: 0 !important;
 9+ margin-left: 12.2em !important;
710 }
811
912 #content {
@@ -13,7 +16,10 @@
1417 width: 120px;
1518 clear: left;
1619 position: absolute;
17 - padding: 35px 0px 0px 3px;
 20+ padding-top: 35px;
 21+ padding-right: 0px;
 22+ padding-bottom: 0px;
 23+ padding-left: 3px;
1824 float: right;
1925 right: 0px;
2026 top: 10px;
@@ -22,24 +28,4 @@
2329
2430 #footer {
2531 width: 91%;
26 -}
27 -
28 -/* RTL rules */
29 -body.rtl #content {
30 - margin: 2.8em 12.2em 0 125px !important;
31 -}
32 -
33 -body.rtl #content {
34 - border-left: solid 1px rgb(170,170,170);
35 -}
36 -
37 -body.rtl #column-google {
38 - width: 120px;
39 - clear: right;
40 - position: absolute;
41 - padding: 35px 3px 0px 0px;
42 - float: left;
43 - left: 0px;
44 - top: 10px;
45 - z-index: 1;
4632 }
\ No newline at end of file
Index: trunk/extensions/ShoutWikiAds/css/monobook-button-ad.css
@@ -6,12 +6,4 @@
77 top: 10px;
88 width: 150px;
99 z-index: 1;
10 -}
11 -
12 -/* RTL rules */
13 -body.rtl #p-ads-left {
14 - left: 0px;
15 - top: 10px;
16 - width: 150px;
17 - z-index: 1;
1810 }
\ No newline at end of file

Comments

#Comment by Siebrand (talk | contribs)   21:04, 4 September 2011

i18n-able extension description message is missing.

#Comment by Jack Phoenix (talk | contribs)   20:28, 5 September 2011

That's "by design" for the time being; I'm not a big fan of adding extension description messages for simple parser hooks and other extensions that do not have any text that is shown to the end-user. That being said, we can cross that bridge when it's necessary, but I have plenty of other extensions and skins — such as SocialProfile, ProtectSite and WikiForum, to name a few — that should be a higher priority to translators than this extension. Of course one additional message doesn't matter much when you have 100+ messages, but in this case it matters, because there's no i18n file.

#Comment by Siebrand (talk | contribs)   20:38, 5 September 2011

Please add it for consistency reasons.

Status & tagging log