r90875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90874‎ | r90875 | r90876 >
Date:14:04, 27 June 2011
Author:janpaul123
Status:ok (Comments)
Tags:
Comment:
Circumvented problem of local config breaking when debug=true and filed ResourceLoader bug: https://bugzilla.wikimedia.org/show_bug.cgi?id=29608
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.hooks.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.local.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.php (modified) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (modified) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js (modified) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.init.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.php
@@ -77,7 +77,15 @@
7878 'remoteExtPath' => 'WikiLove/modules/ext.wikiLove',
7979 );
8080
 81+// messages for default options, because we want to use them in the default
 82+// options module, but also for the user in the user options module
 83+$wgWikiLoveOptionMessages = array(
 84+ 'wikilove-type-makeyourown',
 85+);
 86+
8187 // resources
 88+// it is much better to have a chain like: startup -> default -> local -> init,
 89+// but because of this bug that isn't possible right now: https://bugzilla.wikimedia.org/29608
8290 $wgResourceModules += array(
8391 'ext.wikiLove.icon' => $extWikiLoveTpl + array(
8492 'styles' => 'ext.wikiLove.icon.css',
@@ -86,7 +94,6 @@
8795 'ext.wikiLove.startup' => $extWikiLoveTpl + array(
8896 'scripts' => array(
8997 'ext.wikiLove.core.js',
90 - 'ext.wikiLove.defaultOptions.js',
9198 ),
9299 'styles' => 'ext.wikiLove.css',
93100 'messages' => array(
@@ -107,7 +114,6 @@
108115 'wikilove-preview',
109116 'wikilove-notify',
110117 'wikilove-button-send',
111 - 'wikilove-type-makeyourown',
112118 'wikilove-err-header',
113119 'wikilove-err-title',
114120 'wikilove-err-msg',
@@ -125,15 +131,15 @@
126132 'ext.wikiLove.local' => array(
127133 'class' => 'WikiLoveLocal',
128134 /* for information only, this is actually in the class!
129 - 'dependencies' => array(
130 - 'ext.wikiLove.startup',
131 - ),
 135+ 'messages' => $wgWikiLoveOptionMessages,
 136+ 'dependencies' => 'ext.wikiLove.startup'
132137 */
133138 ),
134 - 'ext.wikiLove.init' => $extWikiLoveTpl + array(
135 - 'scripts' => 'ext.wikiLove.init.js',
136 - 'dependencies' => array(
137 - 'ext.wikiLove.local',
 139+ 'ext.wikiLove.defaultOptions' => $extWikiLoveTpl + array(
 140+ 'scripts' => array(
 141+ 'ext.wikiLove.defaultOptions.js',
138142 ),
 143+ 'messages' => $wgWikiLoveOptionMessages,
 144+ 'dependencies' => 'ext.wikiLove.startup'
139145 ),
140146 );
Index: trunk/extensions/WikiLove/WikiLove.hooks.php
@@ -49,7 +49,7 @@
5050 * @param $skin Skin
5151 */
5252 public static function beforePageDisplay( $out, $skin ) {
53 - global $wgWikiLoveGlobal, $wgUser;
 53+ global $wgWikiLoveGlobal, $wgWikiLoveEnableLocalConfig, $wgUser;
5454 if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) {
5555 return true;
5656 }
@@ -57,7 +57,17 @@
5858 $title = self::getUserTalkPage( $skin->getTitle() );
5959 if ( !is_null( $title ) ) {
6060 $out->addModules( 'ext.wikiLove.icon' );
61 - $out->addModules( 'ext.wikiLove.init' );
 61+
 62+ // it is much better to have a chain like: startup -> default -> local -> init,
 63+ // but because of this bug that isn't possible right now: https://bugzilla.wikimedia.org/29608
 64+ $optionsTitle = Title::newFromText( "MediaWiki:WikiLove.js" );
 65+ if( $optionsTitle->exists() && $optionsTitle->isCssOrJsPage() ) {
 66+ $out->addModules( 'ext.wikiLove.local' );
 67+ }
 68+ else {
 69+ $out->addModules( 'ext.wikiLove.defaultOptions' );
 70+ }
 71+
6272 self::$recipient = $title->getText();
6373 }
6474 return true;
Index: trunk/extensions/WikiLove/WikiLove.local.php
@@ -14,4 +14,9 @@
1515 'ext.wikiLove.startup',
1616 );
1717 }
 18+
 19+ public function getMessages() {
 20+ global $wgWikiLoveOptionMessages;
 21+ return $wgWikiLoveOptionMessages;
 22+ }
1823 }
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.init.js
@@ -1,3 +0,0 @@
2 -( function( $ ) {
3 -$( document ).ready( $.wikiLove.init );
4 -} )( jQuery );
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
@@ -1,5 +1,5 @@
22 ( function( $ ) {
3 -$.wikiLove.optionsHook = function() { return {
 3+$.wikiLoveOptions = function() { return {
44 defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\
55 |rowspan="2" style="vertical-align: middle; padding: 5px;" | [[$3|$4]]\n\
66 |style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\
@@ -356,4 +356,9 @@
357357 }
358358 }
359359 }; };
 360+
 361+if( typeof $.wikiLove != 'undefined' ) $.wikiLove.init(); // this is required when copying this file to MediaWiki:WikiLove.js
 362+// because of https://bugzilla.wikimedia.org/29608 ; please leave it here as it does no harm being executed in defaultOptions.js
 363+// and it may be confusing if it is required to uncomment it when copying this to MediaWiki:WikiLove.js
 364+
360365 } )( jQuery );
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -11,8 +11,6 @@
1212 gallery = {};
1313
1414 return {
15 - optionsHook: function() { return {}; }, // hook that can be overridden by the user to modify options
16 -
1715 /*
1816 * Opens the dialog and builds it if necessary.
1917 */
@@ -532,9 +530,12 @@
533531 /*
534532 * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog.
535533 */
536 - init: function() {
537 - options = $.wikiLove.optionsHook();
538 - $( '#ca-wikilove' ).find( 'a' ).click( function( e ) {
 534+ init: function( ) {
 535+ if( typeof $.wikiLoveOptions == 'function' ) options = $.wikiLoveOptions();
 536+
 537+ var $wikiLoveLink = $( '#ca-wikilove' ).find( 'a' );
 538+ $wikiLoveLink.unbind( 'click' );
 539+ $wikiLoveLink.click( function( e ) {
539540 $.wikiLove.openDialog();
540541 e.preventDefault();
541542 });
@@ -636,4 +637,6 @@
637638 };
638639
639640 }());
 641+
 642+$( document ).ready( $.wikiLove.init );
640643 } ) ( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r91008Follow-up r90875: Removing undefined/unused globalkrinkle21:23, 28 June 2011

Comments

#Comment by Krinkle (talk | contribs)   18:27, 29 June 2011

Made changes in r91008 and r91083. Rest looks good.

Status & tagging log