Mwalker has uploaded a new change for review.
https://gerrit.wikimedia.org/r/148611
Change subject: Render attribution page
......................................................................
Render attribution page
Change-Id: I4e6c3b6d92088fe1a600ddb35eed66abfa630327
---
M lib/index.js
1 file changed, 44 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator/latex_renderer
refs/changes/11/148611/1
diff --git a/lib/index.js b/lib/index.js
index 49b9ba9..f72d39a 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1289,7 +1289,7 @@
// record the final filename
pp = pp.then(function(info) {
imagemap.set(key, info.filename);
- });
+ } ).catch(function(err) {});
p = Promise.join(p, pp); // serialize completion
}).then(function() {
// wait for the queued image renames/conversions/etc.
@@ -1340,7 +1340,7 @@
// book or article?
var hasChapters =
metabook.items.some(function(it) { return it.type ===
'chapter'; });
- var singleItem = (!hasChapters) && metabook.items.length <= 1;
+ var singleItem = (!hasChapters) && metabook.items.length <= 2;
if (!singleItem) {
head = head.replace(/\]\{article\}/, ']{report}');
}
@@ -1448,6 +1448,48 @@
output.write('\\chapter{' + texEscape(item.title) + '}\n');
return P.forEachSeq(item.items, write.article);
};
+ write.attribution = function(item) {
+ console.assert(item.type === 'attribution');
+ status.report('Processing attribution');
+ if ('columns' in item && columns !== item.columns) {
+ columns = item.columns;
+ output.write(columns === 1 ? '\\onecolumn\n' :
'\\twocolumn\n');
+ }
+ var outfile = path.join(builddir, 'latex', 'attribution.tex');
+ var document;
+
+ output.write('\\input{' + outfile + '}\n');
+ return P.call(fs.readFile, fs, path.join(builddir, 'bundle',
item.file))
+ .then(function(fileContents) {
+ document = domino.createDocument(fileContents);
+ // We know the attribution is coming from the
zeroth wiki
+ return sidb.get(metabook.wikis[0].baseurl);
+ }).then(function(siteinfo) {
+ var attributionLanguage = siteinfo.general.lang
|| collectionLanguage;
+ var collectionDir =
Polyglossia.lookup(collectionLanguage).dir;
+ var format = new Formatter(
+ fs.createWriteStream(outfile, {
encoding: 'utf8' }), {
+ dir: collectionDir
+ });
+ var visitor = new Visitor(document, format, {
+ base: '',
+ imagemap: imagemap,
+ singleItem: singleItem,
+ hasChapters: hasChapters,
+ lang: collectionLanguage,
+ dir: collectionDir
+ });
+ document.body.lang = document.body.lang ||
attributionLanguage;
+ document.body.dir = document.body.dir ||
+
Polyglossia.lookup(document.body.lang).dir;
+ visitor.visit(document.body);
+ visitor.usedLanguages.forEach(function(l){
usedLanguages.add(l); });
+ format.paragraphBreak();
+ return format.flush().then(function() {
+ return P.call(format.stream.end,
format.stream, '');
+ });
+ });
+ };
return P.forEachSeq(metabook.items, function(item) {
return write[item.type](item);
--
To view, visit https://gerrit.wikimedia.org/r/148611
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e6c3b6d92088fe1a600ddb35eed66abfa630327
Gerrit-PatchSet: 1
Gerrit-Project:
mediawiki/extensions/Collection/OfflineContentGenerator/latex_renderer
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits