diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-14 22:31:36 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-14 22:31:36 +0100 |
commit | 9467cda131d17ed0e0554929657f0f4acbd2fcd8 (patch) | |
tree | 30d8710c9715728a393a88f1ae91db79a651a1fa | |
parent | 3382f1b0840a7759508357acf88d770f2c5bcaf2 (diff) | |
download | gitbook-9467cda131d17ed0e0554929657f0f4acbd2fcd8.zip gitbook-9467cda131d17ed0e0554929657f0f4acbd2fcd8.tar.gz gitbook-9467cda131d17ed0e0554929657f0f4acbd2fcd8.tar.bz2 |
Apply styles to ebook output
-rw-r--r-- | lib/generate/ebook/index.js | 11 | ||||
-rw-r--r-- | lib/generate/page/index.js | 1 | ||||
-rw-r--r-- | theme/templates/ebook/glossary.html | 2 | ||||
-rw-r--r-- | theme/templates/ebook/page.html | 19 | ||||
-rw-r--r-- | 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 4ecccec..c74ffcd 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 c5f9420..8054fe6 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 8076c4d..ce10c63 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 9ce7c1b..3af7970 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 %} -<link rel="stylesheet" href="{{ staticBase }}/print.css"> -{% for resource in plugins.resources.css %} - {% if resource.url %} - <link rel="stylesheet" href="{{ resource.url }}"> - {% else %} - <link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}"> - {% endif %} -{% endfor %} + <link rel="stylesheet" href="{{ staticBase }}/print.css"> + {% for resource in plugins.resources.css %} + {% if resource.url %} + <link rel="stylesheet" href="{{ resource.url }}"> + {% else %} + <link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}"> + {% endif %} + {% endfor %} + {% for style in styles %} + <link rel="stylesheet" href="{{ basePath }}/{{ style }}"> + {% endfor %} {% endblock %} {% block content %} diff --git a/theme/templates/ebook/summary.html b/theme/templates/ebook/summary.html index dfbba2c..ab4b78f 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 %} -<link rel="stylesheet" href="{{ staticBase }}/print.css"> -{% for resource in plugins.resources.css %} - {% if resource.url %} - <link rel="stylesheet" href="{{ resource.url }}"> - {% else %} - <link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}"> - {% endif %} -{% endfor %} -{% endblock %} - {% macro articles(_articles) %} {% for item in _articles %} {% set externalLink = item.path|isExternalLink %} |