summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-09-19 11:33:19 +0200
committerSamy Pessé <samypesse@gmail.com>2016-09-19 11:33:23 +0200
commit2796065886d824ae7fe7060dafa6fdcbd26d5f93 (patch)
tree4df39fe6e88d88c187623e505fb4e8a8103fa13b
parent82c2c214eb5179538c925460f1d3e823dbba47e2 (diff)
downloadgitbook-2796065886d824ae7fe7060dafa6fdcbd26d5f93.zip
gitbook-2796065886d824ae7fe7060dafa6fdcbd26d5f93.tar.gz
gitbook-2796065886d824ae7fe7060dafa6fdcbd26d5f93.tar.bz2
Add base for gitbook-plugin builder
-rw-r--r--.gitignore1
-rw-r--r--packages/gitbook-plugin-sharing/index.js9
-rw-r--r--packages/gitbook-plugin-sharing/package.json72
-rw-r--r--packages/gitbook-plugin-sharing/src/Button.js17
-rw-r--r--packages/gitbook-plugin-sharing/src/index.js6
-rw-r--r--packages/gitbook-plugin-theme-default/assets/.gitkeep0
-rw-r--r--packages/gitbook-plugin/package.json33
-rw-r--r--packages/gitbook-plugin/src/cli.js22
-rw-r--r--packages/gitbook-plugin/src/index.js0
-rw-r--r--packages/gitbook/src/output/website/onPage.js28
10 files changed, 160 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore
index ca733f3..a9b58d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@ node_modules
# GitBook with babel
/packages/gitbook/lib
/packages/gitbook-core/lib
+/packages/gitbook-plugin/lib
# Output of documentation
_book
diff --git a/packages/gitbook-plugin-sharing/index.js b/packages/gitbook-plugin-sharing/index.js
new file mode 100644
index 0000000..5217cad
--- /dev/null
+++ b/packages/gitbook-plugin-sharing/index.js
@@ -0,0 +1,9 @@
+
+module.exports = {
+ website: {
+ assets: './assets',
+ plugins: [
+ './src/index.js'
+ ]
+ }
+};
diff --git a/packages/gitbook-plugin-sharing/package.json b/packages/gitbook-plugin-sharing/package.json
new file mode 100644
index 0000000..0ca8dc5
--- /dev/null
+++ b/packages/gitbook-plugin-sharing/package.json
@@ -0,0 +1,72 @@
+{
+ "name": "gitbook-plugin-sharing",
+ "description": "Sharing buttons in GitBooks website",
+ "main": "index.js",
+ "version": "1.0.2",
+ "dependencies": {
+
+ },
+ "engines": {
+ "gitbook": ">=3.0.0"
+ },
+ "homepage": "https://github.com/GitbookIO/plugin-sharing",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/GitbookIO/plugin-sharing.git"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/GitbookIO/plugin-sharing/issues"
+ },
+ "gitbook": {
+ "properties": {
+ "facebook": {
+ "type": "boolean",
+ "default": true,
+ "title": "Facebook"
+ },
+ "twitter": {
+ "type": "boolean",
+ "default": true,
+ "title": "Twitter"
+ },
+ "google": {
+ "type": "boolean",
+ "default": false,
+ "title": "Google"
+ },
+ "weibo": {
+ "type": "boolean",
+ "default": false,
+ "description": "Weibo"
+ },
+ "instapaper": {
+ "type": "boolean",
+ "default": false,
+ "description": "Instapaper"
+ },
+ "vk": {
+ "type": "boolean",
+ "default": false,
+ "description": "VK"
+ },
+ "all": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [
+ "facebook",
+ "google",
+ "twitter",
+ "weibo",
+ "instapaper"
+ ],
+ "uniqueItems": true
+ }
+ }
+ },
+ "devDependencies": {
+ "eslint": "^2.7.0"
+ }
+}
diff --git a/packages/gitbook-plugin-sharing/src/Button.js b/packages/gitbook-plugin-sharing/src/Button.js
new file mode 100644
index 0000000..0cfce7c
--- /dev/null
+++ b/packages/gitbook-plugin-sharing/src/Button.js
@@ -0,0 +1,17 @@
+const React = require('react');
+const GitBook = require('gitbook-core');
+
+const ShareButton = React.createClass({
+ render() {
+ return (
+ <button>Share</button>
+ );
+ }
+});
+
+function mapStateToProps(state) {
+
+}
+
+
+module.exports = GitBook.connect(ShareButton, mapStateToProps);
diff --git a/packages/gitbook-plugin-sharing/src/index.js b/packages/gitbook-plugin-sharing/src/index.js
new file mode 100644
index 0000000..e33a470
--- /dev/null
+++ b/packages/gitbook-plugin-sharing/src/index.js
@@ -0,0 +1,6 @@
+const GitBook = require('gitbook-core');
+const ShareButton = require('./Button');
+
+module.exports = GitBook.createPlugin((dispatch, state) => {
+ dispatch(GitBook.registerComponent(ShareButton, { role: 'Toolbar:ActionButton' }));
+});
diff --git a/packages/gitbook-plugin-theme-default/assets/.gitkeep b/packages/gitbook-plugin-theme-default/assets/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/packages/gitbook-plugin-theme-default/assets/.gitkeep
diff --git a/packages/gitbook-plugin/package.json b/packages/gitbook-plugin/package.json
new file mode 100644
index 0000000..e8b6983
--- /dev/null
+++ b/packages/gitbook-plugin/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "gitbook-plugin",
+ "version": "0.0.0",
+ "description": "CLI for compiling and testing plugins",
+ "main": "./lib/index.js",
+ "dependencies": {
+ "babelify": "^7.3.0",
+ "browserify": "^13.1.0",
+ "commander": "^2.9.0"
+ },
+ "devDependencies": {
+ "babel-cli": "^6.14.0",
+ "babel-preset-es2015": "^6.14.0",
+ "babel-preset-react": "^6.11.1",
+ "babel-preset-stage-2": "^6.13.0"
+ },
+ "bin": {
+ "gitbook-plugin": "./lib/cli.js"
+ },
+ "scripts": {
+ "dist": "rm -rf lib/ && babel -d lib/ src/",
+ "prepublish": "npm run dist"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/GitbookIO/gitbook.git"
+ },
+ "author": "GitBook Inc. <contact@gitbook.com>",
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/GitbookIO/gitbook/issues"
+ }
+}
diff --git a/packages/gitbook-plugin/src/cli.js b/packages/gitbook-plugin/src/cli.js
new file mode 100644
index 0000000..e1f201b
--- /dev/null
+++ b/packages/gitbook-plugin/src/cli.js
@@ -0,0 +1,22 @@
+const program = require('commander');
+const pkg = require('../package.json');
+
+program.version(pkg.version)
+
+program
+ .command('build [plugin]')
+ .description('build a plugin')
+ .action(function(plugin, options) {
+
+ });
+
+
+program
+ .command('test [plugin]')
+ .description('test specs for a plugin')
+ .action(function(plugin, options) {
+
+ });
+
+
+program.parse(process.argv);
diff --git a/packages/gitbook-plugin/src/index.js b/packages/gitbook-plugin/src/index.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/packages/gitbook-plugin/src/index.js
diff --git a/packages/gitbook/src/output/website/onPage.js b/packages/gitbook/src/output/website/onPage.js
index 41c4b1b..eb97d20 100644
--- a/packages/gitbook/src/output/website/onPage.js
+++ b/packages/gitbook/src/output/website/onPage.js
@@ -1,7 +1,5 @@
const path = require('path');
-const omit = require('omit-keys');
-const Templating = require('../../templating');
const Plugins = require('../../plugins');
const JSONUtils = require('../../json');
const LocationUtils = require('../../utils/location');
@@ -19,25 +17,14 @@ const render = require('./render');
* @param {Page} page
*/
function onPage(output, page) {
- const options = output.getOptions();
- const prefix = options.get('prefix');
-
const file = page.getFile();
-
- const book = output.getBook();
const plugins = output.getPlugins();
const state = output.getState();
const resources = state.getResources();
- const engine = createTemplateEngine(output, page.getPath());
-
// Output file path
const filePath = fileToOutput(output, file.getPath());
- // Calcul relative path to the root
- const outputDirName = path.dirname(filePath);
- const basePath = LocationUtils.normalize(path.relative(outputDirName, './'));
-
return Modifiers.modifyHTML(page, getModifiers(output, page))
.then(function(resultPage) {
// Generate the context
@@ -46,21 +33,6 @@ function onPage(output, page) {
resources: Plugins.listResources(plugins, resources).toJS()
};
- /*context.template = {
- getJSContext() {
- return {
- page: omit(context.page, 'content'),
- config: context.config,
- file: context.file,
- gitbook: context.gitbook,
- basePath,
- book: {
- language: book.getLanguage()
- }
- };
- }
- };*/
-
// We should probabbly move it to "template" or a "site" namespace
// context.basePath = basePath;