mediawiki-extensions-Relate.../resources/ext.relatedArticles.readMore.bootstrap/index.js
Sam Smith 0fed50e266 Optionally disable Read More using extension data
By default, the Read More feature tries to use editor-curated articles
before using the CirrusSearch morelike: feature. Add a configuration
variable that disables the former behaviour but leave the default in
place.

Changes:

* Add the wgReadMoreOnlyUseCirrusSearch configuration variable, which
  defaults to false, and pass it in to
  mw.relatedArticles.RelatedPagesGateway at construction time
* Add the onlyUseCirrusSearch parameter to
  mw.relatedArticles.RelatedPagesGateway, which controls whether to
  ignore the editorCuratedArticles parameter

Bug: T117443
Change-Id: I0dfa67f4a68e8dc17302fef7ebf8d23c0c1d892c
2015-11-12 12:43:29 +00:00

33 lines
1,003 B
JavaScript

( function ( $ ) {
var config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 'wgMFMode', 'wgIsMainPage' ] ),
relatedPages = new mw.relatedArticles.RelatedPagesGateway(
new mw.Api(),
mw.config.get( 'wgPageName' ),
mw.config.get( 'wgRelatedArticles' ),
mw.config.get( 'wgRelatedArticlesUseCirrusSearch' ),
mw.config.get( 'wgRelatedArticlesOnlyUseCirrusSearch' )
),
LIMIT = 4;
if (
config.wgNamespaceNumber === 0 &&
!config.wgIsMainPage &&
config.skin === 'minerva' &&
config.wgMFMode === 'beta'
) {
$.when(
// Note we load dependencies here rather than ResourceLoader
// to avoid PHP exceptions when MobileFrontend not installed
// which should never happen given the if statement.
mw.loader.using( [ 'mobile.pagelist.scripts', 'ext.relatedArticles.readMore.minerva' ] ),
relatedPages.getForCurrentPage( LIMIT )
).done( function ( _, pages ) {
if ( pages.length ) {
mw.track( 'ext.relatedArticles.init', pages );
}
} );
}
}( jQuery ) );