mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-27 12:39:08 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 799815d85a | |||
| 2946246834 | |||
| 6d276d1e79 | |||
| 6a3a369b3e | |||
| 5d8afa2135 | |||
| ab3e6aa8ce | |||
| 822092736e | |||
| 7497acd2e3 | |||
| ae137885b8 | |||
| b964cc7009 | |||
| c2ea126c5f | |||
| b668dba479 | |||
| 2cae5a0310 | |||
| b6a0f3ff67 | |||
| fa00b52fb5 | |||
| 2999d90907 | |||
| b6696bcad2 | |||
| 728c87c525 | |||
| ace394ee2d | |||
| 076ee98f64 | |||
| 2e472654ca |
@@ -32,7 +32,7 @@ Options for commands `build` and `serve` are:
|
||||
```
|
||||
-o, --output <directory> Path to output directory, defaults to ./_book
|
||||
-f, --format <name> Change generation format, defaults to site, availables are: site, page, pdf, json
|
||||
--config <config file> Configuration file to use, defualt to book.json
|
||||
--config <config file> Configuration file to use, defaults to book.json
|
||||
```
|
||||
|
||||
GitBook load the default configuration from a `book.json` file in the repository if it exists.
|
||||
@@ -42,24 +42,42 @@ Here are the options that can be stored in this file:
|
||||
```
|
||||
{
|
||||
// Folders to use for output (caution: it override the value from the command line)
|
||||
output: null,
|
||||
"output": null,
|
||||
|
||||
// Generator to use for building (caution: it override the value from the command line)
|
||||
generator: "site",
|
||||
"generator": "site",
|
||||
|
||||
// Book title and description (defaults are extracted from the README)
|
||||
title: null,
|
||||
description: null,
|
||||
"title": null,
|
||||
"description": null,
|
||||
|
||||
// GitHub informations (defaults are extracted using git)
|
||||
github: null,
|
||||
githubHost: 'https://github.com/',
|
||||
"github": null,
|
||||
"githubHost": "https://github.com/",
|
||||
|
||||
// Plugins list, can contain "-name" for removing default plugins
|
||||
plugins: [],
|
||||
"plugins": [],
|
||||
|
||||
// Global configuration for plugins
|
||||
pluginsConfig: {}
|
||||
"pluginsConfig": {},
|
||||
|
||||
// Links in template (null: default, false: remove, string: new value)
|
||||
"links": {
|
||||
// Link to home in the top-left corner
|
||||
"home": null,
|
||||
|
||||
// Links in top of sidebar
|
||||
"about": null,
|
||||
"issues": null,
|
||||
"edit": null,
|
||||
|
||||
// Sharing links
|
||||
"sharing": {
|
||||
"google": null,
|
||||
"facebook": null,
|
||||
"twitter": null
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -160,7 +178,7 @@ GitBook will read the `.gitignore`, `.bookignore` and `.ignore` files to get a l
|
||||
|
||||
#### Plugins
|
||||
|
||||
Plugins can used to extend your book functionnalities. Read [GitbookIO/plugin](https://github.com/GitbookIO/plugin) for more informations about how to build a plugin for gitbook.
|
||||
Plugins can 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.
|
||||
|
||||
##### Default plugins:
|
||||
|
||||
@@ -173,3 +191,6 @@ Plugins can used to extend your book functionnalities. Read [GitbookIO/plugin](h
|
||||
* [Disqus](https://github.com/GitbookIO/plugin-disqus): Disqus comments integration in 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 blockin 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
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ build.command(prog.command('serve [source_dir]'))
|
||||
if (!options.watch) return;
|
||||
return utils.watch(_options.input)
|
||||
.then(function(filepath) {
|
||||
console.log("Restart after change in "+path.relative(dir, filepath));
|
||||
console.log("Restart after change in files");
|
||||
console.log('');
|
||||
return generate();
|
||||
})
|
||||
|
||||
+16
-11
@@ -28,29 +28,34 @@ var generate = function(options) {
|
||||
|
||||
options = _.defaults(options || {}, {
|
||||
// Folders to use
|
||||
input: null,
|
||||
output: null,
|
||||
"input": null,
|
||||
"output": null,
|
||||
|
||||
// Config file (relative to input)
|
||||
configFile: "book.json",
|
||||
"configFile": "book.json",
|
||||
|
||||
// Output generator
|
||||
generator: "site",
|
||||
"generator": "site",
|
||||
|
||||
// Book title, keyword, description
|
||||
title: null,
|
||||
description: null,
|
||||
"title": null,
|
||||
"description": null,
|
||||
|
||||
// Origin github repository id
|
||||
github: null,
|
||||
githubHost: 'https://github.com/',
|
||||
"github": null,
|
||||
"githubHost": 'https://github.com/',
|
||||
|
||||
// Theming
|
||||
theme: path.resolve(__dirname, '../../theme'),
|
||||
"theme": path.resolve(__dirname, '../../theme'),
|
||||
|
||||
// Plugins
|
||||
plugins: [],
|
||||
pluginsConfig: {}
|
||||
"plugins": [],
|
||||
"pluginsConfig": {},
|
||||
|
||||
// Links
|
||||
"links": {
|
||||
"about": null
|
||||
}
|
||||
});
|
||||
|
||||
if (!options.input) {
|
||||
|
||||
@@ -86,9 +86,14 @@ Plugin.prototype.callHook = function(name, context, data) {
|
||||
});
|
||||
};
|
||||
|
||||
// Has assets
|
||||
Plugin.prototype.hasAssets = function(out) {
|
||||
return (this.infos.book && this.infos.book.assets);
|
||||
};
|
||||
|
||||
// Copy plugin assets fodler
|
||||
Plugin.prototype.copyAssets = function(out) {
|
||||
if (!this.infos.book || !this.infos.book.assets) return Q();
|
||||
if (!this.hasAssets()) return Q();
|
||||
return fs.copy(
|
||||
this.resolveFile(this.infos.book.assets),
|
||||
out
|
||||
|
||||
@@ -80,7 +80,9 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
|
||||
allNavigation: that.options.navigation,
|
||||
|
||||
plugins: that.plugins,
|
||||
pluginsConfig: JSON.stringify(that.options.pluginsConfig)
|
||||
pluginsConfig: JSON.stringify(that.options.pluginsConfig),
|
||||
|
||||
options: that.options
|
||||
}, options));
|
||||
})
|
||||
.then(interpolate)
|
||||
@@ -115,7 +117,7 @@ Generator.prototype.convertFile = function(content, _input) {
|
||||
};
|
||||
|
||||
var _callHook = function(name) {
|
||||
return that.callHook("page:before", page)
|
||||
return that.callHook(name, page)
|
||||
.then(function(_page) {
|
||||
page = _page;
|
||||
return page;
|
||||
@@ -205,8 +207,9 @@ Generator.prototype.copyAssets = function() {
|
||||
.then(function() {
|
||||
return Q.all(
|
||||
_.map(that.plugins.list, function(plugin) {
|
||||
var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name);
|
||||
if (!plugin.hasAssets()) return Q();
|
||||
|
||||
var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name);
|
||||
return plugin.copyAssets(pluginAssets)
|
||||
.then(function() {
|
||||
return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"homepage": "http://www.gitbook.io/",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
@@ -18,7 +18,7 @@
|
||||
"highlight.js": "8.0.0",
|
||||
"tmp": "0.0.23",
|
||||
"semver": "2.2.1",
|
||||
"gaze": "0.6.4",
|
||||
"gaze": "~0.5.1",
|
||||
"resolve": "0.6.3",
|
||||
|
||||
"gitbook-plugin": "0.0.2",
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -28,7 +28,7 @@ define([
|
||||
.done(function (html) {
|
||||
// Push url to history
|
||||
if (push) history.pushState({ path: url }, null, url);
|
||||
|
||||
|
||||
// Replace html content
|
||||
html = html.replace( /<(\/?)(html|head|body)([^>]*)>/ig, function(a,b,c,d){
|
||||
return '<' + b + 'div' + ( b ? '' : ' data-element="' + c + '"' ) + d + '>';
|
||||
@@ -36,6 +36,7 @@ define([
|
||||
|
||||
var $page = $(html);
|
||||
var $pageHead = $page.find("[data-element=head]");
|
||||
var $pageBody = $page.find('.book');
|
||||
|
||||
// Merge heads
|
||||
var headContent = $pageHead.html()
|
||||
@@ -45,13 +46,11 @@ define([
|
||||
});
|
||||
$("head").html(headContent);
|
||||
|
||||
// Update header, body
|
||||
$('.book-header').html($page.find('.book-header').html());
|
||||
$('.book-body').html($page.find('.book-body').html());
|
||||
|
||||
// Update summary
|
||||
// Merge body
|
||||
var scrollPosition = $('.book-summary .summary').scrollTop();
|
||||
$('.book-summary').html($page.find('.book-summary').html());
|
||||
$pageBody.toggleClass("with-summary", $(".book").hasClass("with-summary"))
|
||||
|
||||
$(".book").replaceWith($pageBody);
|
||||
$('.book-summary .summary').scrollTop(scrollPosition);
|
||||
|
||||
// Update state
|
||||
@@ -134,7 +133,7 @@ define([
|
||||
if (url) handleNavigation(url, true);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var init = function() {
|
||||
// Prevent cache so that using the back button works
|
||||
@@ -157,7 +156,7 @@ define([
|
||||
$(document).on('click', ".navigation-prev", handlePagination);
|
||||
$(document).on('click', ".navigation-next", handlePagination);
|
||||
$(document).on('click', ".summary [data-path] a", handlePagination);
|
||||
|
||||
|
||||
$(window).resize(updateNavigationPosition);
|
||||
|
||||
// Prepare current page
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
.book {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.book-body {
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
top: @header-height;
|
||||
right: 0px;
|
||||
left: 0px;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
.book-header {
|
||||
font-family: @font-family-sans;
|
||||
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
overflow: visible;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal {
|
||||
padding: 25px 0px;
|
||||
padding-bottom: 25px;
|
||||
padding-top: 15px;
|
||||
color:@page-color;
|
||||
|
||||
@@ -72,25 +72,25 @@
|
||||
font-size: inherit; }
|
||||
|
||||
h1 {
|
||||
font-size: 28px;
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
font-size: 2em;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 18px; }
|
||||
font-size: 1.5em; }
|
||||
|
||||
h4 {
|
||||
font-size: 16px; }
|
||||
font-size: 1.2em; }
|
||||
|
||||
h5 {
|
||||
font-size: 14px; }
|
||||
font-size: 1em; }
|
||||
|
||||
h6 {
|
||||
font-size: 14px; }
|
||||
font-size: 1em; }
|
||||
|
||||
p, blockquote, ul, ol, dl, table, pre {
|
||||
margin: 15px 0; }
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
width: 50%;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
|
||||
&.navigation-unique {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
width: 100%;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.bar {
|
||||
height: @bar-height;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
.book-summary {
|
||||
font-family: @font-family-sans;
|
||||
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
top: @header-height;
|
||||
left: -@sidebar-width;
|
||||
bottom: 0px;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
{% if githubId %}
|
||||
<a href="{{ githubHost }}{{ githubId }}" target="_blank" class="btn pull-left"><i class="fa fa-github-alt"></i></a>
|
||||
{% if options.links.home !== false and (options.links.home != null or githubId) %}
|
||||
<a href="{{ options.links.home|default(githubHost+githubId) }}" target="_blank" class="btn pull-left"><i class="fa fa-bookmark-o"></i></a>
|
||||
{% endif %}
|
||||
<a href="#" class="btn pull-left toggle-summary"><i class="fa fa-align-justify"></i></a>
|
||||
<a href="#" class="btn pull-left toggle-search"><i class="fa fa-search"></i></a>
|
||||
@@ -12,13 +12,19 @@
|
||||
</span>
|
||||
|
||||
<!-- Actions Right -->
|
||||
{% if options.links.sharing.google !== false %}
|
||||
<a href="#" target="_blank" class="btn pull-right" data-sharing="google-plus"><i class="fa fa-google-plus"></i></a>
|
||||
{% endif %}
|
||||
{% if options.links.sharing.facebook !== false %}
|
||||
<a href="#" target="_blank" class="btn pull-right" data-sharing="facebook"><i class="fa fa-facebook"></i></a>
|
||||
{% endif %}
|
||||
{% if options.links.sharing.twitter !== false %}
|
||||
<a href="#" target="_blank" class="btn pull-right" data-sharing="twitter"><i class="fa fa-twitter"></i></a>
|
||||
{% endif %}
|
||||
|
||||
{% if githubId %}
|
||||
<a href="{{ githubHost }}{{ githubId }}/stargazers" target="_blank" class="btn pull-right count-star"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
|
||||
<a href="{{ githubHost }}{{ githubId }}/watchers" target="_blank" class="btn pull-right count-watch"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a>
|
||||
<a href="{{ githubHost }}{{ githubId }}/stargazers" target="_blank" class="btn pull-right count-star hidden-xs"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
|
||||
<a href="{{ githubHost }}{{ githubId }}/watchers" target="_blank" class="btn pull-right count-watch hidden-xs"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
@@ -3,18 +3,28 @@
|
||||
<input type="text" placeholder="Search" class="form-control" />
|
||||
</div>
|
||||
<ul class="summary">
|
||||
{% if githubId %}
|
||||
{% if options.links.about !== false && (options.links.about != null || githubId) %}
|
||||
<li>
|
||||
<a href="{{ githubHost }}{{ githubAuthor }}" target="blank">About the author</a>
|
||||
<a href="{{ options.links.about|default(githubHost+githubAuthor) }}" target="blank">About the author</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if options.links.issues !== false && (options.links.issues != null || githubId) %}
|
||||
<li>
|
||||
<a href="{{ githubHost }}{{ githubId }}/issues" target="blank">Questions and Issues</a>
|
||||
<a href="{{ options.links.issues|default(githubHost+githubId+"/issues") }}" target="blank">Questions and Issues</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if options.links.contribute !== false && (options.links.contribute != null || githubId) %}
|
||||
<li>
|
||||
<a href="{{ githubHost }}{{ githubId }}/edit/master/{{ _input }}" target="blank">Edit and Contribute</a>
|
||||
<a href="{{ options.links.contribute|default(githubHost+githubId+"/edit/master/"+_input) }}" target="blank">Edit and Contribute</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if options.links.contribute || options.links.issues || options.links.about || githubId %}
|
||||
<li class="divider"></li>
|
||||
{% endif %}
|
||||
|
||||
<li data-level="0" data-path="index.html">
|
||||
<a href="{{ basePath }}/"><i class="fa fa-check"></i> Introduction</a>
|
||||
</li>
|
||||
@@ -44,5 +54,12 @@
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% if options.links.gitbook !== false %}
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a href="http://www.gitbook.io/" target="blank">Generated using GitBook</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
</div>
|
||||
|
||||
{% if progress.current.prev and progress.current.prev.path %}
|
||||
<a href="{{ basePath }}/{{ progress.current.prev.path|mdLink }}" class="navigation navigation-prev"><i class="fa fa-angle-left"></i></a>
|
||||
<a href="{{ basePath }}/{{ progress.current.prev.path|mdLink }}" class="navigation navigation-prev {% if !progress.current.next or !progress.current.next.path %}navigation-unique{% endif %}"><i class="fa fa-angle-left"></i></a>
|
||||
{% endif %}
|
||||
{% if progress.current.next and progress.current.next.path %}
|
||||
<a href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" class="navigation navigation-next"><i class="fa fa-angle-right"></i></a>
|
||||
<a href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" class="navigation navigation-next {% if !progress.current.prev or !progress.current.prev.path %}navigation-unique{% endif %}"><i class="fa fa-angle-right"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user