From 9467cda131d17ed0e0554929657f0f4acbd2fcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 14 Jan 2015 22:31:36 +0100 Subject: [PATCH] Apply styles to ebook output --- lib/generate/ebook/index.js | 11 ++++++++--- lib/generate/page/index.js | 1 + theme/templates/ebook/glossary.html | 2 +- theme/templates/ebook/page.html | 19 +++++++++++-------- theme/templates/ebook/summary.html | 13 +------------ 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/generate/ebook/index.js b/lib/generate/ebook/index.js index 4ecccec1f..c74ffcd57 100644 --- a/lib/generate/ebook/index.js +++ b/lib/generate/ebook/index.js @@ -11,6 +11,12 @@ var stringUtils = require("../../utils/string"); var Generator = function() { BaseGenerator.apply(this, arguments); + + // eBook format + this.ebookFormat = this.options.extension || path.extname(this.options.output).replace("\.", "") || "pdf"; + + // Styles to use + this.styles = ["ebook", this.ebookFormat]; }; util.inherits(Generator, BaseGenerator); @@ -20,7 +26,6 @@ Generator.prototype.finish = function() { return BaseGenerator.prototype.finish.apply(this) .then(function() { var d = Q.defer(); - var format = that.options.extension || path.extname(that.options.output).replace("\.", "") || "pdf"; if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) { that.options.cover = path.join(that.options.output, "cover.jpg"); @@ -44,7 +49,7 @@ Generator.prototype.finish = function() { "--breadth-first": true }; - if (format == "pdf") { + if (that.ebookFormat == "pdf") { var pdfOptions = that.options.pdf; _.extend(_options, { @@ -64,7 +69,7 @@ Generator.prototype.finish = function() { var command = [ "ebook-convert", path.join(that.options.output, "SUMMARY.html"), - path.join(that.options.output, "index."+format), + path.join(that.options.output, "index."+that.ebookFormat), stringUtils.optionsToShellArgs(_options) ].join(" "); diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js index c5f94200e..8054fe69a 100644 --- a/lib/generate/page/index.js +++ b/lib/generate/page/index.js @@ -11,6 +11,7 @@ var BaseGenerator = require("../site"); var Generator = function() { BaseGenerator.apply(this, arguments); + // Styles to use this.styles = ["ebook"]; // Base for assets in plugins diff --git a/theme/templates/ebook/glossary.html b/theme/templates/ebook/glossary.html index 8076c4d8c..ce10c637f 100644 --- a/theme/templates/ebook/glossary.html +++ b/theme/templates/ebook/glossary.html @@ -1,4 +1,4 @@ -{% extends "./layout.html" %} +{% extends "./page.html" %} {% block title %}Glossary | {{ title }}{% endblock %} diff --git a/theme/templates/ebook/page.html b/theme/templates/ebook/page.html index 9ce7c1b54..3af7970cb 100644 --- a/theme/templates/ebook/page.html +++ b/theme/templates/ebook/page.html @@ -3,14 +3,17 @@ {% block title %}{{ progress.current.title }} | {{ title }}{% endblock %} {% block style %} - -{% for resource in plugins.resources.css %} - {% if resource.url %} - - {% else %} - - {% endif %} -{% endfor %} + + {% for resource in plugins.resources.css %} + {% if resource.url %} + + {% else %} + + {% endif %} + {% endfor %} + {% for style in styles %} + + {% endfor %} {% endblock %} {% block content %} diff --git a/theme/templates/ebook/summary.html b/theme/templates/ebook/summary.html index dfbba2cdc..ab4b78fb1 100644 --- a/theme/templates/ebook/summary.html +++ b/theme/templates/ebook/summary.html @@ -1,18 +1,7 @@ -{% extends "./layout.html" %} +{% extends "./page.html" %} {% block title %}Table of Contents | {{ title }}{% endblock %} -{% block style %} - -{% for resource in plugins.resources.css %} - {% if resource.url %} - - {% else %} - - {% endif %} -{% endfor %} -{% endblock %} - {% macro articles(_articles) %} {% for item in _articles %} {% set externalLink = item.path|isExternalLink %}