Compare commits

...

33 Commits

Author SHA1 Message Date
Samy Pessé 4a9adb9440 Bump version to 2.0.0-alpha.6 2015-02-06 19:42:55 +01:00
Samy Pessé d8898b7a1f Add changelog for version 2.0.0-alpha.* 2015-02-06 15:54:40 +01:00
Samy Pessé bb7e081a37 Fix #588: Fix replacement of glossary terms by links 2015-02-06 15:28:53 +01:00
Samy Pessé c3ffa5e0ef Add test for glossary replacement #588 2015-02-06 15:07:01 +01:00
Samy Pessé 724bc2b59c Add capital to german translation of share links 2015-02-06 15:00:13 +01:00
Samy Pessé 178d2e2a48 Add @RyanOM as spanish translator 2015-02-06 14:35:23 +01:00
Samy Pessé 4d710c129c Merge pull request #590 from RyanOM/patch-2
Created es.json
2015-02-06 14:34:25 +01:00
RyanOM e4dbf62c0f Create es.json 2015-02-06 11:33:26 -02:00
Samy Pessé b0cd23fd34 Add @RyanOM as a translator 2015-02-06 14:32:20 +01:00
Samy Pessé af5764bc3b Merge pull request #589 from RyanOM/patch-1
Create pt.json
2015-02-06 14:29:31 +01:00
RyanOM 6309da1214 Create pt.json 2015-02-06 11:21:22 -02:00
Samy Pessé 38c9bfa357 Fix dom-serializer dependency 2015-02-05 21:10:17 +01:00
Samy Pessé f194cb513c Merge pull request #586 from ludovicofischer/version/2.0
Use tiny-lr instead of old unmaintained fork.
2015-02-05 20:50:02 +01:00
Ludovico Fischer 03ff892727 Use tiny-lr instead of old unmaintained fork. 2015-02-05 19:43:29 +01:00
Samy Pessé 8cc0f64f54 Handle SVG correctly in page normalization
Related to mathjax/MathJax-node#65
2015-02-05 17:36:44 +01:00
Samy Pessé 532e8b0388 Bump version to 2.0.0-alpha.5 2015-02-05 13:56:52 +01:00
Samy Pessé 35b3d50012 Add "finish:before" to the list of valid hooks 2015-02-05 13:56:43 +01:00
Samy Pessé 72ff9996ce Update fs-extra to fix fs.copy issue 2015-02-05 13:51:53 +01:00
Samy Pessé 0759c4dd78 Bump version to 2.0.0-alpha.4 2015-02-04 20:49:09 +01:00
Samy Pessé 82a1a151e4 Correctly copy cover for sub books 2015-02-04 20:29:49 +01:00
Samy Pessé ff6e8387fb Bump version to 2.0.0-alpha.3 2015-02-04 18:31:26 +01:00
Samy Pessé f71601e8d3 Fix generation of multilingual books as ebook 2015-02-04 18:31:07 +01:00
Samy Pessé 234a37726f Improve logs for images and ebook copy 2015-02-04 16:54:02 +01:00
Samy Pessé 65a7979874 Load plugins from the book in priority 2015-02-04 15:25:40 +01:00
Samy Pessé 6a00bf0fc0 Remove plugin list 2015-02-04 11:54:52 +01:00
Samy Pessé 853f3d6482 Add translators on AUTHORS.md
@gbonanome, @kmelve, @AndreyAkinshin, @winniehell
2015-02-04 11:52:00 +01:00
Samy Pessé 27de7cd914 Merge pull request #582 from kmelve/version/2.0
Added Norwegian translation
2015-02-04 11:42:46 +01:00
Knut Melvær 2318cae1e6 Added Norwegian translation 2015-02-04 11:39:40 +01:00
Samy Pessé cb313c0fab Bump version to 2.0.0-alpha.2 2015-02-04 10:02:51 +01:00
Samy Pessé 4f25056017 Update gitbook-parsers@0.3.1 2015-02-03 14:34:20 +01:00
Samy Pessé 5baebb8754 Set "info" as default log level 2015-02-03 10:53:33 +01:00
Samy Pessé 1eea994e73 Fix init command 2015-02-03 10:52:39 +01:00
Samy Pessé 8a597ff3f1 Fix installation instruction 2015-02-03 10:40:22 +01:00
16 changed files with 197 additions and 71 deletions
+22 -4
View File
@@ -7,12 +7,30 @@ Names below are ordered by first contribution.
Author
------
- Samy Pessé <samypesse@gmail.com>
- Aaron O'Mullan <aaron.omullan@gmail.com>
- Samy Pessé <samypesse@gmail.com> (@SamyPesse)
- Aaron O'Mullan <aaron.omullan@gmail.com> (@AaronO)
Contributors
------------
- Nijiko Yonskai
- Herman Starikov
- Nijiko Yonskai (@Nijikokun)
- Herman Starikov (@Hermanya)
Translators
------------
- German
- Winnie (@winniehell)
- Italian
- Giulio Bonanome (@gbonanome)
- Russian
- Andrey Akinshin (@AndreyAkinshin)
- Norwegian
- Knut Melvær (@kmelve)
- Portuguese
- Ryan O'Mullan (@RyanOM)
- Spanish
- Ryan O'Mullan (@RyanOM)
- French
- Samy Pessé (@SamyPesse)
+35
View File
@@ -1,5 +1,40 @@
# Release notes
## 2.0.0-alpha.6
- Add es and pt translations
- Fix replacement of glossary terms
## 2.0.0-alpha.5
- Fix copy of files/covers
- Add back `finish:before` hook
## 2.0.0-alpha.4
- Fix copy of cover for multilingal books
## 2.0.0-alpha.3
- Norwegian translation
- Load plugins from book in priority
## 2.0.0-alpha.3
- Fix init command
- Update parsers to fix spaces in summary (`gitbook-parsers@0.3.1`)
## 2.0.0-alpha.1
- Externalize parsing into `gitbook-parsers` module
- Supports AsciiDoc and reStructuredText
- Hooks for page (`page:*`) are now deprecated, plugins should extend filters and blocks instead
- Hooks `summary` and `glossary` (after and before) have been removed
- Exercises and Quizzes are no longer parsed in the markdown parser
- Support for more markdown extensions: `.markdown`, `.mdown`
- Templates are rendered with nunjucks instead of swig, syntax is almost compatible, there is some changes with contexts and filters. `{{ super() }}` should be use instead of `{% parent %}`
- Clean output folder on build without removing `.git` and `.svn`
- MathJAX is no longer a default plugin
- SVG images are converted to PNG during generation of ebooks
- i18n in website and ebook (ru, it, de, fr)
- New templating syntax
- Content references (both internal and external)
- Glossary terms are handled during generation (also in ebook format)
## 1.5.0
- Fix `serve` command, broken by `1.4.2`
- Add nicer `dark` theme :)
+4 -31
View File
@@ -15,10 +15,11 @@ GitBook is a command line tool (and Node.js library) for building beautiful book
GitBook can be installed from **NPM** using:
```
$ npm install gitbook -g
$ npm install gitbook-cli -g
```
Create the directories and files for a book from its [SUMMARY.md](https://github.com/GitbookIO/gitbook#book-format) file using
Create the directories and files for a book from its [SUMMARY.md](https://github.com/GitbookIO/gitbook#book-format) file (if existing) using
```
$ gitbook init
```
@@ -198,36 +199,8 @@ The platform [GitBook.com](https://www.gitbook.com/) is like an "Heroku for book
Plugins can be used to extend your book's functionality. Read [GitbookIO/plugin](https://github.com/GitbookIO/plugin) for more information about how to build a plugin for GitBook.
Plugins needed to build a book can be installed using: `gitbook install ./`.
Plugins needed to build a book can be installed using: `gitbook install ./`. You can find plugins at [plugins.gitbook.com](plugins.gitbook.com).
##### Official plugins:
| Name | Description |
| ----- | ---- |
| [exercises](https://github.com/GitbookIO/plugin-exercises) | Add interactive exercises to your book. |
| [quizzes](https://github.com/GitbookIO/plugin-quizzes) | Add interactive quizzes to your book. |
| [mathjax](https://github.com/GitbookIO/plugin-mathjax) | Displays mathematical notation in the book. |
| [mixpanel](https://github.com/GitbookIO/plugin-mixpanel) | Mixpanel tracking for your book |
| [infinitescroll](https://github.com/GitbookIO/gitbook-plugin-infinitescroll) | Infinite Scrolling |
##### Other plugins:
| Name | Description |
| ----- | ---- |
| [Google Analytics](https://github.com/GitbookIO/plugin-ga) | Google Analytics tracking for your book |
| [Disqus](https://github.com/GitbookIO/plugin-disqus) | Disqus comments integration in your book |
| [Autocover](https://github.com/GitbookIO/plugin-autocover) | Generate a cover for your book |
| [Transform annoted quotes to notes](https://github.com/erixtekila/gitbook-plugin-richquotes) | Allow extra markdown markup to render blockquotes as nice notes |
| [Send code to console](https://github.com/erixtekila/gitbook-plugin-toconsole) | Evaluate javascript block in the browser inspector's console |
| [Revealable sections](https://github.com/mrpotes/gitbook-plugin-reveal) | Reveal sections of the page using buttons made from the first title in each section |
| [Markdown within HTML](https://github.com/mrpotes/gitbook-plugin-nestedmd) | Process markdown within HTML blocks - allows custom layout options for individual pages |
| [Bootstrap JavaScript plugins](https://github.com/mrpotes/gitbook-plugin-bootstrapjs) | Use the [Bootstrap JavaScript plugins](http://getbootstrap.com/javascript) in your online GitBook |
| [Piwik Open Analytics](https://github.com/emmanuel-keller/gitbook-plugin-piwik) | Piwik Open Analytics tracking for your book |
| [Heading Anchors](https://github.com/rlmv/gitbook-plugin-anchors) | Add linkable Github-style anchors to headings |
| [JSBin](https://github.com/jcouyang/gitbook-plugin-jsbin) | Embedded jsbin frame into your book |
| [GrVis](https://github.com/romanlytkin/gitbook-grvis) | Gitbook GrViz plugin is used to select from markdown dot and converting it into a picture format svg |
| [PlantUml](https://github.com/romanlytkin/gitbook-plantuml) | Gitbook PlantUml plugin is used to select from markdown uml and converting it into a picture format svg |
| [Mermaid](https://github.com/JozoVilcek/gitbook-plugin-mermaid) | Adds diagrams and flowcharts rendered by [mermaid](https://github.com/knsv/mermaid) |
## Debugging
+30 -19
View File
@@ -33,7 +33,7 @@ var Book = function(root, context, parent) {
},
// Log level
logLevel: logger.LEVELS
logLevel: "info"
});
// Log
@@ -117,7 +117,7 @@ Book.prototype.parse = function() {
path.join(that.root, lang.path),
_.merge({}, that.context, {
config: _.extend({}, that.options, {
'output': path.join(that.options.output, lang.path),
'output': path.join(that.options.output, lang.lang),
'language': lang.lang
})
}),
@@ -185,8 +185,6 @@ Book.prototype.generate = function(generator) {
return generator.prepare();
})
// Generate content
.then(function() {
if (that.isMultilingual()) {
@@ -280,9 +278,7 @@ Book.prototype.generateFile = function(output, options) {
return fs.tmp.dir()
.then(function(tmpDir) {
book.config.extend({
output: tmpDir
});
book.setOutput(tmpDir);
return book.generate(options.ebookFormat)
.then(function(_options) {
@@ -295,14 +291,11 @@ Book.prototype.generateFile = function(output, options) {
_tmpDir = path.join(_tmpDir, lang);
}
book.log.info("copy ebook to", output, "...");
book.log.debug.ln("copy ebook to", _outputFile);
return fs.copy(
path.join(_tmpDir, "index."+options.ebookFormat),
_outputFile
)
.then(function() {
book.log.info.ok();
});
);
};
// Multi-langs book
@@ -313,12 +306,15 @@ Book.prototype.generateFile = function(output, options) {
_.map(book.langs, function(lang) {
return copyFile(lang.lang);
})
);
)
.thenResolve(book.langs.length);
} else {
return copyFile();
return copyFile().thenResolve(1);
}
})
.then(function() {
.then(function(n) {
book.log.info.ok(n+" file(s) generated");
return fs.remove(tmpDir);
});
});
@@ -650,6 +646,11 @@ Book.prototype.parentRoot = function() {
return this.root;
};
// Return true if it's a sub-book
Book.prototype.isSubBook = function() {
return !!this.parent;
};
// Resolve a path in book
Book.prototype.resolve = function(p) {
return path.resolve(this.root, p);
@@ -692,6 +693,16 @@ Book.prototype._defaultsStructure = function(filename) {
that.langsFile = that.langsFile || that.config.getStructure("langs")+extension;
}
// Change output path
Book.prototype.setOutput = function(p) {
var that = this;
this.options.output = path.resolve(p);
_.each(this.books, function(book) {
book.setOutput(path.join(that.options.output, book.options.language));
});
};
// Init and return a book
Book.init = function(root) {
@@ -712,10 +723,10 @@ Book.init = function(root) {
}, []);
};
book.log.infoLn("init book at", root);
book.log.info.ln("init book at", root);
return fs.mkdirp(root)
.then(function() {
book.log.infoLn("detect structure from SUMMARY (if it exists)");
book.log.info.ln("detect structure from SUMMARY (if it exists)");
return book.parseSummary();
})
.fail(function() {
@@ -748,7 +759,7 @@ Book.init = function(root) {
return fs.exists(absolutePath)
.then(function(exists) {
book.log.infoLn("create", chapter.path);
book.log.info.ln("create", chapter.path);
if(exists) return;
return fs.mkdirp(path.dirname(absolutePath))
@@ -759,7 +770,7 @@ Book.init = function(root) {
}));
})
.then(function() {
book.log.infoLn("initialization is finished");
book.log.info.ln("initialization is finished");
});
};
+2
View File
@@ -107,6 +107,8 @@ Configuration.prototype.load = function() {
if (that.options.gitbook == "*") {
that.book.log.warn.ln("you should specify a gitbook version to use in your book.json, for example: "+(_.first(pkg.version.split("."))+".x.x"));
}
that.options.gitbook = pkg.version;
});
};
+1 -1
View File
@@ -58,7 +58,7 @@ BaseGenerator.prototype.copyCover = function() {
])
.fail(function() {
// If orignaly from multi-lang, try copy from parent
if (!that.isMultilingual()) return;
if (!that.book.isSubBook()) return;
return Q.all([
fs.copy(path.join(that.book.parentRoot(), "cover.jpg"), path.join(that.options.output, "cover.jpg")),
+1 -1
View File
@@ -1,7 +1,7 @@
var Q = require("q");
var _ = require("lodash");
var path = require("path");
var tinylr = require('tiny-lr-fork');
var tinylr = require('tiny-lr');
var color = require('bash-color');
var Book = require("./book");
+5 -2
View File
@@ -22,15 +22,18 @@ var Plugin = function(book, name) {
"gitbook-"+name,
name,
], function(_name) {
if (this.load(_name, __dirname)) return false;
// Load from the book
if (this.load(_name, book.root)) return false;
// Load from default plugins
if (this.load(_name, __dirname)) return false;
}, this);
};
// Type of plugins resources
Plugin.RESOURCES = ["js", "css"];
Plugin.HOOKS = [
"init", "finish"
"init", "finish", "finish:before"
]
// Load from a name
+14 -6
View File
@@ -78,7 +78,14 @@ function pregQuote( str ) {
// Adapt an html snippet to be relative to a base folder
function normalizeHtml(src, options) {
var $ = cheerio.load(src, { xmlMode: false});
var $ = cheerio.load(src, {
// We should parse html without trying to normalize too much
xmlMode: false,
// SVG need some attributes to use uppercases
lowerCaseAttributeNames: false,
lowerCaseTags: false
});
var toConvert = [];
var svgContent = {};
var outputRoot = options.book.options.output;
@@ -198,12 +205,13 @@ function normalizeHtml(src, options) {
$("*").each(function() {
replaceText($, this, r, function(match) {
// Add to files index in glossary
if (!includedInFiles) {
includedInFiles = true;
term.files = term.files || [];
term.files.push(options.navigation[options.input]);
}
return "<a href='"+links.toAbsolute("GLOSSARY.html", options.base, options.output)+"#"+term.id+"' class='glossary-term' title='"+term.description+"'>"+match+"</span>";
return "<a href='"+links.toAbsolute("GLOSSARY.html", options.base, options.output)+"#"+term.id+"' class='glossary-term' title='"+term.description+"'>"+match+"</a>";
});
});
});
@@ -218,7 +226,7 @@ function normalizeHtml(src, options) {
function convertImages(images, options) {
if (!options.convertImages) return Q();
options.book.log.info.ln("convert ", images.length, "images to png");
options.book.log.debug.ln("convert ", images.length, "images to png");
return _.reduce(images, function(prev, image) {
var imgin = path.resolve(options.book.options.output, image.source);
@@ -228,8 +236,8 @@ function convertImages(images, options) {
// Write image if need to be download
.then(function() {
if (!image.origin) return;
options.book.log.info("download image", image.origin);
return options.book.log.info.promise(fs.writeStream(imgin, request(image.origin)));
options.book.log.debug("download image", image.origin, "...");
return options.book.log.debug.promise(fs.writeStream(imgin, request(image.origin)));
})
// Write svg if content
@@ -247,7 +255,7 @@ function convertImages(images, options) {
});
}, Q())
.then(function() {
options.book.log.info.ok(images.length+" images converted with success");
options.book.log.debug.ok(images.length+" images converted with success");
});
};
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.6",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
@@ -10,9 +10,9 @@
"lodash": "2.4.1",
"graceful-fs": "3.0.5",
"resolve": "0.6.3",
"fs-extra": "0.14.0",
"fs-extra": "0.16.3",
"fstream-ignore": "1.0.2",
"gitbook-parsers": "0.3.0",
"gitbook-parsers": "0.3.1",
"nunjucks": "git+https://github.com/SamyPesse/nunjucks.git#4019d1b7379372336b86ce1b0bf84352a2029747",
"nunjucks-autoescape": "0.1.0",
"nunjucks-filter": "0.1.0",
@@ -23,14 +23,14 @@
"gitbook-plugin-livereload": "0.0.1",
"gaze": "~0.5.1",
"send": "0.2.0",
"tiny-lr-fork": "0.0.5",
"tiny-lr": "0.1.5",
"tmp": "0.0.24",
"crc": "3.2.1",
"bash-color": "0.0.3",
"URIjs": "1.14.1",
"request": "2.51.0",
"npm": "2.4.1",
"dom-serializer": "git+https://github.com/SamyPesse/dom-serializer.git#58d8ea24b9b7b4137ee5f30a41abce4d7c4a922a"
"dom-serializer": "git+https://github.com/SamyPesse/dom-serializer.git#57ed9a2c3dfa964022ce7d71859c558ba7721785"
},
"devDependencies": {
"mocha": "1.18.2",
+1 -1
View File
@@ -1,3 +1,3 @@
# Other Title
A description
This is a description, it's simple, no ?
+22
View File
@@ -0,0 +1,22 @@
var path = require('path');
var _ = require('lodash');
var assert = require('assert');
var cheerio = require('cheerio');
var fs = require("fs");
var fsUtil = require("../lib/utils/fs");
describe('Glossary Generation', function () {
it('should correctly replace glossary terms', function(done) {
testGeneration(books[0], "website", function(output) {
var content = fs.readFileSync(path.join(output, "index.html"), { encoding: "utf8" });
var $ = cheerio.load(content);
var $body = $(".page-inner");
var $a = $("a[href='GLOSSARY.html#description']");
assert($a.length == 1);
assert($a.text() == "description");
}, done);
});
});
+1 -1
View File
@@ -11,7 +11,7 @@
"SEARCH_PLACEHOLDER": "Suchbegriff eingeben",
"FONTSETTINGS_TOGGLE": "Schrifteinstellungen",
"SHARE_TOGGLE": "Teilen",
"SHARE_ON": "auf __platform__ teilen",
"SHARE_ON": "Auf __platform__ teilen",
"FONTSETTINGS_WHITE": "Hell",
"FONTSETTINGS_SEPIA": "Sepia",
"FONTSETTINGS_NIGHT": "Nacht"
+18
View File
@@ -0,0 +1,18 @@
{
"LANGS_CHOOSE": "Seleccione un idioma",
"GLOSSARY": "Glosario",
"GLOSSARY_INDEX": "Índice",
"GLOSSARY_OPEN": "Glosario",
"GITBOOK_LINK": "Publicado con GitBook",
"SUMMARY": "Tabla de contenido",
"SUMMARY_INTRODUCTION": "Introducción",
"SUMMARY_TOGGLE": "Tabla de contenido",
"SEARCH_TOGGLE": "Busca",
"SEARCH_PLACEHOLDER": "Escribe para buscar",
"FONTSETTINGS_TOGGLE": "Configuración de fuente",
"SHARE_TOGGLE": "Comparte",
"SHARE_ON": "Comparte en __platform__",
"FONTSETTINGS_WHITE": "Claro",
"FONTSETTINGS_SEPIA": "Sépia",
"FONTSETTINGS_NIGHT": "Noche"
}
+18
View File
@@ -0,0 +1,18 @@
{
"LANGS_CHOOSE": "Velg språk",
"GLOSSARY": "Register",
"GLOSSARY_INDEX": "Indeks",
"GLOSSARY_OPEN": "Register",
"GITBOOK_LINK": "Publisert med GitBook",
"SUMMARY": "Innholdsfortegnelse",
"SUMMARY_INTRODUCTION": "Innledning",
"SUMMARY_TOGGLE": "Innholdsfortegnelse",
"SEARCH_TOGGLE": "Søk",
"SEARCH_PLACEHOLDER": "Skriv inn søkeord",
"FONTSETTINGS_TOGGLE": "Tekstinnstillinger",
"SHARE_TOGGLE": "Del",
"SHARE_ON": "Del på __platform__",
"FONTSETTINGS_WHITE": "Lys",
"FONTSETTINGS_SEPIA": "Sepia",
"FONTSETTINGS_NIGHT": "Mørk"
}
+18
View File
@@ -0,0 +1,18 @@
{
"LANGS_CHOOSE": "Escolher sua língua",
"GLOSSARY": "Glossário",
"GLOSSARY_INDEX": "Índice",
"GLOSSARY_OPEN": "Glossário",
"GITBOOK_LINK": "Publicado com GitBook",
"SUMMARY": "Tabela de conteúdos",
"SUMMARY_INTRODUCTION": "Introdução",
"SUMMARY_TOGGLE": "Tabela de conteúdos",
"SEARCH_TOGGLE": "Pesquise",
"SEARCH_PLACEHOLDER": "Escreva para pesquisar",
"FONTSETTINGS_TOGGLE": "Configurações de fonte",
"SHARE_TOGGLE": "Compartilhar",
"SHARE_ON": "Compartilhar no __platform__",
"FONTSETTINGS_WHITE": "Claro",
"FONTSETTINGS_SEPIA": "Sépia",
"FONTSETTINGS_NIGHT": "Noite"
}