jenkins-bot has submitted this change and it was merged. Change subject: Wrapper for page loader to choose one based on configuration ......................................................................
Wrapper for page loader to choose one based on configuration Change-Id: I4a0434b5c77f23fe16831799c19ed88de8dfd93b --- A server/pageloader/PageLoader.js 1 file changed, 54 insertions(+), 0 deletions(-) Approvals: Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/server/pageloader/PageLoader.js b/server/pageloader/PageLoader.js new file mode 100644 index 0000000..fe53526 --- /dev/null +++ b/server/pageloader/PageLoader.js @@ -0,0 +1,54 @@ +/** + * Loads html for pages to translate + * + * @file + * @copyright See AUTHORS.txt + * @license GPL-2.0+ + */ + +'use strict'; + +var config; + +try { + // TODO: Have an example configuration file. + config = require( __dirname + '/../config.js' ); +} catch ( e ) { + // TODO: define this configuration in betterway + config = { + pageloaderservice: 'parsoid', + parsoid: { + api: 'http://parsoid.wmflabs.org' + }, + mediawiki: { + api: 'http://en.wikipedia.org/w/api.php' + } + }; +} + +/** +/** + * @class ParsoidPageLoader + */ +function PageLoader( page ) { + this.page = page; +} + +PageLoader.prototype.load = function () { + var loader, promise, ParsoidPageLoader, MediaWikiApiPageLoader, title; + + title = this.page.split( '/' ).pop(); + if ( config.pageloaderservice === 'parsoid' ) { + ParsoidPageLoader = require( __dirname + '/ParsoidPageLoader.js' ).ParsoidPageLoader; + loader = new ParsoidPageLoader( config.parsoid.api, 'enwiki' ); //FIXME + promise = loader.load( title ); + } + if ( config.pageloaderservice === 'mediawiki' ) { + MediaWikiApiPageLoader = require( __dirname + '/MediaWikiApiPageLoader.js' ).MediaWikiApiPageLoader; + loader = new MediaWikiApiPageLoader( config.mediawiki.api ); + promise = loader.load( title ); + } + return promise; +}; + +module.exports.PageLoader = PageLoader; -- To view, visit https://gerrit.wikimedia.org/r/114693 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4a0434b5c77f23fe16831799c19ed88de8dfd93b Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: KartikMistry <kartik.mis...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits