jenkins-bot has submitted this change and it was merged. Change subject: Add --no-compat option to avoid pediapress compatibility overhead. ......................................................................
Add --no-compat option to avoid pediapress compatibility overhead. Using the `--no-compat` option avoids resource fetches and bundle bloat which are used only for pediapress compatibility, not by any of the modern backends. Change-Id: I520837b0fdf838df405361bda2bfbf7507f7ac01 --- M bin/mw-ocg-bundler M lib/index.js M lib/siteinfo.js 3 files changed, 14 insertions(+), 9 deletions(-) Approvals: Cscott: Looks good to me, approved jenkins-bot: Verified diff --git a/bin/mw-ocg-bundler b/bin/mw-ocg-bundler index 2a58c5d..de3ffb2 100755 --- a/bin/mw-ocg-bundler +++ b/bin/mw-ocg-bundler @@ -30,6 +30,10 @@ 'Force the given maximum image dimension (in pixels)', null) .option('--title <title>', 'Set the title of the generated collection', null) + // set this to true to emit deprecated file formats for better pediapress + // compatibility + .option('--no-compat', + 'Omit redundant data used for backward-compatibility') .option('-v, --verbose', 'Print verbose progress information') .option('-D, --debug', @@ -84,6 +88,7 @@ output: program.directory || program.output, verbose: !!program.verbose, debug: !!program.debug, + compat: !!program.compat, parsoid: program.api, toc: program.toc, size: program.size diff --git a/lib/index.js b/lib/index.js index 93a0d5e..a8c8627 100644 --- a/lib/index.js +++ b/lib/index.js @@ -16,9 +16,6 @@ var Siteinfo = require('./siteinfo'); var StatusReporter = require('./status'); -// set this to true to emit deprecated file formats for better pediapress -// compatibility -var PEDIAPRESS_COMPAT = true; // set this to true to emit bundles which are more closely compatible // with the pediapress bundler (at the cost of poorer support for // interwiki collections) @@ -91,7 +88,8 @@ ); var parsoidDb = new Db(path.join(options.output, "parsoid.db")); - var htmlDb = new Db(path.join(options.output, "html.db")); + var htmlDb = options.compat ? + new Db(path.join(options.output, "html.db")) : null; var tasks = []; // a promise to parse a single item (from parsoid & php) @@ -114,9 +112,9 @@ key += item.revision; return parsoidDb.put(key, result.text); }).then(function() { - return html.fetch(item.wiki, item.title, item.revision, status); + return options.compat ? html.fetch(item.wiki, item.title, item.revision, status) : null; }).then(function(result) { - return htmlDb.put(key, result); + return options.compat ? htmlDb.put(key, result) : null; }).then(function() { status.report(null, util.format( '%s:%s [complete]', @@ -139,7 +137,7 @@ return when.all(tasks).then(function() { return parsoidDb.close(); }).then(function() { - return htmlDb.close(); + return options.compat ? htmlDb.close() : null; }); }; @@ -224,7 +222,7 @@ }); status.createStage(titles.length, 'Fetching wikitext'); return Revisions.fetchAndWrite( - metabook.wikis, titles, options.output, status, PEDIAPRESS_COMPAT + metabook.wikis, titles, options.output, status, options.compat ); }; @@ -238,6 +236,7 @@ { filename: 'metabook.json', data: metabook }, { filename: 'nfo.json', data: nfo } ], function(item) { + if (item.filename==='nfo.json' && !options.compat) { return; } return P.call(fs.writeFile, fs, path.join(options.output, item.filename), JSON.stringify(item.data), diff --git a/lib/siteinfo.js b/lib/siteinfo.js index 4ab2be7..bf31182 100644 --- a/lib/siteinfo.js +++ b/lib/siteinfo.js @@ -46,7 +46,8 @@ return this.fetch(wikis, wiki).then(function(siteinfo) { status.report(null, wikis[wiki].prefix + ' siteinfo'); // only write siteinfo.json for wiki 0 (backward compat) - var p = (wiki===0) ? writeSiteInfo(outdir, wiki, siteinfo) : + var p = (wiki===0 && options.compat) ? + writeSiteInfo(outdir, wiki, siteinfo) : when.resolve(); return p.then(function() { // write siteinfo.db, keyed on the baseURL for the wiki -- To view, visit https://gerrit.wikimedia.org/r/106719 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I520837b0fdf838df405361bda2bfbf7507f7ac01 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator/bundler Gerrit-Branch: master Gerrit-Owner: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits