summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-06-08 00:11:50 +0200
committerSamy Pessé <samypesse@gmail.com>2014-06-08 00:11:50 +0200
commitd1c1277bb9af3e4f5770a7e8c448211d631760cf (patch)
treecadb843b614a6b490345ff81fc613aeb705dc550
parent9a66f56c79fb7e589b9f0b56087d5f8ba956c934 (diff)
downloadgitbook-d1c1277bb9af3e4f5770a7e8c448211d631760cf.zip
gitbook-d1c1277bb9af3e4f5770a7e8c448211d631760cf.tar.gz
gitbook-d1c1277bb9af3e4f5770a7e8c448211d631760cf.tar.bz2
Fix cover picture for multilangs book convertion to ebook
-rw-r--r--lib/generate/generator.js22
-rw-r--r--lib/generate/index.js4
-rw-r--r--lib/generate/page/index.js5
-rw-r--r--lib/generate/site/index.js6
4 files changed, 34 insertions, 3 deletions
diff --git a/lib/generate/generator.js b/lib/generate/generator.js
index 2c4cb44..18d6066 100644
--- a/lib/generate/generator.js
+++ b/lib/generate/generator.js
@@ -45,6 +45,28 @@ BaseGenerator.prototype.transferFolder = function(input) {
);
};
+BaseGenerator.prototype.copyCover = function() {
+ var that = this;
+
+ return Q.all([
+ fs.copy(path.join(this.options.input, "cover.jpg"), path.join(this.options.output, "cover.jpg")),
+ fs.copy(path.join(this.options.input, "cover_small.jpg"), path.join(this.options.output, "cover_small.jpg"))
+ ])
+ .fail(function() {
+ // If orignally from multi-lang, try copy from originalInput
+ if (!that.options.originalInput) return;
+
+ return Q.all([
+ fs.copy(path.join(that.options.originalInput, "cover.jpg"), path.join(that.options.output, "cover.jpg")),
+ fs.copy(path.join(that.options.originalInput, "cover_small.jpg"), path.join(that.options.output, "cover_small.jpg"))
+ ]);
+ })
+ .fail(function(err) {
+ console.log(err);
+ return Q();
+ });
+};
+
BaseGenerator.prototype.langsIndex = function(langs) {
return Q.reject(new Error("Langs index is not supported in this generator"));
};
diff --git a/lib/generate/index.js b/lib/generate/index.js
index ede2c60..740f6ba 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -161,7 +161,9 @@ var generateMultiLang = function(options) {
return prev.then(function() {
return generate(_.extend({}, options, {
input: path.join(options.input, entry.path),
- output: path.join(options.output, entry.path)
+ output: path.join(options.output, entry.path),
+ originalInput: options.input,
+ originalOutput: options.output
}));
})
}, Q());
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index 68fd334..bd9b233 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -75,6 +75,11 @@ Generator.prototype.finish = function() {
}, output);
})
+ // Copy cover
+ .then(function() {
+ return that.copyCover();
+ })
+
// Copy assets
.then(function() {
return fs.copy(
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 51f8cae..b59c01c 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -188,7 +188,7 @@ Generator.prototype.copyAssets = function() {
path.join(that.options.output, "gitbook")
)
- // Add to cach manifest
+ // Add to cache manifest
.then(function() {
return that.manifest.addFolder(path.join(that.options.output, "gitbook"), "gitbook");
})
@@ -227,7 +227,9 @@ Generator.prototype.writeCacheManifest = function() {
};
Generator.prototype.finish = function() {
- var deferred = this.copyAssets().then(this.writeSearchIndex);
+ var deferred = this.copyAssets()
+ .then(this.copyCover)
+ .then(this.writeSearchIndex);
if (this.options.cache !== false) {
deferred = deferred.then(this.writeCacheManifest);