From b61254dda64b686e09e896e146d081519ced87d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 7 Mar 2016 11:00:01 +0100 Subject: [PATCH] Add more deprecated api --- lib/book.js | 13 +++++++++++++ lib/output/base.js | 4 ++-- lib/output/website.js | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/book.js b/lib/book.js index e4616f9f7..1d3a0d289 100644 --- a/lib/book.js +++ b/lib/book.js @@ -100,6 +100,12 @@ function Book(opts) { var cfg = this.config.dump(); error.deprecateField(cfg, 'book', (this.output? this.output.name : null), '"options.generator" property is deprecated, use "output.name" instead'); + // options.generator + cfg.generator = this.output? this.output.name : null; + + // options.output + cfg.output = this.output? this.output.root() : null; + return cfg; } }); @@ -353,6 +359,13 @@ Book.prototype.isInLanguageBook = function(filename) { }); }; +// ----- DEPRECATED METHODS + +Book.prototype.contentLink = error.deprecateMethod(function(s) { + return this.output.toURL(s); +}, '.contentLink() is deprecated, use ".output.toURL()" instead'); + + // Initialize a book Book.init = function(fs, root, opts) { var book = new Book(_.extend(opts || {}, { diff --git a/lib/output/base.js b/lib/output/base.js index f10f015e4..9c2153de1 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -185,7 +185,7 @@ Output.prototype.onRelativeLink = function(currentPage, href) { href = currentPage.relative(href); // Replace .md by .html - href = this.outputUrl(href); + href = this.toURL(href); } return href; @@ -263,7 +263,7 @@ Output.prototype.outputPath = function(filename, ext) { // Filename for output // /test/index.html -> /test/ -Output.prototype.outputUrl = function(filename, ext) { +Output.prototype.toURL = function(filename, ext) { var href = this.outputPath(filename, ext); if (path.basename(href) == 'index.html' && this.opts.directoryIndex) { diff --git a/lib/output/website.js b/lib/output/website.js index 230af7182..ae3d7af45 100644 --- a/lib/output/website.js +++ b/lib/output/website.js @@ -117,7 +117,7 @@ WebsiteOutput.prototype.prepare = function() { // Transform a '.md' into a '.html' (README -> index) that.env.addFilter('contentURL', function(s) { - return location.normalize(that.outputUrl(s)); + return that.toURL(s); }); // Relase path to an asset