diff options
author | Soreine <nicolas@gitbook.com> | 2016-06-06 16:46:36 +0200 |
---|---|---|
committer | Soreine <nicolas@gitbook.com> | 2016-06-06 16:55:00 +0200 |
commit | f8676483c1cd913d9788bc79f54e28d9c21bc79f (patch) | |
tree | ef3bce92db2fc4892df169956c7c947cc0c34e99 /lib/models | |
parent | c79a6f2fba8203c93b4adc6332750445c6bae9ea (diff) | |
download | gitbook-f8676483c1cd913d9788bc79f54e28d9c21bc79f.zip gitbook-f8676483c1cd913d9788bc79f54e28d9c21bc79f.tar.gz gitbook-f8676483c1cd913d9788bc79f54e28d9c21bc79f.tar.bz2 |
Default paths are relative to the current book
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/book.js | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lib/models/book.js b/lib/models/book.js index fed66f9..f774ee8 100644 --- a/lib/models/book.js +++ b/lib/models/book.js @@ -293,26 +293,47 @@ Book.prototype.getDefaultExt = function() { /** Infer the default path for a Readme. + @param {Boolean} [absolute=false] False for a path relative to + this book's content root @return {String} */ -Book.prototype.getDefaultReadmePath = function() { - return this.getContentRoot()+'README'+this.getDefaultExt(); +Book.prototype.getDefaultReadmePath = function(absolute) { + var defaultPath = 'README'+this.getDefaultExt(); + if (absolute) { + return path.join(this.getContentRoot(), defaultPath); + } else { + return defaultPath; + } }; /** Infer the default path for a Summary. + @param {Boolean} [absolute=false] False for a path relative to + this book's content root @return {String} */ -Book.prototype.getDefaultSummaryPath = function() { - return this.getContentRoot()+'SUMMARY'+this.getDefaultExt(); +Book.prototype.getDefaultSummaryPath = function(absolute) { + var defaultPath = 'SUMMARY'+this.getDefaultExt(); + if (absolute) { + return path.join(this.getContentRoot(), defaultPath); + } else { + return defaultPath; + } }; /** Infer the default path for a Glossary. + @param {Boolean} [absolute=false] False for a path relative to + this book's content root @return {String} */ -Book.prototype.getDefaultGlossaryPath = function() { - return this.getContentRoot()+'GLOSSARY'+this.getDefaultExt(); +Book.prototype.getDefaultGlossaryPath = function(absolute) { + var defaultPath = 'GLOSSARY'+this.getDefaultExt(); + if (absolute) { + return path.join(this.getContentRoot(), defaultPath); + } else { + return defaultPath; + } }; /** |