Index: trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | kv = kvs[i]; |
43 | 43 | // XXX: tokensToString actually strips too much here! Anything |
44 | 44 | // 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 ) { |
46 | 46 | // found. now look for the next entry with a non-empty key. |
47 | 47 | for ( var j = i; j < l; j++) { |
48 | 48 | kv = kvs[j]; |
— | — | @@ -152,15 +152,31 @@ |
153 | 153 | ParserFunctions.prototype['pf_currentmonthname'] = function ( target, argList, argDict ) { |
154 | 154 | return this['pf_#time']( 'F', [], {} ); |
155 | 155 | }; |
| 156 | +// XXX Actually use genitive form! |
| 157 | +ParserFunctions.prototype['pf_currentmonthnamegen'] = function ( target, argList, argDict ) { |
| 158 | + return this['pf_#time']( 'F', [], {} ); |
| 159 | +}; |
156 | 160 | ParserFunctions.prototype['pf_currentmonthabbrev'] = function ( target, argList, argDict ) { |
157 | 161 | return this['pf_#time']( 'M', [], {} ); |
158 | 162 | }; |
| 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 | +}; |
159 | 169 | ParserFunctions.prototype['pf_currentday'] = function ( target, argList, argDict ) { |
160 | 170 | return this['pf_#time']( 'j', [], {} ); |
161 | 171 | }; |
| 172 | +ParserFunctions.prototype['pf_currentday2'] = function ( target, argList, argDict ) { |
| 173 | + return this['pf_#time']( 'd', [], {} ); |
| 174 | +}; |
162 | 175 | ParserFunctions.prototype['pf_currentdayname'] = function ( target, argList, argDict ) { |
163 | 176 | return this['pf_#time']( 'l', [], {} ); |
164 | 177 | }; |
| 178 | +ParserFunctions.prototype['pf_currenttime'] = function ( target, argList, argDict ) { |
| 179 | + return this['pf_#time']( 'H:i', [], {} ); |
| 180 | +}; |
165 | 181 | |
166 | 182 | // A first approximation of time stuff. |
167 | 183 | // TODO: Implement time spec (+ 1 day etc), check if formats are complete etc. |
— | — | @@ -350,7 +366,7 @@ |
351 | 367 | }; |
352 | 368 | |
353 | 369 | ParserFunctions.prototype['pf_localurl'] = function ( target, argList, argDict ) { |
354 | | - return ( this.manager.env.wgScriptPath + '/index' + |
| 370 | + return ( this.manager.env.wgScriptPath + 'index' + |
355 | 371 | this.manager.env.wgScriptExtension + '?title=' + |
356 | 372 | this.manager.env.normalizeTitle( target ) + '&' + |
357 | 373 | argList.map( |
— | — | @@ -394,7 +410,6 @@ |
395 | 411 | return [target.trim()]; |
396 | 412 | }; |
397 | 413 | |
398 | | - |
399 | 414 | // The following items all depends on information from the Wiki, so are hard |
400 | 415 | // to implement independently. Some might require using action=parse in the |
401 | 416 | // API to get the value. See |
— | — | @@ -414,9 +429,6 @@ |
415 | 430 | ParserFunctions.prototype['pf_anchorencode'] = function ( target, argList, argDict ) { |
416 | 431 | return [target]; |
417 | 432 | }; |
418 | | -ParserFunctions.prototype['pf_namespace'] = function ( target, argList, argDict ) { |
419 | | - return ['Main']; |
420 | | -}; |
421 | 433 | ParserFunctions.prototype['pf_protectionlevel'] = function ( target, argList, argDict ) { |
422 | 434 | return ['']; |
423 | 435 | }; |
— | — | @@ -438,7 +450,23 @@ |
439 | 451 | ParserFunctions.prototype['pf_contentlang'] = function ( target, argList, argDict ) { |
440 | 452 | return ['en']; |
441 | 453 | }; |
| 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 | +}; |
442 | 469 | |
| 470 | + |
443 | 471 | if (typeof module == "object") { |
444 | 472 | module.exports.ParserFunctions = ParserFunctions; |
445 | 473 | } |