summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-06-02 10:23:31 +0200
committerSamy Pessé <samypesse@gmail.com>2015-06-02 10:23:31 +0200
commit52e10b7cfe9c79eb3b8d2a6a5d9540f46d6914df (patch)
tree206083b7aa2a4285e0c059dc4fab4449c0607930
parentaddac85696aa836f504993b5536b3ecbf7c124c5 (diff)
downloadgitbook-52e10b7cfe9c79eb3b8d2a6a5d9540f46d6914df.zip
gitbook-52e10b7cfe9c79eb3b8d2a6a5d9540f46d6914df.tar.gz
gitbook-52e10b7cfe9c79eb3b8d2a6a5d9540f46d6914df.tar.bz2
Remove default print.css when styles/print.css is present
-rw-r--r--lib/configuration.js1
-rw-r--r--lib/generators/ebook.js2
-rw-r--r--lib/generators/website.js3
-rw-r--r--test/assertions.js2
-rw-r--r--theme/templates/ebook/layout.html2
-rw-r--r--theme/templates/ebook/page.html4
-rw-r--r--theme/templates/website/page.html2
7 files changed, 10 insertions, 6 deletions
diff --git a/lib/configuration.js b/lib/configuration.js
index d206505..29776bd 100644
--- a/lib/configuration.js
+++ b/lib/configuration.js
@@ -186,6 +186,7 @@ Configuration.DEFAULT = {
// CSS Styles
"styles": {
"website": "styles/website.css",
+ "print": "styles/print.css",
"ebook": "styles/ebook.css",
"pdf": "styles/pdf.css",
"mobi": "styles/mobi.css",
diff --git a/lib/generators/ebook.js b/lib/generators/ebook.js
index 0bad35a..cff9ef6 100644
--- a/lib/generators/ebook.js
+++ b/lib/generators/ebook.js
@@ -18,7 +18,7 @@ var Generator = function(book, format) {
this.namespace = "ebook";
// Styles to use
- this.styles = _.compact(["ebook", this.ebookFormat]);
+ this.styles = _.compact(["print", "ebook", this.ebookFormat]);
// Convert images (svg -> png)
this.convertImages = true;
diff --git a/lib/generators/website.js b/lib/generators/website.js
index 8d1a3c5..a671ca7 100644
--- a/lib/generators/website.js
+++ b/lib/generators/website.js
@@ -51,11 +51,12 @@ Generator.prototype.prepareStyles = function() {
.map(function(style) {
var stylePath = that.options.styles[style];
if (fs.existsSync(path.resolve(that.book.root, stylePath))) {
- return stylePath;
+ return [style, stylePath];
}
return null;
})
.compact()
+ .object()
.value();
return Q();
diff --git a/test/assertions.js b/test/assertions.js
index d807d4d..7a34380 100644
--- a/test/assertions.js
+++ b/test/assertions.js
@@ -35,7 +35,7 @@ should.Assertion.add('html', function(rules, description) {
var $el = $(query);
// Test number of elements
- $el.should.have.lengthOf(validations.count);
+ $el.length.should.be.equal(validations.count);
// Test text
if (validations.text !== undefined) {
diff --git a/theme/templates/ebook/layout.html b/theme/templates/ebook/layout.html
index c2501b6..982618f 100644
--- a/theme/templates/ebook/layout.html
+++ b/theme/templates/ebook/layout.html
@@ -11,11 +11,11 @@
{% if options.author %}<meta name="author" content="{{ options.author }}">{% endif %}
{% if options.isbn %}<meta name="identifier" content="{{ options.isbn }}" scheme="ISBN">{% endif %}
{% block head %}{% endblock %}
+ {% block style %}{% endblock %}
{{ htmlSnippet("head:end")|default("", true)|safe }}
</head>
<body>
{{ htmlSnippet("body:start")|default("", true)|safe }}
- {% block style %}{% endblock %}
{% block content %}{% endblock %}
{% block javascript %}{% endblock %}
{{ htmlSnippet("body:end")|default("", true)|safe }}
diff --git a/theme/templates/ebook/page.html b/theme/templates/ebook/page.html
index 0951c27..f207184 100644
--- a/theme/templates/ebook/page.html
+++ b/theme/templates/ebook/page.html
@@ -3,7 +3,9 @@
{% block title %}{{ progress.current.title }} | {{ title }}{% endblock %}
{% block style %}
+ {% if not styles.print %}
<link rel="stylesheet" href="{{ staticBase }}/print.css">
+ {% endif %}
{% for resource in plugins.resources.css %}
{% if resource.url %}
<link rel="stylesheet" href="{{ resource.url }}">
@@ -11,7 +13,7 @@
<link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}">
{% endif %}
{% endfor %}
- {% for style in styles %}
+ {% for type, style in styles %}
<link rel="stylesheet" href="{{ basePath }}/{{ style }}">
{% endfor %}
{% endblock %}
diff --git a/theme/templates/website/page.html b/theme/templates/website/page.html
index 37fc9dd..7f424e1 100644
--- a/theme/templates/website/page.html
+++ b/theme/templates/website/page.html
@@ -70,7 +70,7 @@ require(["gitbook"], function(gitbook) {
<link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}">
{% endif %}
{% endfor %}
- {% for style in styles %}
+ {% for type, style in styles %}
<link rel="stylesheet" href="{{ basePath }}/{{ style }}">
{% endfor %}
{% endblock %}