Compare commits

...

36 Commits

Author SHA1 Message Date
Addison e350f4d8fc Update README.md 2023-03-02 13:30:09 +08:00
Addison 3492488236 Fix typo 2023-02-14 11:09:14 +01:00
Samy Pessé 6c6ef7f4af Add message about gitbook.com on README (#2170) 2018-12-27 17:51:39 +01:00
Johan Preynat 7bcd0438b5 Merge pull request #2115 from GitbookIO/remove-slack-link
Remove Slack link
2018-08-31 09:52:31 +00:00
Nicolas Gaborit 339b77071a Update README.md 2018-08-31 11:49:42 +02:00
Nicolas Gaborit 6efbb70c32 Update docs to become legacy (#2016)
* Update links to legacy.gitbook.com

* Update README.md

* Update README.md

* Update faq.md
2018-04-13 14:50:07 +02:00
Aaron O'Mullan b48f8472d3 Bump version to 3.2.3 2017-08-03 23:26:45 +02:00
Aaron O'Mullan fc46dab752 Update theme-default to 1.0.7 (fixes #1670) 2017-08-03 23:26:32 +02:00
Johan Preynat ad425b9772 Bump version to 3.2.2 2016-10-01 22:35:54 +02:00
Johan Preynat 5238fa352c Rollback to use gitbook-markdown@1.3.2 2016-10-01 22:30:43 +02:00
Johan Preynat 32183b6650 Merge branch 'fix-3.1-version' 2016-10-01 21:49:06 +02:00
Johan Preynat cb3d6a7f01 Correctly handle page parsing errors 2016-10-01 21:47:25 +02:00
Johan Preynat c978f0ab21 Add comment 2016-10-01 21:47:08 +02:00
Samy Pessé 33ff60cee7 Add changes for 3.2.1 2016-09-28 15:56:36 +02:00
Samy Pesse 33d7e022e6 Bump version to 3.2.1 2016-09-28 13:21:24 +02:00
Samy Pesse 09782b964b Update theme-default@1.0.6 2016-09-28 13:10:47 +02:00
Johan Preynat 7938ee8ec6 Use nunjucks@2.5.2 2016-09-28 10:32:14 +02:00
Peter B Smith 2e8e4f63d7 fixing a typo of the word "publishing" (#1536) 2016-09-28 09:49:29 +02:00
jdaviescoates b9fa6c3051 Update examples.md (#1522)
By adding the Loomio and Enspiral handbook examples
2016-09-08 20:38:59 +02:00
Samy Pessé 9c071dade5 Merge pull request #1481 from mcveat/patch-1
Fixed typo
2016-08-04 00:19:11 +02:00
Piotr Adamski 56e44651fa Fixed typo 2016-08-03 22:08:12 +02:00
Samy Pessé 42fac98992 Fix command for getting gitbook version 2016-08-01 09:47:31 +02:00
Samy Pessé 4f5513add0 Create template for GitHub issues 2016-07-25 20:39:31 +02:00
Samy Pesse 90cbfc0596 Add OSX testing on Travis 2016-07-15 11:38:58 +02:00
Samy Pessé 38ab9fa05a Bump version to 3.2.0 2016-07-11 16:48:13 +02:00
Samy Pessé 12e20c5fcc Update theme-default@1.0.5 2016-07-11 16:47:16 +02:00
Samy Pessé 6b103f4532 Fix #1408: fix i18n in website generator and add tests for it 2016-07-11 16:27:22 +02:00
Soreine d4fa5c18a8 editPlugin and getPluginConfig 2016-07-11 15:18:35 +02:00
Soreine 2a116dfdb0 Fix reducedObject when default property is undefined 2016-07-11 15:18:35 +02:00
Samy Pessé 0349f54f3c Export file model 2016-07-07 16:41:05 +02:00
Samy Pessé 695bda312c Bump version to 3.2.0-pre.1 2016-07-05 17:15:48 +02:00
Samy Pessé 144bd4c97a Update gitbook-markdown@2.0.1 2016-07-05 11:07:51 +02:00
Samy Pessé e105983cf8 Add back property "output" to page/template context 2016-07-04 18:08:44 +02:00
Soreine ea3afbed75 Update gitbook-plugin-lunr@1.2.0 2016-07-01 17:52:15 +02:00
Soreine d563abe3df Reduce size of logo to give room to version number 2016-06-30 15:37:31 +02:00
Soreine 70fd4ded29 Update theme-official for doc 2016-06-30 12:15:50 +02:00
39 changed files with 359 additions and 167 deletions
+19
View File
@@ -0,0 +1,19 @@
Thank you for giving us your feedback! We listed some guidelines to help you:
If possible, open separate issues for each bug report. Avoid grouping bugs that are unrelated.
### What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce. if possible, provide the GitBook version being used (`gitbook -V`) and the system infromations (OS and version).
### What is the expected behavior?
How do you think, or how would you like it should behave.
#### For legacy.gitbook.com
Provide, if possible, your username and the URL of the concerned book.
----
The GitBook Team
+3
View File
@@ -1,5 +1,8 @@
sudo: false
language: node_js
os:
- linux
- osx
node_js:
- "stable"
- "4.1"
+14 -1
View File
@@ -2,9 +2,22 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 3.2.0 (pre)
## 3.2.2
- Fix catching parsing errors leading to possible missing pages in generated book
- Rollback markdown parser to `kramed` until `markup-it` is stable enough
## 3.2.1
- Fix bug on Firefox when navigating to an url containing an hash
- Update nunjucks to fix JS error when page contains a lot of templating blocks
## 3.2.0
- Switch markdown parser from `kramed` to `markup-it`
- Fix support of `|` in tables
- Fix access to `output.name` in templating
- Fix i18n for website and PDF
- Fix minor scrolling issues on website
- Improve options of default search indexer (keywords, disabling per pages)
- Improve pertinence of search results
## 3.1.1
- Fix order of plugins during loading
+14 -6
View File
@@ -1,3 +1,11 @@
> ## ⚠️ Deprecation warning:
> As the efforts of the GitBook team are focused on the [GitBook.com](https://www.gitbook.com) platform, the CLI is no longer under active development.
> All content supported by the CLI are mostly supported by our [GitBook.com / GitHub integration](https://docs.gitbook.com/getting-started/git-sync).
> Content hosted on the [legacy.gitbook.com](https://legacy.gitbook.com) will continue working until further notice. For differences with the new version, > check out our [documentation](https://docs.gitbook.com/v2-changes/important-differences).
>
> Join our [GitHub community](https://github.com/GitbookIO/community) to stay up to date with the latest news at GitBook.
GitBook
=======
@@ -6,11 +14,11 @@ GitBook
[![Windows Build status](https://ci.appveyor.com/api/projects/status/63nlflxcwmb2pue6?svg=true)](https://ci.appveyor.com/project/GitBook/gitbook)
[![Slack Status](https://slack.gitbook.com/badge.svg)](https://slack.gitbook.com)
GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). Here is an example: [Learn Javascript](https://www.gitbook.com/book/GitBookIO/javascript).
GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). Here is an example: [Learn Javascript](https://legacy.gitbook.com/book/GitBookIO/javascript).
You can publish and host books easily online using [gitbook.com](https://www.gitbook.com). A desktop editor is [also available](https://www.gitbook.com/editor).
You can publish and host books easily online using [gitbook.com](https://legacy.gitbook.com). A desktop editor is [also available](https://legacy.gitbook.com/editor).
Check out the [GitBook Community Slack Channel](https://slack.gitbook.com), Stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook.
Stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook.
Complete documentation is available at [toolchain.gitbook.com](http://toolchain.gitbook.com/).
@@ -18,7 +26,7 @@ Complete documentation is available at [toolchain.gitbook.com](http://toolchain.
## Getting started
GitBook can be used either on your computer for building local books or on GitBook.com for hosting them. To get started, check out [the installation instructions in the documentation](docs/setup.md).
GitBook can be used either on your computer for building local books or on legacy.gitbook.com for hosting them. To get started, check out [the installation instructions in the documentation](docs/setup.md).
## Usage examples
@@ -28,7 +36,7 @@ You can find a [list of real-world examples](docs/examples.md) in the documentat
## Help and Support
We're always happy to help out with your books or any other questions you might have. You can ask a question on the following contact form at [gitbook.com/contact](https://www.gitbook.com/contact) or signal an issue on [GitHub](https://github.com/GitbookIO/gitbook).
We're always happy to help out with your books or any other questions you might have. You can ask a question on the following contact form at [gitbook.com/contact](https://legacy.gitbook.com/contact) or signal an issue on [GitHub](https://github.com/GitbookIO/gitbook).
## Features
@@ -44,7 +52,7 @@ We're always happy to help out with your books or any other questions you might
## Publish your book
The platform [GitBook.com](https://www.gitbook.com/) is like an "Heroku for books": you can create a book on it (public, or private) and update it using **git push**.
The platform [legacy.gitbook.com](https://legacy.gitbook.com/) is like an "Heroku for books": you can create a book on it (public, or private) and update it using **git push**.
## Licensing
+2 -2
View File
@@ -6,10 +6,10 @@ module.exports = {
title: 'GitBook Toolchain Documentation',
// Enforce use of GitBook v3
gitbook: '>=3.0.0-pre.0',
gitbook: '3.1.1',
// Use the "official" theme
plugins: ['theme-official', 'sitemap'],
plugins: ['theme-official@2.1.1', '-sharing', '-fontsettings', 'sitemap'],
variables: {
version: pkg.version
+7 -8
View File
@@ -1,20 +1,20 @@
# GitBook Toolchain Documentation
This document aims to be a comprehensive guide to GitBook. It contains the full documentation for version **{{ book.version }}**. Help for GitBook.com specific questions can be found at [help.gitbook.com](https://help.gitbook.com).
This document aims to be a comprehensive guide to the GitBook command line tool, version **3.2.3**. This is the same toolchain used by the legacy GitBook platform, living at legacy.gitbook.com. Help for using the platform can be found at [help.legacy.gitbook.com](https://help.legacy.gitbook.com). If you are looking for the new GitBook service, head to [gitbook.com](https://www.gitbook.com).
### What is GitBook?
### What is `gitbook`?
GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). . This documentation has been generated using GitBook.
`gitbook` is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). This documentation has been generated using `gitbook.
GitBook can output your content as a website ([customizable](themes/README.md) and [extensibles](plugins/README.md)) or as an ebook (PDF, ePub or Mobi).
`gitbook` can output your content as a website ([customizable](themes/README.md) and [extensibles](plugins/README.md)) or as an ebook (PDF, ePub or Mobi).
[GitBook.com](https://www.gitbook.com) is the online platform to create and host books built using the GitBook format. It offers hosting, collaboration features and an [easy-to-use editor](https://www.gitbook.com/editor).
[legacy.gitbook.com](https://legacy.gitbook.com) is the online platform to create and host books built using the GitBook format. It offers hosting, collaboration features and an [easy-to-use editor](https://legacy.gitbook.com/editor).
### Help and Support
We're always happy to help out with your books or any other questions you might have. You can ask a question on the following contact form at [gitbook.com/contact](https://www.gitbook.com/contact) or signal an issue on [GitHub](https://github.com/GitbookIO/gitbook).
If you have problems with the toolchain, you can search for or open a discussion on [GitHub](https://github.com/GitbookIO/gitbook).
Check out the [GitBook Community Slack Channel](https://slack.gitbook.com), Stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook.
Check out the [GitBook Community Slack Channel](https://slack.gitbook.com) for help, and stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook.
### FAQ
@@ -23,4 +23,3 @@ Some questions are frequently asked. If you have a problem you should [check th
### Contribute to this documentation
You can contribute to improve this documentation on [GitHub](https://github.com/GitbookIO/gitbook) by signaling issues or proposing changes.
+3 -3
View File
@@ -8,9 +8,9 @@ GitBook allows you to customize your book using a flexible configuration. These
| -------- | ----------- |
| `root` | Path to the root folder containing all the book's files, except `book.json`|
| `structure` | To specify paths for Readme, Summary, Glossary etc. See [Structure paragraph](#structure). |
| `title` | Title of your book, default value is extracted from the README. On GitBook.com this field is pre-filled. |
| `description` | Description of your book, default value is extracted from the README. On GitBook.com this field is pre-filled. |
| `author` | Name of the author. On GitBook.com this field is pre-filled. |
| `title` | Title of your book, default value is extracted from the README. On legacy.gitbook.com this field is pre-filled. |
| `description` | Description of your book, default value is extracted from the README. On legacy.gitbook.com this field is pre-filled. |
| `author` | Name of the author. On legacy.gitbook.com this field is pre-filled. |
| `isbn` | ISBN of the book |
| `language` | [ISO code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) of the book's language, default value is `en` |
| `direction` | Text's direction. Can be `rtl` or `ltr`, the default value depends on the value of `language` |
+10 -8
View File
@@ -4,24 +4,26 @@ description: Real world examples of content published using GitBook.
# Examples
More than 50,000 books have been published on [GitBook.com](https://www.gitbook.com/explore).
More than 50,000 books have been published on [legacy.gitbook.com](https://legacy.gitbook.com/explore).
### Books
- [Front-end Handbook](https://www.gitbook.com/book/frontendmasters/front-end-handbook/details) by [Cody Lindley](http://codylindley.com)
- [How to make an Operating System](https://www.gitbook.com/book/samypesse/how-to-create-an-operating-system/details) by [@SamyPesse](https://github.com/SamyPesse)
- [Building Web Apps with Go](https://www.gitbook.com/book/codegangsta/building-web-apps-with-go/details) by [@codegangsta](https://github.com/codegangsta)
- [Front-end Handbook](https://legacy.gitbook.com/book/frontendmasters/front-end-handbook/details) by [Cody Lindley](http://codylindley.com)
- [How to make an Operating System](https://legacy.gitbook.com/book/samypesse/how-to-create-an-operating-system/details) by [@SamyPesse](https://github.com/SamyPesse)
- [Building Web Apps with Go](https://legacy.gitbook.com/book/codegangsta/building-web-apps-with-go/details) by [@codegangsta](https://github.com/codegangsta)
- [Django Girls Tutorial](http://tutorial.djangogirls.org/en/index.html) by [Django Girls](https://djangogirls.org)
- [Linux Inside](https://www.gitbook.com/book/0xax/linux-insides/details) by [0xAX](https://twitter.com/0xAX)
- [Learn Javascript](https://www.gitbook.com/book/gitbookio/javascript/details) by [GitBook](https://twitter.com/GitbookIO)
- [Linux Inside](https://legacy.gitbook.com/book/0xax/linux-insides/details) by [0xAX](https://twitter.com/0xAX)
- [Learn Javascript](https://legacy.gitbook.com/book/gitbookio/javascript/details) by [GitBook](https://twitter.com/GitbookIO)
### Research Papers
- [TowCenter Collection](https://www.gitbook.com/@towcenter) by [Columbia Journalism School](http://www.journalism.columbia.edu/)
- [Block Relaxation Algorithms in Statistics](https://www.gitbook.com/@jandeleeuw) by Jan de Leeuw
- [TowCenter Collection](https://legacy.gitbook.com/@towcenter) by [Columbia Journalism School](http://www.journalism.columbia.edu/)
- [Block Relaxation Algorithms in Statistics](https://legacy.gitbook.com/@jandeleeuw) by Jan de Leeuw
### Documentation
- [DuckDuckHack Documentation](http://docs.duckduckhack.com) by [DuckDuckGo](https://duckduckgo.com/about)
- [Loomio Handbook](http://loomio.coop/) by [Loomio](https://www.loomio.org/)
- [Enspiral Handbook](http://handbook.enspiral.com/) by [Enspiral](http://enspiral.com/)
- This documentation
+4 -4
View File
@@ -2,15 +2,15 @@
This page gathers common questions and answers concerning the GitBook format and toolchain.
Questions about GitBook.com and the Editor are gather into the [help.gitbook.com's FAQ](http://help.gitbook.com/faq.html).
Questions about the legacy platform at legacy.gitbook.com and the Editor are gather into the [help.legacy.gitbook.com's FAQ](http://help.legacy.gitbook.com/faq.html).
#### How can I host/publish my book?
Books can easily be published and hosted on [GitBook.com](https://www.gitbook.com). But GitBook output can be hosted on any static file hosting solution.
Books can easily be published and hosted on [legacy.gitbook.com](https://legacy.gitbook.com). But GitBook output can be hosted on any static file hosting solution.
#### What can I use to edit my content?
Any text editor should work! But we advise using the [GitBook Editor](https://www.gitbook.com/editor). [GitBook.com](https://www.gitbook.com) also provides a web version of this editor.
Any text editor should work! But we advise using the [GitBook Editor](https://legacy.gitbook.com/editor). [legacy.gitbook.com](https://legacy.gitbook.com) also provides a web version of this editor.
---
@@ -34,7 +34,7 @@ You should always use paths and the `.md` extensions when linking to your files,
#### Can I create a GitBook in a sub-directory of my repository?
Yes, GitBooks can be created in [sub-directories](structure.md#subdirectory). GitBook.com and the CLI also looks by default in a serie of [folders](structure.md).
Yes, GitBooks can be created in [sub-directories](structure.md#subdirectory). legacy.gitbook.com and the CLI also looks by default in a serie of [folders](structure.md).
#### Does GitBook supports RTL languages?
+2 -2
View File
@@ -19,9 +19,9 @@ Once you find a plugin that you want to install, you need to add it to your `boo
You can also specify a specific version using: `"myPlugin@0.3.1"`. By default GitBook will resolve the latest version of the plugin compatbile with the current GitBook version.
### GitBook.com
### legacy.gitbook.com
Plugins are automatically installed on [GitBook.com](https://www.gitbook.com). Locally, run `gitbook install` to install and prepare all plugins for your books.
Plugins are automatically installed on [legacy.gitbook.com](https://legacy.gitbook.com). Locally, run `gitbook install` to install and prepare all plugins for your books.
### Configuring plugins
+2 -2
View File
@@ -2,7 +2,7 @@
### Testing your plugin locally
Testing your plugin on your book before plushing it is possible using [npm link](https://docs.npmjs.com/cli/link).
Testing your plugin on your book before publishing it is possible using [npm link](https://docs.npmjs.com/cli/link).
In the plugin's folder, run:
@@ -10,7 +10,7 @@ In the plugin's folder, run:
$ npm link
```
The nin your book's folder:
Then in your book's folder:
```
$ npm link gitbook-plugin-<plugin's name>
+3 -3
View File
@@ -2,11 +2,11 @@
Getting GitBook installed and ready-to-go should only take a few minutes.
### GitBook.com
### legacy.gitbook.com
[GitBook.com](https://www.gitbook.com) is an easy to use solution to write, publish and host books. It is the easiest solution for publishing your content and collaborating on it.
[legacy.gitbook.com](https://legacy.gitbook.com) is an easy to use solution to write, publish and host books. It is the easiest solution for publishing your content and collaborating on it.
It integrates well with the [GitBook Editor](https://www.gitbook.com/editor).
It integrates well with the [GitBook Editor](https://legacy.gitbook.com/editor).
### Local Installation
+4
View File
@@ -0,0 +1,4 @@
/* Reduce size of logo to allow long versions like 3.0.0-pre.1 */
.gb-page-header .container .logo h1 {
font-size: 24px ;
}
+1
View File
@@ -6,6 +6,7 @@ module.exports = {
// Models
Book: require('./models/book'),
FS: require('./models/fs'),
File: require('./models/file'),
Summary: require('./models/summary'),
Glossary: require('./models/glossary'),
Config: require('./models/config'),
+4
View File
@@ -18,6 +18,10 @@ module.exports = {
'type': 'string',
'title': 'ISBN for published book'
},
'language': {
'type': 'string',
'title': 'Language of the book'
},
'author': {
'type': 'string',
'title': 'Name of the author'
+6 -6
View File
@@ -3,12 +3,12 @@ var encodePage = require('./encodePage');
var encodeFile = require('./encodeFile');
/**
Return a JSON representation of a book with a specific file
@param {Book} output
@param {Page} page
@return {Object}
*/
* Return a JSON representation of a book with a specific file
*
* @param {Book} output
* @param {Page} page
* @return {Object}
*/
function encodeBookWithPage(book, page) {
var file = page.getFile();
+5 -5
View File
@@ -1,11 +1,11 @@
var encodeBook = require('./encodeBook');
/**
Encode an output to JSON
@param {Output}
@return {Object}
*/
* Encode an output to JSON
*
* @param {Output}
* @return {Object}
*/
function encodeOutputToJson(output) {
var book = output.getBook();
var generator = output.getGenerator();
+23
View File
@@ -0,0 +1,23 @@
var encodeOutput = require('./encodeOutput');
var encodePage = require('./encodePage');
var encodeFile = require('./encodeFile');
/**
* Return a JSON representation of a book with a specific file
*
* @param {Book} output
* @param {Page} page
* @return {Object}
*/
function encodeOutputWithPage(output, page) {
var file = page.getFile();
var book = output.getBook();
var result = encodeOutput(output);
result.page = encodePage(page, book.getSummary());
result.file = encodeFile(file);
return result;
}
module.exports = encodeOutputWithPage;
+1
View File
@@ -2,6 +2,7 @@
module.exports = {
encodeOutput: require('./encodeOutput'),
encodeBookWithPage: require('./encodeBookWithPage'),
encodeOutputWithPage: require('./encodeOutputWithPage'),
encodeBook: require('./encodeBook'),
encodeFile: require('./encodeFile'),
encodePage: require('./encodePage'),
+1 -1
View File
@@ -7,7 +7,7 @@
* @return {Config}
*/
function editPlugin(config, pluginName, pluginConfig) {
return config.set('pluginsConfig.'+pluginName, pluginConfig);
return config.setValue('pluginsConfig.'+pluginName, pluginConfig);
}
module.exports = editPlugin;
+20
View File
@@ -0,0 +1,20 @@
/**
* Return the configuration for a plugin
* @param {Config} config
* @param {String} pluginName
* @return {Object}
*/
function getPluginConfig(config, pluginName) {
var pluginsConfig = config.getValues().get('pluginsConfig');
if (pluginsConfig === undefined) {
return {};
}
var pluginConf = pluginsConfig.get(pluginName);
if (pluginConf === undefined) {
return {};
} else {
return pluginConf.toJS();
}
}
module.exports = getPluginConfig;
+1
View File
@@ -5,5 +5,6 @@ module.exports = {
togglePlugin: require('./togglePlugin'),
editPlugin: require('./editPlugin'),
hasPlugin: require('./hasPlugin'),
getPluginConfig: require('./getPluginConfig'),
isDefaultPlugin: require('./isDefaultPlugin')
};
+38
View File
@@ -0,0 +1,38 @@
var Immutable = require('immutable');
var Output = require('../../models/output');
var Book = require('../../models/book');
var parseBook = require('../../parse/parseBook');
var createMockFS = require('../../fs/mock');
var preparePlugins = require('../preparePlugins');
/**
* Create an output using a generator
*
* FOR TESTING PURPOSE ONLY
*
* @param {Generator} generator
* @param {Map<String:String|Map>} files
* @return {Promise<Output>}
*/
function createMockOutput(generator, files, options) {
var fs = createMockFS(files);
var book = Book.createForFS(fs);
var state = generator.State? generator.State({}) : Immutable.Map();
book = book.setLogLevel('disabled');
options = generator.Options(options);
return parseBook(book)
.then(function(resultBook) {
return new Output({
book: resultBook,
options: options,
state: state,
generator: generator.name
});
})
.then(preparePlugins);
}
module.exports = createMockOutput;
+1 -1
View File
@@ -1,4 +1,4 @@
var generateMock = require('../generateMock');
var generateMock = require('./generateMock');
var EbookGenerator = require('../ebook');
describe('EbookGenerator', function() {
@@ -1,21 +1,20 @@
var tmp = require('tmp');
var Book = require('../models/book');
var createMockFS = require('../fs/mock');
var parseBook = require('../parse/parseBook');
var generateBook = require('./generateBook');
var Book = require('../../models/book');
var createMockFS = require('../../fs/mock');
var parseBook = require('../../parse/parseBook');
var generateBook = require('../generateBook');
/**
Generate a book using JSON generator
And returns the path to the output dir.
FOR TESTING PURPOSE ONLY
@param {Generator}
@param {Map<String:String|Map>} files
@return {Promise<String>}
*/
* Generate a book using a generator
* And returns the path to the output dir.
*
* FOR TESTING PURPOSE ONLY
*
* @param {Generator}
* @param {Map<String:String|Map>} files
* @return {Promise<String>}
*/
function generateMock(Generator, files) {
var fs = createMockFS(files);
var book = Book.createForFS(fs);
+1 -1
View File
@@ -1,4 +1,4 @@
var generateMock = require('../generateMock');
var generateMock = require('./generateMock');
var JSONGenerator = require('../json');
describe('JSONGenerator', function() {
+1 -1
View File
@@ -1,5 +1,5 @@
var fs = require('fs');
var generateMock = require('../generateMock');
var generateMock = require('./generateMock');
var WebsiteGenerator = require('../website');
describe('WebsiteGenerator', function() {
+26 -28
View File
@@ -13,13 +13,12 @@ var generateAssets = require('./generateAssets');
var generatePages = require('./generatePages');
/**
Process an output to generate the book
@param {Generator} generator
@param {Output} output
@return {Promise<Output>}
*/
* Process an output to generate the book
*
* @param {Generator} generator
* @param {Output} output
* @return {Promise<Output>}
*/
function processOutput(generator, startOutput) {
return Promise(startOutput)
.then(preparePlugins)
@@ -133,27 +132,26 @@ function processOutput(generator, startOutput) {
}
/**
Generate a book using a generator.
The overall process is:
1. List and load plugins for this book
2. Call hook "config"
3. Call hook "init"
4. Initialize generator
5. List all assets and pages
6. Copy all assets to output
7. Generate all pages
8. Call hook "finish:before"
9. Finish generation
10. Call hook "finish"
@param {Generator} generator
@param {Book} book
@param {Object} options
@return {Promise<Output>}
*/
* Generate a book using a generator.
*
* The overall process is:
* 1. List and load plugins for this book
* 2. Call hook "config"
* 3. Call hook "init"
* 4. Initialize generator
* 5. List all assets and pages
* 6. Copy all assets to output
* 7. Generate all pages
* 8. Call hook "finish:before"
* 9. Finish generation
* 10. Call hook "finish"
*
*
* @param {Generator} generator
* @param {Book} book
* @param {Object} options
* @return {Promise<Output>}
*/
function generateBook(generator, book, options) {
options = generator.Options(options);
var state = generator.State? generator.State({}) : Immutable.Map();
+7 -7
View File
@@ -10,12 +10,12 @@ var createTemplateEngine = require('./createTemplateEngine');
var callPageHook = require('./callPageHook');
/**
Prepare and generate HTML for a page
@param {Output} output
@param {Page} page
@return {Promise<Page>}
*/
* Prepare and generate HTML for a page
*
* @param {Output} output
* @param {Page} page
* @return {Promise<Page>}
*/
function generatePage(output, page) {
var book = output.getBook();
var engine = createTemplateEngine(output);
@@ -27,7 +27,7 @@ function generatePage(output, page) {
var file = resultPage.getFile();
var filePath = file.getPath();
var parser = file.getParser();
var context = JSONUtils.encodeBookWithPage(book, resultPage);
var context = JSONUtils.encodeOutputWithPage(output, resultPage);
if (!parser) {
return Promise.reject(error.FileNotParsableError({
+5 -5
View File
@@ -7,11 +7,11 @@ var getModifiers = require('../getModifiers');
var JSON_VERSION = '3';
/**
Write a page as a json file
@param {Output} output
@param {Page} page
*/
* Write a page as a json file
*
* @param {Output} output
* @param {Page} page
*/
function onPage(output, page) {
var file = page.getFile();
var readme = output.getBook().getReadme().getFile();
+5 -5
View File
@@ -2,11 +2,11 @@ var Plugins = require('../plugins');
var Promise = require('../utils/promise');
/**
Load and setup plugins
@param {Output}
@return {Promise<Output>}
*/
* Load and setup plugins
*
* @param {Output}
* @return {Promise<Output>}
*/
function preparePlugins(output) {
var book = output.getBook();
+38
View File
@@ -0,0 +1,38 @@
var createMockOutput = require('../../__tests__/createMock');
var prepareI18n = require('../prepareI18n');
var createTemplateEngine = require('../createTemplateEngine');
var WebsiteGenerator = require('../');
describe('i18n', function() {
it('should correctly use english as default language', function() {
return createMockOutput(WebsiteGenerator, {
'README.md': 'Hello World'
})
.then(function(output) {
return prepareI18n(output);
})
.then(function(output) {
var engine = createTemplateEngine(output, 'README.md');
var t = engine.getFilters().get('t');
expect(t('SUMMARY_INTRODUCTION')).toEqual('Introduction');
});
});
it('should correctly use language from book.json', function() {
return createMockOutput(WebsiteGenerator, {
'README.md': 'Hello World',
'book.json': JSON.stringify({ language: 'fr' })
})
.then(function(output) {
return prepareI18n(output);
})
.then(function(output) {
var engine = createTemplateEngine(output, 'README.md');
var t = engine.getFilters().get('t');
expect(t('GITBOOK_LINK')).toEqual('Publié avec GitBook');
});
});
});
+27 -31
View File
@@ -18,19 +18,19 @@ var fileToURL = require('../helper/fileToURL');
var resolveFileToURL = require('../helper/resolveFileToURL');
/**
Directory for a theme with the templates
*/
* Directory for a theme with the templates
*/
function templateFolder(dir) {
return path.join(dir, templatesFolder);
}
/**
Create templating engine to render themes
@param {Output} output
@param {String} currentFile
@return {TemplateEngine}
*/
* Create templating engine to render themes
*
* @param {Output} output
* @param {String} currentFile
* @return {TemplateEngine}
*/
function createTemplateEngine(output, currentFile) {
var book = output.getBook();
var state = output.getState();
@@ -47,18 +47,17 @@ function createTemplateEngine(output, currentFile) {
var loader = new Templating.ThemesLoader(tplSearchPaths);
// Get languages
var language = config.get('language');
var language = config.getValue('language');
// Create API context
var context = Api.encodeGlobal(output);
/**
Check if a file exists
@param {String} fileName
@return {Boolean}
*/
* Check if a file exists
* @param {String} fileName
* @return {Boolean}
*/
function fileExists(fileName) {
if (!fileName) {
return false;
@@ -69,11 +68,10 @@ function createTemplateEngine(output, currentFile) {
}
/**
Return an article by its path
@param {String} filePath
@return {Object|undefined}
*/
* Return an article by its path
* @param {String} filePath
* @return {Object|undefined}
*/
function getArticleByPath(filePath) {
var article = summary.getByPath(filePath);
if (!article) return undefined;
@@ -82,11 +80,10 @@ function createTemplateEngine(output, currentFile) {
}
/**
Return a page by its path
@param {String} filePath
@return {Object|undefined}
*/
* Return a page by its path
* @param {String} filePath
* @return {Object|undefined}
*/
function getPageByPath(filePath) {
var page = output.getPage(filePath);
if (!page) return undefined;
@@ -94,7 +91,6 @@ function createTemplateEngine(output, currentFile) {
return JSONUtils.encodePage(page, summary);
}
return TemplateEngine.create({
loader: loader,
@@ -108,17 +104,17 @@ function createTemplateEngine(output, currentFile) {
filters: defaultFilters.merge({
/**
Translate a sentence
*/
* Translate a sentence
*/
t: function t(s) {
return i18n.t(language, s);
},
/**
Resolve an absolute file path into a
relative path.
it also resolve pages
*/
* Resolve an absolute file path into a
* relative path.
* it also resolve pages
*/
resolveFile: function(filePath) {
filePath = resolveFileToURL(output, filePath);
return LocationUtils.relativeForFile(currentFile, filePath);
+6 -6
View File
@@ -12,11 +12,11 @@ var createTemplateEngine = require('./createTemplateEngine');
var fileToOutput = require('../helper/fileToOutput');
/**
Write a page as a json file
@param {Output} output
@param {Page} page
*/
* Write a page as a json file
*
* @param {Output} output
* @param {Page} page
*/
function onPage(output, page) {
var options = output.getOptions();
var prefix = options.get('prefix');
@@ -40,7 +40,7 @@ function onPage(output, page) {
return Modifiers.modifyHTML(page, getModifiers(output, page))
.then(function(resultPage) {
// Generate the context
var context = JSONUtils.encodeBookWithPage(output.getBook(), resultPage);
var context = JSONUtils.encodeOutputWithPage(output, resultPage);
context.plugins = {
resources: Plugins.listResources(plugins, resources).toJS()
};
+5 -5
View File
@@ -5,11 +5,11 @@ var Promise = require('../../utils/promise');
var listSearchPaths = require('./listSearchPaths');
/**
Prepare i18n, load translations from plugins and book
@param {Output}
@return {Promise<Output>}
*/
* Prepare i18n, load translations from plugins and book
*
* @param {Output}
* @return {Promise<Output>}
*/
function prepareI18n(output) {
var state = output.getState();
var i18n = state.getI18n();
+1
View File
@@ -9,6 +9,7 @@ var direction = require('direction');
* @return {Page}
*/
function parsePageFromString(page, content) {
// Parse page YAML
var parsed = fm(content);
return page.merge({
+25 -6
View File
@@ -11,15 +11,26 @@ var parsePage = require('./parsePage');
@param {Book} book
@param {String} filePath
@return {Page}
@return {Page?}
*/
function parseFilePage(book, filePath) {
var fs = book.getContentFS();
return fs.statFile(filePath)
.then(function(file) {
var page = Page.createForFile(file);
return parsePage(book, page);
.then(
function(file) {
var page = Page.createForFile(file);
return parsePage(book, page);
},
function(err) {
// file doesn't exist
return null;
}
)
.fail(function(err) {
var logger = book.getLogger();
logger.error.ln('error while parsing page "' + filePath + '":');
throw err;
});
}
@@ -48,9 +59,12 @@ function parsePagesList(book) {
return parseFilePage(book, filepath)
.then(function(page) {
map = map.set(filepath, page);
}, function() {
// file doesn't exist
if (!page) {
return;
}
map = map.set(filepath, page);
});
})
)
@@ -65,6 +79,11 @@ function parsePagesList(book) {
return parseFilePage(book, file.getPath())
.then(function(page) {
// file doesn't exist
if (!page) {
return;
}
map = map.set(file.getPath(), page);
});
})
+5
View File
@@ -4,8 +4,13 @@ var Immutable = require('immutable');
* Reduce the difference between a map and its default version
* @param {Map} defaultVersion
* @param {Map} currentVersion
* @return {Map} The properties of currentVersion that differs from defaultVersion
*/
function reducedObject(defaultVersion, currentVersion) {
if(defaultVersion === undefined) {
return currentVersion;
}
return currentVersion.reduce(function(result, value, key) {
var defaultValue = defaultVersion.get(key);
+6 -6
View File
@@ -1,7 +1,7 @@
{
"name": "gitbook",
"version": "3.2.0-pre.0",
"homepage": "https://www.gitbook.com",
"version": "3.2.3",
"homepage": "https://legacy.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
"browser": "./lib/browser.js",
@@ -22,14 +22,14 @@
"fresh-require": "1.0.3",
"front-matter": "^2.1.0",
"gitbook-asciidoc": "1.2.2",
"gitbook-markdown": "2.0.0",
"gitbook-markdown": "1.3.2",
"gitbook-plugin-fontsettings": "2.0.0",
"gitbook-plugin-highlight": "2.0.2",
"gitbook-plugin-livereload": "0.0.1",
"gitbook-plugin-lunr": "1.1.0",
"gitbook-plugin-lunr": "1.2.0",
"gitbook-plugin-search": "2.2.1",
"gitbook-plugin-sharing": "1.0.2",
"gitbook-plugin-theme-default": "1.0.4",
"gitbook-plugin-theme-default": "1.0.7",
"github-slugid": "1.0.1",
"graceful-fs": "4.1.4",
"i18n-t": "1.0.1",
@@ -44,7 +44,7 @@
"moment": "2.13.0",
"npm": "3.9.2",
"npmi": "2.0.1",
"nunjucks": "2.4.2",
"nunjucks": "2.5.2",
"nunjucks-do": "1.0.0",
"object-path": "^0.9.2",
"omit-keys": "^0.1.0",