mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
A few (partly hackish) improvements
* Very basic support attribute key-value pairs emitted from templates * Add TALKPAGENAME stub implementation * Only show 'no revisions' message for top-level pages Change-Id: I4b4ac0c7b2c0531ac4b39f0f49f4217302576ab9
This commit is contained in:
parent
540d14d8fe
commit
13ae7cda11
|
@ -655,6 +655,9 @@ ParserFunctions.prototype.pf_pagenamebase = function ( token, frame, cb, args )
|
|||
ParserFunctions.prototype.pf_scriptpath = function ( token, frame, cb, args ) {
|
||||
cb( { tokens: [this.env.wgScriptPath] } );
|
||||
};
|
||||
ParserFunctions.prototype.pf_talkpagename = function ( token, frame, cb, args ) {
|
||||
cb( { tokens: [this.env.pageName.replace(/^[^:]:/, 'Talk:' ) || ''] } );
|
||||
};
|
||||
|
||||
|
||||
if (typeof module == "object") {
|
||||
|
|
|
@ -371,11 +371,13 @@ TemplateRequest.prototype._handler = function (error, response, body) {
|
|||
normalizeTitle = page.title;
|
||||
} else {
|
||||
console.warn( 'Did not find page revisions for ' + this.title );
|
||||
src = 'No revisions for ' + this.title;
|
||||
if ( this.title === this.manager.env.pageName ) {
|
||||
src = 'No revisions for ' + this.title;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch ( e2 ) {
|
||||
console.warn( 'Did not find page revisions in the returned body:' + body );
|
||||
console.warn( 'Did not find page revisions in the returned body:' + body + e2 );
|
||||
src = 'No content for ' + this.title;
|
||||
}
|
||||
|
||||
|
|
|
@ -793,6 +793,20 @@ AttributeTransformManager.prototype.process = function ( attributes ) {
|
|||
var kv = new KV( [], [] );
|
||||
this.kvs.push( kv );
|
||||
|
||||
if ( cur.v.constructor === Array && cur.v.length ) {
|
||||
// Assume that the return is async, will be decremented in callback
|
||||
this.outstanding++;
|
||||
|
||||
// transform the value
|
||||
this.frame.expand( cur.v,
|
||||
{
|
||||
type: this._toType,
|
||||
cb: this._returnAttributeValue.bind( this, i )
|
||||
} );
|
||||
} else {
|
||||
kv.v = cur.v;
|
||||
}
|
||||
|
||||
if ( cur.k.constructor === Array && cur.k.length ) {
|
||||
// Assume that the return is async, will be decremented in callback
|
||||
this.outstanding++;
|
||||
|
@ -807,19 +821,6 @@ AttributeTransformManager.prototype.process = function ( attributes ) {
|
|||
kv.k = cur.k;
|
||||
}
|
||||
|
||||
if ( cur.v.constructor === Array && cur.v.length ) {
|
||||
// Assume that the return is async, will be decremented in callback
|
||||
this.outstanding++;
|
||||
|
||||
// transform the value
|
||||
this.frame.expand( cur.v,
|
||||
{
|
||||
type: this._toType,
|
||||
cb: this._returnAttributeValue.bind( this, i )
|
||||
} );
|
||||
} else {
|
||||
kv.v = cur.v;
|
||||
}
|
||||
}
|
||||
this.outstanding--;
|
||||
if ( this.outstanding === 0 ) {
|
||||
|
@ -943,6 +944,15 @@ AttributeTransformManager.prototype._returnAttributeKey = function ( ref, tokens
|
|||
//console.warn( 'check _returnAttributeKey: ' + JSON.stringify( tokens ) );
|
||||
this.kvs[ref].k = tokens;
|
||||
this.kvs[ref].k = this.manager.env.stripEOFTkfromTokens( this.kvs[ref].k );
|
||||
if ( this.kvs[ref].v === '' ) {
|
||||
// FIXME: use tokenizer production to properly parse this
|
||||
var m = this.manager.env.tokensToString( this.kvs[ref].k ).match( /([^=]+)=['"]?([^'"]*)['"]?$/ );
|
||||
if ( m ) {
|
||||
this.kvs[ref].k = m[1];
|
||||
this.kvs[ref].v = m[2];
|
||||
//console.warn( m + JSON.stringify( this.kvs[ref] ) );
|
||||
}
|
||||
}
|
||||
this.outstanding--;
|
||||
if ( this.outstanding === 0 ) {
|
||||
this.callback( this.kvs );
|
||||
|
|
|
@ -254,8 +254,8 @@ MWParserEnvironment.prototype.normalizeTitle = function( name ) {
|
|||
* @fixme do this for real eh
|
||||
*/
|
||||
MWParserEnvironment.prototype.resolveTitle = function( name, namespace ) {
|
||||
// hack!
|
||||
if (name.indexOf(':') == -1 && namespace ) {
|
||||
// hack! FIXME: match against proper list of namespaces
|
||||
if ( ( name.indexOf(':') == -1 || name.match(/^H:/) ) && namespace ) {
|
||||
// hack hack hack
|
||||
name = namespace + ':' + this.normalizeTitle( name );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue