summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-21 18:08:36 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-21 18:08:36 +0100
commit5f058f2ceb77490cbbeaa56523e128e0a46a0dea (patch)
tree38affeed096afadf4b44f6d109ca34806b8f17f4
parent360381dd9f90a785e1ac7e8c5649215ba6220e2b (diff)
downloadgitbook-5f058f2ceb77490cbbeaa56523e128e0a46a0dea.zip
gitbook-5f058f2ceb77490cbbeaa56523e128e0a46a0dea.tar.gz
gitbook-5f058f2ceb77490cbbeaa56523e128e0a46a0dea.tar.bz2
Disable directoryIndex for ebook generation
-rw-r--r--lib/output/base.js4
-rw-r--r--lib/output/ebook.js3
-rw-r--r--lib/output/website.js6
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/output/base.js b/lib/output/base.js
index 828a11e..cc4eb8d 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -19,7 +19,7 @@ function Output(book, opts) {
_.bindAll(this);
this.opts = _.defaults(opts || {}, {
-
+ directoryIndex: true
});
this.book = book;
@@ -222,7 +222,7 @@ Output.prototype.outputPath = function(filename, ext) {
Output.prototype.outputUrl = function(filename, ext) {
var href = this.outputPath(filename, ext);
- if (path.basename(href) == 'index.html') {
+ if (path.basename(href) == 'index.html' && this.opts.directoryIndex) {
href = path.dirname(href) + '/';
}
diff --git a/lib/output/ebook.js b/lib/output/ebook.js
index ce83cef..6d531f8 100644
--- a/lib/output/ebook.js
+++ b/lib/output/ebook.js
@@ -10,6 +10,9 @@ var assetsInliner = require('./assets-inliner');
function _EbookOutput() {
WebsiteOutput.apply(this, arguments);
+
+ // ebook-convert does not support link like "./"
+ this.opts.directoryIndex = false;
}
util.inherits(_EbookOutput, WebsiteOutput);
diff --git a/lib/output/website.js b/lib/output/website.js
index 32647f6..01021e5 100644
--- a/lib/output/website.js
+++ b/lib/output/website.js
@@ -103,8 +103,10 @@ WebsiteOutput.prototype.prepare = function() {
// Relase path to an asset
that.env.addFilter('resolveAsset', function(href) {
- href = path.join('/gitbook', href);
- return that.resolveForPage(this.ctx.file.path, href);
+ href = path.join('gitbook', href);
+ if (!this.ctx.file) return href;
+
+ return that.resolveForPage(this.ctx.file.path, '/' + href);
});
})