summaryrefslogtreecommitdiffstats
path: root/lib/output
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output')
-rw-r--r--lib/output/base.js5
-rw-r--r--lib/output/folder.js12
-rw-r--r--lib/output/website/index.js8
3 files changed, 20 insertions, 5 deletions
diff --git a/lib/output/base.js b/lib/output/base.js
index 39e46c2..d301b14 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -100,6 +100,11 @@ Output.prototype.onRelativeLink = function(currentPage, href) {
return href;
};
+// Output a SVG as a file
+Output.prototype.onOutputSVG = function(page, svg) {
+ return null;
+};
+
// Finish the generation
Output.prototype.finish = function() {
diff --git a/lib/output/folder.js b/lib/output/folder.js
index 96ea443..7e6ddf0 100644
--- a/lib/output/folder.js
+++ b/lib/output/folder.js
@@ -5,10 +5,11 @@ var path = require('path');
var Output = require('./base');
var fs = require('../utils/fs');
var pathUtil = require('../utils/path');
+var imagesUtil = require('../utils/images');
var Promise = require('../utils/promise');
/*
-This output require the native fs module to output
+This output requires the native fs module to output
book as a directory (mapping assets and pages)
*/
@@ -25,6 +26,15 @@ FolderOutput.prototype.onAsset = function(filename) {
);
};
+// Output a SVG as a file
+Output.prototype.onOutputSVG = function(page, svg) {
+ this.log.debug.ln('output svg from', page.path);
+ var filename = _.uniqueId('svg_') + '.png';
+
+ return imagesUtil.convertSVGBufferToPNG(svg, this.resolve(filename))
+ .thenResolve('/' + filename);
+};
+
// Prepare the generation by creating the output folder
FolderOutput.prototype.prepare = function() {
return fs.mkdirp(this.root());
diff --git a/lib/output/website/index.js b/lib/output/website/index.js
index 35e81c2..e60dae2 100644
--- a/lib/output/website/index.js
+++ b/lib/output/website/index.js
@@ -1,13 +1,13 @@
var util = require('util');
-var Output = require('../base');
+var FolderOutput = require('../base');
function WebsiteOutput() {
- Output.apply(this, arguments);
+ FolderOutput.apply(this, arguments);
}
-util.inherits(WebsiteOutput, Output);
+util.inherits(WebsiteOutput, FolderOutput);
// Write a page (parsable file)
-WebsiteOutput.prototype.writePage = function(page) {
+WebsiteOutput.prototype.onPage = function(page) {
};