r112117 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112116‎ | r112117 | r112118 >
Date:16:41, 22 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Follow-up to r112116, accidentally committed from subdirectory.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js
@@ -41,7 +41,7 @@
4242 kv = kvs[i];
4343 // XXX: tokensToString actually strips too much here! Anything
4444 // non-stringish should not match at all.
45 - if ( this.manager.env.tokensToString( kv.v ).trim() === key ) {
 45+ if ( this.manager.env.tokensToString( kv.v ) === key ) {
4646 // found. now look for the next entry with a non-empty key.
4747 for ( var j = i; j < l; j++) {
4848 kv = kvs[j];
@@ -152,15 +152,31 @@
153153 ParserFunctions.prototype['pf_currentmonthname'] = function ( target, argList, argDict ) {
154154 return this['pf_#time']( 'F', [], {} );
155155 };
 156+// XXX Actually use genitive form!
 157+ParserFunctions.prototype['pf_currentmonthnamegen'] = function ( target, argList, argDict ) {
 158+ return this['pf_#time']( 'F', [], {} );
 159+};
156160 ParserFunctions.prototype['pf_currentmonthabbrev'] = function ( target, argList, argDict ) {
157161 return this['pf_#time']( 'M', [], {} );
158162 };
 163+ParserFunctions.prototype['pf_currentweek'] = function ( target, argList, argDict ) {
 164+ return this['pf_#time']( 'W', [], {} );
 165+};
 166+ParserFunctions.prototype['pf_currentdow'] = function ( target, argList, argDict ) {
 167+ return this['pf_#time']( 'w', [], {} );
 168+};
159169 ParserFunctions.prototype['pf_currentday'] = function ( target, argList, argDict ) {
160170 return this['pf_#time']( 'j', [], {} );
161171 };
 172+ParserFunctions.prototype['pf_currentday2'] = function ( target, argList, argDict ) {
 173+ return this['pf_#time']( 'd', [], {} );
 174+};
162175 ParserFunctions.prototype['pf_currentdayname'] = function ( target, argList, argDict ) {
163176 return this['pf_#time']( 'l', [], {} );
164177 };
 178+ParserFunctions.prototype['pf_currenttime'] = function ( target, argList, argDict ) {
 179+ return this['pf_#time']( 'H:i', [], {} );
 180+};
165181
166182 // A first approximation of time stuff.
167183 // TODO: Implement time spec (+ 1 day etc), check if formats are complete etc.
@@ -350,7 +366,7 @@
351367 };
352368
353369 ParserFunctions.prototype['pf_localurl'] = function ( target, argList, argDict ) {
354 - return ( this.manager.env.wgScriptPath + '/index' +
 370+ return ( this.manager.env.wgScriptPath + 'index' +
355371 this.manager.env.wgScriptExtension + '?title=' +
356372 this.manager.env.normalizeTitle( target ) + '&' +
357373 argList.map(
@@ -394,7 +410,6 @@
395411 return [target.trim()];
396412 };
397413
398 -
399414 // The following items all depends on information from the Wiki, so are hard
400415 // to implement independently. Some might require using action=parse in the
401416 // API to get the value. See
@@ -414,9 +429,6 @@
415430 ParserFunctions.prototype['pf_anchorencode'] = function ( target, argList, argDict ) {
416431 return [target];
417432 };
418 -ParserFunctions.prototype['pf_namespace'] = function ( target, argList, argDict ) {
419 - return ['Main'];
420 -};
421433 ParserFunctions.prototype['pf_protectionlevel'] = function ( target, argList, argDict ) {
422434 return [''];
423435 };
@@ -438,7 +450,23 @@
439451 ParserFunctions.prototype['pf_contentlang'] = function ( target, argList, argDict ) {
440452 return ['en'];
441453 };
 454+ParserFunctions.prototype['pf_numberoffiles'] = function ( target, argList, argDict ) {
 455+ return ['2'];
 456+};
 457+ParserFunctions.prototype['pf_namespace'] = function ( target, argList, argDict ) {
 458+ return [target.split(':').pop() || 'Main'];
 459+};
 460+ParserFunctions.prototype['pf_namespacee'] = function ( target, argList, argDict ) {
 461+ return [target.split(':').pop() || 'Main'];
 462+};
 463+ParserFunctions.prototype['pf_pagename'] = function ( target, argList, argDict ) {
 464+ return ['Main page'];
 465+};
 466+ParserFunctions.prototype['pf_scriptpath'] = function ( target, argList, argDict ) {
 467+ return [this.manager.env.wgScriptPath];
 468+};
442469
 470+
443471 if (typeof module == "object") {
444472 module.exports.ParserFunctions = ParserFunctions;
445473 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112116Green two more parser tests by implementing some parser functions.gwicke16:39, 22 February 2012

Status & tagging log