mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-27 04:29:05 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 532e8b0388 | |||
| 35b3d50012 | |||
| 72ff9996ce | |||
| 0759c4dd78 | |||
| 82a1a151e4 | |||
| ff6e8387fb | |||
| f71601e8d3 | |||
| 234a37726f | |||
| 65a7979874 | |||
| 6a00bf0fc0 | |||
| 853f3d6482 | |||
| 27de7cd914 | |||
| 2318cae1e6 | |||
| cb313c0fab | |||
| 4f25056017 | |||
| 5baebb8754 | |||
| 1eea994e73 | |||
| 8a597ff3f1 |
+18
-4
@@ -7,12 +7,26 @@ 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)
|
||||
- French
|
||||
- Samy Pessé (@SamyPesse)
|
||||
@@ -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
@@ -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");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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
@@ -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")),
|
||||
|
||||
+5
-2
@@ -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
|
||||
|
||||
+4
-4
@@ -218,7 +218,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 +228,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 +247,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");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "2.0.0-alpha.1",
|
||||
"version": "2.0.0-alpha.5",
|
||||
"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",
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user