From f8676483c1cd913d9788bc79f54e28d9c21bc79f Mon Sep 17 00:00:00 2001 From: Soreine Date: Mon, 6 Jun 2016 16:46:36 +0200 Subject: Default paths are relative to the current book --- lib/models/book.js | 33 +++++++++++++++++++++++++++------ 1 file 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; + } }; /** -- cgit v1.1