Provide mw-redirect and mw-disambig classes for links on the surface

To mimic PHP parser, or, in the case of mw-disambig, what I would want
the PHP parser to be.

Change-Id: I70dc426a3b87daef27816d6d86130c39f30ba0f4
This commit is contained in:
Bartosz Dziewoński 2014-07-31 16:25:52 +02:00
parent 3d475420cb
commit 066283dde7
2 changed files with 20 additions and 4 deletions

View file

@ -28,6 +28,16 @@ ve.ce.MWInternalLinkAnnotation = function VeCeMWInternalLinkAnnotation( model, p
.done( function ( data ) {
if ( data.missing ) {
annotation.$element.addClass( 'new' );
} else {
// Provided by core MediaWiki, no styles by default.
if ( data.redirect ) {
annotation.$element.addClass( 'mw-redirect' );
}
// Should be provided by the Disambiguator extension, but no one has yet written a suitably
// performant patch to do it. It is instead implemented in JavaScript in on-wiki gadgets.
if ( data.disambiguation ) {
annotation.$element.addClass( 'mw-disambig' );
}
}
} );

View file

@ -92,12 +92,17 @@
}
function processData( data ) {
var pageid, info, dfd, pages = data.query && data.query.pages || {};
var pageid, page, info, dfd,
pages = data.query && data.query.pages || {};
for ( pageid in pages ) {
page = pages[pageid];
info = {
'missing': pages[pageid].missing !== undefined
'missing': page.missing !== undefined,
'redirect': page.redirect !== undefined,
// Disambiguator extension
'disambiguation': page.pageprops && page.pageprops.disambiguation !== undefined
};
dfd = linkCache.cache[pages[pageid].title];
dfd = linkCache.cache[page.title];
if ( dfd ) {
dfd.resolve( info );
}
@ -115,7 +120,8 @@
subqueue = queue.splice( 0, 50 ).map( normalizeTitle );
ve.init.target.constructor.static.apiRequest( {
'action': 'query',
'prop': 'info',
'prop': 'info|pageprops',
'ppprop': 'disambiguation',
'titles': subqueue.join( '|' )
} )
.done( processData )