mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 07:35:16 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05943db3b5 | |||
| 682fabd1ef | |||
| ee8ccc6d7e | |||
| 8ee0bcac2a | |||
| 0c4ad74788 | |||
| 7d944e4f1f | |||
| 67b2394c16 | |||
| 269d08a35f |
+10
@@ -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.5.0-beta.4
|
||||
- Fix compatibility for some plugins (like `autocover`)
|
||||
- Fix position of sidebar toggle button when glossary button is present
|
||||
|
||||
## 2.5.0-beta.3
|
||||
- Fix installation of plugins when using a pre-release
|
||||
|
||||
## 2.5.0-beta.2
|
||||
- Fix support for pre-releases
|
||||
|
||||
## 2.5.0-beta.1
|
||||
- Font settings, sharing and search are externalized as default plugins
|
||||
- Plugins can define a configuration schema in the manifest, this schema will be used to validate configuration during build
|
||||
|
||||
@@ -222,9 +222,9 @@ To use the latest commit from `GitBook/gitbook` with `gitbook-cli`:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/GitbookIO/gitbook.git ./gitbook
|
||||
$ gitbook versions:link 2.0.0 ./gitbook
|
||||
$ gitbook versions:link ./gitbook
|
||||
```
|
||||
|
||||
Now the version tag `2.0.0` wil be associated with the `./gitbook` folder.
|
||||
Now `gitbook-cli` will be using the `./gitbook` folder.
|
||||
|
||||
You can uninstall it using: `gitbook versions:uninstall 2.0.0`.
|
||||
You can uninstall it using: `gitbook versions:uninstall latest`.
|
||||
|
||||
+25
-24
@@ -5,6 +5,7 @@ var semver = require('semver');
|
||||
|
||||
var pkg = require('../package.json');
|
||||
var i18n = require('./utils/i18n');
|
||||
var version = require('./version');
|
||||
|
||||
var DEFAULT_CONFIG = require('./config_default');
|
||||
|
||||
@@ -83,31 +84,8 @@ function normalizePluginsList(plugins, addDefaults) {
|
||||
}
|
||||
|
||||
var Configuration = function(book, options) {
|
||||
var that = this;
|
||||
|
||||
this.book = book;
|
||||
this.replace(options);
|
||||
|
||||
// options.input == book.root
|
||||
Object.defineProperty(this.options, 'input', {
|
||||
get: function () {
|
||||
return that.book.root;
|
||||
}
|
||||
});
|
||||
|
||||
// options.originalInput == book.parent.root
|
||||
Object.defineProperty(this.options, 'originalInput', {
|
||||
get: function () {
|
||||
return that.book.parent? that.book.parent.root : undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// options.originalOutput == book.parent.options.output
|
||||
Object.defineProperty(this.options, 'originalOutput', {
|
||||
get: function () {
|
||||
return that.book.parent? that.book.parent.options.output : undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Read and parse the configuration
|
||||
@@ -139,7 +117,7 @@ Configuration.prototype.load = function() {
|
||||
})
|
||||
.then(function() {
|
||||
if (!that.book.isSubBook()) {
|
||||
if (!semver.satisfies(pkg.version, that.options.gitbook)) {
|
||||
if (!version.satisfies(that.options.gitbook)) {
|
||||
throw new Error('GitBook version doesn\'t satisfy version required by the book: '+that.options.gitbook);
|
||||
}
|
||||
if (that.options.gitbook != '*' && !semver.satisfies(semver.inc(pkg.version, 'patch'), that.options.gitbook)) {
|
||||
@@ -170,8 +148,31 @@ Configuration.prototype.extend = function(options) {
|
||||
|
||||
// Replace the whole configuration
|
||||
Configuration.prototype.replace = function(options) {
|
||||
var that = this;
|
||||
|
||||
this.options = _.cloneDeep(DEFAULT_CONFIG);
|
||||
this.options = _.merge(this.options, options || {});
|
||||
|
||||
// options.input == book.root
|
||||
Object.defineProperty(this.options, 'input', {
|
||||
get: function () {
|
||||
return that.book.root;
|
||||
}
|
||||
});
|
||||
|
||||
// options.originalInput == book.parent.root
|
||||
Object.defineProperty(this.options, 'originalInput', {
|
||||
get: function () {
|
||||
return that.book.parent? that.book.parent.root : undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// options.originalOutput == book.parent.options.output
|
||||
Object.defineProperty(this.options, 'originalOutput', {
|
||||
get: function () {
|
||||
return that.book.parent? that.book.parent.options.output : undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Dump configuration as json object
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
var _ = require('lodash');
|
||||
var Q = require('q');
|
||||
var semver = require('semver');
|
||||
var path = require('path');
|
||||
var url = require('url');
|
||||
var fs = require('./utils/fs');
|
||||
@@ -9,7 +8,7 @@ var mergeDefaults = require('merge-defaults');
|
||||
var jsonschema = require('jsonschema');
|
||||
var jsonSchemaDefaults = require('json-schema-defaults');
|
||||
|
||||
var pkg = require('../package.json');
|
||||
var version = require('./version');
|
||||
|
||||
var PLUGIN_PREFIX = 'gitbook-plugin-';
|
||||
|
||||
@@ -145,7 +144,7 @@ Plugin.prototype.isValid = function() {
|
||||
this.packageInfos.name &&
|
||||
this.packageInfos.engines &&
|
||||
this.packageInfos.engines.gitbook &&
|
||||
semver.satisfies(pkg.version, this.packageInfos.engines.gitbook)
|
||||
version.satisfies(this.packageInfos.engines.gitbook)
|
||||
);
|
||||
|
||||
// Valid hooks
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ var npm = require('npm');
|
||||
var semver = require('semver');
|
||||
|
||||
var Plugin = require('./plugin');
|
||||
var pkg = require('../package.json');
|
||||
var version = require('./version');
|
||||
|
||||
var initNPM = _.memoize(function() {
|
||||
return Q.nfcall(npm.load, { silent: true, loglevel: 'silent' });
|
||||
@@ -191,7 +191,7 @@ PluginsList.prototype.install = function() {
|
||||
};
|
||||
})
|
||||
.filter(function(v) {
|
||||
return v.gitbook && semver.satisfies(pkg.version, v.gitbook);
|
||||
return v.gitbook && version.satisfies(v.gitbook);
|
||||
})
|
||||
.sort(function(v1, v2) {
|
||||
return semver.lt(v1.version, v2.version)? 1 : -1;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
var semver = require('semver');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
var VERSION = pkg.version;
|
||||
var VERSION_STABLE = VERSION.replace(/\-(\S+)/g, '');
|
||||
|
||||
// Test if current current gitbook version satisfies a condition
|
||||
// We can't directly use samver.satisfies since it will break all plugins when gitbook version is a prerelease (beta, alpha)
|
||||
function satisfies(condition) {
|
||||
// Test with real version
|
||||
if (semver.satisfies(VERSION, condition)) return true;
|
||||
|
||||
// Test with future stable release
|
||||
return semver.satisfies(VERSION_STABLE, condition);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
satisfies: satisfies
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "2.5.0-beta.1",
|
||||
"version": "2.5.0-beta.4",
|
||||
"homepage": "https://www.gitbook.com",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
|
||||
@@ -24073,6 +24073,7 @@ function start(config) {
|
||||
|
||||
// Add action to toggle sidebar
|
||||
toolbar.createButton({
|
||||
index: 0,
|
||||
icon: 'fa fa-align-justify',
|
||||
onClick: function(e) {
|
||||
e.preventDefault();
|
||||
@@ -24466,6 +24467,18 @@ var events = require('./events');
|
||||
// List of created buttons
|
||||
var buttons = [];
|
||||
|
||||
// Insert a jquery element at a specific position
|
||||
function insertAt(parent, selector, index, element) {
|
||||
var lastIndex = parent.children(selector).size();
|
||||
if (index < 0) {
|
||||
index = Math.max(0, lastIndex + 1 + index);
|
||||
}
|
||||
parent.append(element);
|
||||
|
||||
if (index < lastIndex) {
|
||||
parent.children(selector).eq(index).before(parent.children(selector).last());
|
||||
}
|
||||
}
|
||||
|
||||
// Default click handler
|
||||
function defaultOnClick(e) {
|
||||
@@ -24543,7 +24556,10 @@ function createButton(opts) {
|
||||
onClick: defaultOnClick,
|
||||
|
||||
// Button is a dropdown
|
||||
dropdown: null
|
||||
dropdown: null,
|
||||
|
||||
// Position in the toolbar
|
||||
index: null
|
||||
});
|
||||
|
||||
buttons.push(opts);
|
||||
@@ -24552,6 +24568,7 @@ function createButton(opts) {
|
||||
|
||||
// Update a button
|
||||
function updateButton(opts) {
|
||||
var $result;
|
||||
var $toolbar = $('.book-header');
|
||||
var $title = $toolbar.find('h1');
|
||||
|
||||
@@ -24593,12 +24610,17 @@ function updateButton(opts) {
|
||||
$menu.addClass('dropdown-'+(opts.position == 'right'? 'left' : 'right'));
|
||||
|
||||
$container.append($menu);
|
||||
|
||||
$container.insertBefore($title);
|
||||
$result = $container;
|
||||
} else {
|
||||
$btn.addClass(positionClass);
|
||||
$btn.addClass(opts.className);
|
||||
$btn.insertBefore($title);
|
||||
$result = $btn;
|
||||
}
|
||||
|
||||
if (_.isNumber(opts.index) && opts.index >= 0) {
|
||||
insertAt($toolbar, '.btn, .dropdown', opts.index, $result);
|
||||
} else {
|
||||
$result.insertBefore($title);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ function start(config) {
|
||||
|
||||
// Add action to toggle sidebar
|
||||
toolbar.createButton({
|
||||
index: 0,
|
||||
icon: 'fa fa-align-justify',
|
||||
onClick: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -6,6 +6,18 @@ var events = require('./events');
|
||||
// List of created buttons
|
||||
var buttons = [];
|
||||
|
||||
// Insert a jquery element at a specific position
|
||||
function insertAt(parent, selector, index, element) {
|
||||
var lastIndex = parent.children(selector).size();
|
||||
if (index < 0) {
|
||||
index = Math.max(0, lastIndex + 1 + index);
|
||||
}
|
||||
parent.append(element);
|
||||
|
||||
if (index < lastIndex) {
|
||||
parent.children(selector).eq(index).before(parent.children(selector).last());
|
||||
}
|
||||
}
|
||||
|
||||
// Default click handler
|
||||
function defaultOnClick(e) {
|
||||
@@ -83,7 +95,10 @@ function createButton(opts) {
|
||||
onClick: defaultOnClick,
|
||||
|
||||
// Button is a dropdown
|
||||
dropdown: null
|
||||
dropdown: null,
|
||||
|
||||
// Position in the toolbar
|
||||
index: null
|
||||
});
|
||||
|
||||
buttons.push(opts);
|
||||
@@ -92,6 +107,7 @@ function createButton(opts) {
|
||||
|
||||
// Update a button
|
||||
function updateButton(opts) {
|
||||
var $result;
|
||||
var $toolbar = $('.book-header');
|
||||
var $title = $toolbar.find('h1');
|
||||
|
||||
@@ -133,12 +149,17 @@ function updateButton(opts) {
|
||||
$menu.addClass('dropdown-'+(opts.position == 'right'? 'left' : 'right'));
|
||||
|
||||
$container.append($menu);
|
||||
|
||||
$container.insertBefore($title);
|
||||
$result = $container;
|
||||
} else {
|
||||
$btn.addClass(positionClass);
|
||||
$btn.addClass(opts.className);
|
||||
$btn.insertBefore($title);
|
||||
$result = $btn;
|
||||
}
|
||||
|
||||
if (_.isNumber(opts.index) && opts.index >= 0) {
|
||||
insertAt($toolbar, '.btn, .dropdown', opts.index, $result);
|
||||
} else {
|
||||
$result.insertBefore($title);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user