Use exchars instead of exsentences for the extract

To avoid sentence parsing bugs in other languages.

We have to artificially remove the always-added ellipsis from textextracts to
mimic previous behavior, and we'll add ellipsis via CSS afterwards.

Bug: T135824
Change-Id: Idf27f2fd18f7197e588c609eeb62ac8fc80626d7
This commit is contained in:
Joakin 2016-05-26 12:33:05 +02:00 committed by Sam Smith
parent 107d6edd37
commit ea072139df

View file

@ -8,6 +8,12 @@
var article = {},
$window = $( window );
/**
* Number of chars to request for the article extract
* @property CHARS
*/
article.CHARS = 525;
/**
* Size constants for popup images
* @property SIZES
@ -55,7 +61,7 @@
formatversion: 2,
redirects: true,
exintro: true,
exsentences: 5,
exchars: article.CHARS,
// there is an added geometric limit on .mwe-popups-extract
// so that text does not overflow from the card
explaintext: true,
@ -100,6 +106,8 @@
return;
}
re.query.pages[ 0 ].extract = removeEllipsis( re.query.pages[ 0 ].extract );
mw.popups.render.cache[ href ] = {};
mw.popups.render.cache[ href ].popup = article.createPopup( re.query.pages[ 0 ], href );
mw.popups.render.cache[ href ].getOffset = article.getOffset;
@ -667,4 +675,11 @@
*/
mw.popups.render.getClosestYPosition = getClosestYPosition;
/**
* Remove ellipsis if exists at the end
*/
function removeEllipsis( text ) {
return text.replace( /\.\.\.$/, '' );
}
} )( jQuery, mediaWiki );