Compare commits

...

22 Commits

Author SHA1 Message Date
Samy Pessé d895c63211 Bump version to 2.1.0 2015-06-02 14:52:11 +02:00
Samy Pessé 8c86da67ca Update gitbook-parsers@0.7.6 2015-06-02 14:47:21 +02:00
Samy Pessé a9a230dfc3 Merge pull request #781 from GitbookIO/fix/775
Fix #775: add optional print.css style
2015-06-02 11:00:22 +02:00
Samy Pessé 6d53e52771 Handle empty string for styles configuration 2015-06-02 11:00:15 +02:00
Samy Pessé 52e10b7cfe Remove default print.css when styles/print.css is present 2015-06-02 10:23:31 +02:00
Samy Pessé addac85696 Add test for custom print style 2015-06-02 10:18:44 +02:00
Samy Pessé 13fb949d68 Merge pull request #774 from wilhelmmatilainen/patch-1
Styling should go to <head>, not to <body>
2015-05-30 18:11:15 +02:00
Wilhelm f1b593cfbd Styling should go to <head>, not to <body>
https://developers.google.com/speed/pagespeed/module/filter-css-to-head
2015-05-29 15:42:40 +03:00
Samy Pesse f998e2dec9 Bump version to 2.0.4 2015-05-28 18:07:20 +02:00
Samy Pesse 2c0bd53a91 Fix i18n used in multilingual book 2015-05-28 17:06:09 +02:00
Samy Pesse 6dd7f6162f Add title to languages chooser
Related to #757
2015-05-28 16:14:03 +02:00
Samy Pesse 475b0bb2b3 Adapt to nunjucks 1.3.x 2015-05-28 15:59:14 +02:00
Samy Pesse e6343935e3 Update nunjucks to fix raw tags 2015-05-28 15:50:46 +02:00
Samy Pessé 946883fd4c Merge pull request #772 from GitbookIO/feature/glossary_order
Fix #768: sort glossary, start with longest matchs
2015-05-28 15:21:03 +02:00
Samy Pessé b1b7e3148b Merge pull request #743 from chudaol/master
Added vk sharing button.
2015-05-28 14:54:03 +02:00
Samy Pesse 32203f6438 Sort glossary before applying it on pages 2015-05-28 14:49:53 +02:00
Samy Pesse f2d3c5d2ed Add test for #768 2015-05-28 14:38:21 +02:00
Samy Pessé 7e2f0ed4bc Merge pull request #758 from aschempp/hotfix/x-ua-compatible
Fix the X-UA-Compatible meta tag
2015-05-28 14:18:19 +02:00
Samy Pessé a877acf905 Merge pull request #759 from aschempp/hotfix/stylesheets
Move style sheets to the <head> section
2015-05-28 14:17:39 +02:00
Andreas Schempp 1a60778248 Move style sheets to the <head> section
see https://github.com/GitbookIO/gitbook/issues/756
2015-05-23 09:14:26 +02:00
Andreas Schempp cda4bb5bda Fix the X-UA-Compatible meta tag
see https://github.com/GitbookIO/gitbook/issues/755
2015-05-23 09:06:58 +02:00
Olga Filipova 7543781046 Added vk sharing button. 2015-05-12 22:30:09 +02:00
21 changed files with 111 additions and 33 deletions
+10
View File
@@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.1.0
- Fix error in calcul of `levels` in table of contents, error introduced a few versions ago
- Add optional `styles/print.css` to replace `print.css` used in ebook
## 2.0.4
- Fix `{% raw %}`, got confused with "fake" variable declarations
- Fix title of language chooser
- Fix the X-UA-Compatible meta tag
- Move style sheets to the <head> section
## 2.0.3
- Fix `gitbook init` for SUMMARY with empty entries
- Fix escaping of code blocks in markdown
+1
View File
@@ -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",
+1 -1
View File
@@ -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;
+7 -5
View File
@@ -4,8 +4,8 @@ var Q = require("q");
var _ = require("lodash");
var nunjucks = require("nunjucks");
var AutoEscapeExtension = require("nunjucks-autoescape");
var FilterExtension = require("nunjucks-filter");
var AutoEscapeExtension = require("nunjucks-autoescape")(nunjucks);
var FilterExtension = require("nunjucks-filter")(nunjucks);
var fs = require("../utils/fs");
var BaseGenerator = require("../generator");
@@ -50,12 +50,13 @@ Generator.prototype.prepareStyles = function() {
this.styles = _.chain(this.styles)
.map(function(style) {
var stylePath = that.options.styles[style];
if (fs.existsSync(path.resolve(that.book.root, stylePath))) {
return stylePath;
if (stylePath && fs.existsSync(path.resolve(that.book.root, stylePath))) {
return [style, stylePath];
}
return null;
})
.compact()
.object()
.value();
return Q();
@@ -100,7 +101,6 @@ Generator.prototype.prepareTemplateEngine = function() {
that.env.addFilter('lvl', function(lvl) {
return lvl.split(".").length;
});
that.env.addGlobal('__', that.book.i18n.bind(that.book));
// Add extension
that.env.addExtension('AutoEscapeExtension', new AutoEscapeExtension(that.env));
@@ -238,6 +238,8 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
basePath: ".",
staticBase: path.join(".", "gitbook"),
'__': that.book.i18n.bind(that.book)
}, options)
);
})
+5 -2
View File
@@ -237,13 +237,16 @@ function normalizeHtml(src, options) {
});
// Replace glossary terms
_.each(options.glossary, function(term) {
var glossary = _.sortBy(options.glossary, function(term) {
return -term.name.length;
});
_.each(glossary, function(term) {
var r = new RegExp( "\\b(" + pregQuote(term.name.toLowerCase()) + ")\\b" , 'gi' );
var includedInFiles = false;
$("*").each(function() {
// Ignore codeblocks
if (_.contains(["code", "pre"], this.name.toLowerCase())) return;
if (_.contains(["code", "pre", "a"], this.name.toLowerCase())) return;
replaceText($, this, r, function(match) {
// Add to files index in glossary
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "2.0.3",
"version": "2.1.0",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
@@ -12,10 +12,10 @@
"resolve": "0.6.3",
"fs-extra": "0.16.5",
"fstream-ignore": "1.0.2",
"gitbook-parsers": "0.7.5",
"nunjucks": "1.3.0",
"nunjucks-autoescape": "0.1.1",
"nunjucks-filter": "0.1.0",
"gitbook-parsers": "0.7.6",
"nunjucks": "mozilla/nunjucks#103513c294835bcbe64222de6db494e2555e294e",
"nunjucks-autoescape": "1.0.0",
"nunjucks-filter": "1.0.0",
"i18n": "0.5.0",
"semver": "2.2.1",
"npmi": "0.1.1",
+1 -1
View File
@@ -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) {
+4
View File
@@ -7,3 +7,7 @@ Just a simple and easy to understand test.
## hakunamatata
This word is not present in the content.
## test long
This is a test with a longer text that the first entry to test order.
+2
View File
@@ -6,3 +6,5 @@ The word test should be replaced by a glossary link.
But the word test should not be replaced in code blocks
```
The two words test long should be replaced by the correct glossary links.
+3
View File
@@ -0,0 +1,3 @@
# Readme
Default description for the book.
+1
View File
@@ -0,0 +1 @@
# Summary
+3
View File
@@ -0,0 +1,3 @@
body {
color: red;
}
+31
View File
@@ -21,4 +21,35 @@ describe('eBook generator', function () {
book.should.have.file("gitbook/style.css");
});
});
describe('Custom styles', function() {
var book;
before(function() {
return books.generate("style-print", "ebook")
.then(function(_book) {
book = _book;
});
});
it('should remove default print.css', function() {
var PAGE = fs.readFileSync(
path.join(book.options.output, "index.html"),
{ encoding: "utf-8" }
);
PAGE.should.be.html({
"link": {
count: 1,
attributes: {
href: "./styles/print.css"
}
}
});
});
it('should correctly print.css', function() {
book.should.have.file("styles");
book.should.have.file("styles/print.css");
});
})
});
+10 -1
View File
@@ -14,7 +14,7 @@ describe('Glossary', function () {
it('should correctly list items', function() {
book.should.have.property("glossary");
book.glossary.should.have.lengthOf(2);
book.glossary.should.have.lengthOf(3);
});
});
@@ -73,6 +73,15 @@ describe('Glossary', function () {
}
});
});
it('should correctly select the longest term', function() {
readme.should.be.html({
".page-inner a[href='GLOSSARY.html#test_long']": {
count: 1,
text: "test long"
}
});
});
});
});
});
+3
View File
@@ -16,6 +16,9 @@ define([
},
"instapaper": function($el) {
window.open("http://www.instapaper.com/text?u="+encodeURIComponent(location.href));
},
"vk": function($el) {
window.open("http://vkontakte.ru/share.php?url="+encodeURIComponent(location.href));
}
};
+7 -7
View File
@@ -1,8 +1,8 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" {% block htmlTag %}{% endblock %} {% if options.direction == "rtl" %}dir="rtl"{% endif %}>
{{ htmlSnippet("html:start")|default("")|safe }}
{{ htmlSnippet("html:start")|default("", true)|safe }}
<head>
{{ htmlSnippet("head:start")|default("")|safe }}
{{ htmlSnippet("head:start")|default("", true)|safe }}
<meta charset="UTF-8">
<title>{% block title %}{% endblock %}</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -11,14 +11,14 @@
{% 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 %}
{{ htmlSnippet("head:end")|default("")|safe }}
{% block style %}{% endblock %}
{{ htmlSnippet("head:end")|default("", true)|safe }}
</head>
<body>
{{ htmlSnippet("body:start")|default("")|safe }}
{% block style %}{% endblock %}
{{ htmlSnippet("body:start")|default("", true)|safe }}
{% block content %}{% endblock %}
{% block javascript %}{% endblock %}
{{ htmlSnippet("body:end")|default("")|safe }}
{{ htmlSnippet("body:end")|default("", true)|safe }}
</body>
{{ htmlSnippet("html:end")|default("")|safe }}
{{ htmlSnippet("html:end")|default("", true)|safe }}
</html>
+3 -1
View File
@@ -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 %}
@@ -54,6 +54,10 @@
{% if options.links.sharing.weibo == true %}
<a href="#" target="_blank" class="btn pull-right weibo-sharing-link sharing-link" data-sharing="weibo" aria-label="Weibo"><i class="fa fa-weibo"></i></a>
{% endif %}
{% if options.links.sharing.vk == true %}
<a href="#" target="_blank" class="btn pull-right vk-sharing-link sharing-link" data-sharing="vk" aria-label="VK"><i class="fa fa-vk"></i></a>
{% endif %}
<!-- Title -->
<h1>
+1 -1
View File
@@ -1,6 +1,6 @@
{% extends "./layout.html" %}
{% block title %}{{ title }}{% endblock %}
{% block title %}{{ __("LANGS_CHOOSE") }} | {{ title }}{% endblock %}
{% block style %}
<link rel="stylesheet" href="{{ staticBase }}/style.css">
+8 -8
View File
@@ -1,10 +1,10 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" {% if options.direction == "rtl" %}dir="rtl"{% endif %}>
{{ htmlSnippet("html:start")|default("")|safe }}
{{ htmlSnippet("html:start")|default("", true)|safe }}
<head>
{{ htmlSnippet("head:start")|default("")|safe }}
{{ htmlSnippet("head:start")|default("", true)|safe }}
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>{% block title %}{% endblock %}</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="{% block description %}{% endblock %}">
@@ -17,15 +17,15 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="{{ staticBase }}/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="{{ staticBase }}/images/favicon.ico" type="image/x-icon">
{% block style %}{% endblock %}
{% block head %}{% endblock %}
{{ htmlSnippet("head:end")|default("")|safe }}
{{ htmlSnippet("head:end")|default("", true)|safe }}
</head>
<body>
{{ htmlSnippet("body:start")|default("")|safe }}
{% block style %}{% endblock %}
{{ htmlSnippet("body:start")|default("", true)|safe }}
{% block content %}{% endblock %}
{% block javascript %}{% endblock %}
{{ htmlSnippet("body:end")|default("")|safe }}
{{ htmlSnippet("body:end")|default("", true)|safe }}
</body>
{{ htmlSnippet("html:end")|default("")|safe }}
{{ htmlSnippet("html:end")|default("", true)|safe }}
</html>
+1 -1
View File
@@ -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 %}