r94138 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94137‎ | r94138 | r94139 >
Date:21:51, 9 August 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
* Use ResourceLoader for Babel extension (Babel::Render() is a more logical place but does not work)
* Make it follow page content language direction
Modified paths:
  • /trunk/extensions/Babel/Babel.css (modified) (history)
  • /trunk/extensions/Babel/Babel.php (modified) (history)
  • /trunk/extensions/Babel/BabelStatic.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Babel/Babel.php
@@ -40,6 +40,12 @@
4141 $wgAutoloadClasses['BabelStatic'] = $dir . 'BabelStatic.class.php';
4242 $wgAutoloadClasses['BabelAutoCreate'] = $dir . 'BabelAutoCreate.class.php';
4343
 44+$wgResourceModules['BabelExtension'] = array(
 45+ 'styles' => 'Babel.css',
 46+ 'localBasePath' => dirname( __FILE__ ),
 47+ 'remoteExtPath' => 'Babel',
 48+);
 49+
4450 // Configuration setttings.
4551 // Language names and codes constant database files, the defaults should suffice.
4652 $wgBabelLanguageCodesCdb = $dir . 'codes.cdb';
Index: trunk/extensions/Babel/Babel.css
@@ -12,8 +12,8 @@
1313 /* Babel wrapper layout. */
1414 /* @noflip */table.mw-babel-wrapper {
1515 width: 238px;
16 - float: right; /* change this to 'left' on RTL wikis */
17 - clear: right; /* change this to 'left' on RTL wikis */
 16+ float: right;
 17+ clear: right;
1818 margin: 1em;
1919 background-color: white;
2020 border-style: solid;
@@ -21,13 +21,31 @@
2222 border-color: #99B3FF;
2323 }
2424
 25+/* @noflip */.mw-content-ltr table.mw-babel-wrapper {
 26+ float: right;
 27+ clear: right;
 28+}
 29+/* @noflip */.mw-content-rtl table.mw-babel-wrapper {
 30+ float: left;
 31+ clear: left;
 32+}
 33+
2534 /* Babel box layout */
2635 /* @noflip */div.mw-babel-box {
27 - float: left; /* change this to 'right' on RTL wikis */
28 - clear: left; /* change this to 'right' on RTL wikis */
 36+ float: left;
 37+ clear: left;
2938 margin: 1px;
3039 }
3140
 41+/* @noflip */.mw-content-ltr table.mw-babel-box {
 42+ float: left;
 43+ clear: left;
 44+}
 45+/* @noflip */.mw-content-rtl table.mw-babel-box {
 46+ float: right;
 47+ clear: right;
 48+}
 49+
3250 div.mw-babel-box table {
3351 width: 238px;
3452 }
Index: trunk/extensions/Babel/BabelStatic.class.php
@@ -14,6 +14,8 @@
1515 * @return Boolean: True.
1616 */
1717 public static function Setup( $parser ) {
 18+ global $wgOut;
 19+ $wgOut->addModules( 'BabelExtension' );
1820 $parser->setFunctionHook( 'babel', array( 'Babel', 'Render' ) );
1921 return true;
2022 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94142Followup r94138: use RL naming conventionsdemon01:41, 10 August 2011
r94149fu r94138: update comment in css file, and bump versionrobin10:11, 10 August 2011
r95610follow-up r94138: Change addModules() to addModuleStyles() as it only uses CSSrobin21:22, 27 August 2011
r97415Address one issue in r94138. Also added caller to linkbatch for debuggingnikerabbit12:39, 18 September 2011

Comments

#Comment by Jack Phoenix (talk | contribs)   01:11, 10 August 2011
 +$wgResourceModules['BabelExtension'] = array(

According to ResourceLoader/Migration guide for extension developers#Registering a module, the module name should probably be ext.babel.

#Comment by Catrope (talk | contribs)   11:45, 18 September 2011

A ParserFirstCallInit hook is not the right place to add your module. Babel::render() , as you say, is the right place. You just have to use $parser->getOutput()->addModuleStyles() rather than $wgOut->addModuleStyles().

OK otherwise.

#Comment by SPQRobin (talk | contribs)   13:06, 18 September 2011

Nikerabbit did this now in r97415.

Status & tagging log