diff options
Diffstat (limited to 'lib/constants')
-rw-r--r-- | lib/constants/configDefault.js | 6 | ||||
-rw-r--r-- | lib/constants/configFiles.js | 5 | ||||
-rw-r--r-- | lib/constants/configSchema.js | 188 | ||||
-rw-r--r-- | lib/constants/defaultBlocks.js | 51 | ||||
-rw-r--r-- | lib/constants/defaultFilters.js | 15 | ||||
-rw-r--r-- | lib/constants/defaultPlugins.js | 14 | ||||
-rw-r--r-- | lib/constants/ignoreFiles.js | 6 | ||||
-rw-r--r-- | lib/constants/pluginAssetsFolder.js | 2 | ||||
-rw-r--r-- | lib/constants/pluginHooks.js | 8 | ||||
-rw-r--r-- | lib/constants/pluginPrefix.js | 5 | ||||
-rw-r--r-- | lib/constants/pluginResources.js | 6 | ||||
-rw-r--r-- | lib/constants/templatesFolder.js | 2 |
12 files changed, 308 insertions, 0 deletions
diff --git a/lib/constants/configDefault.js b/lib/constants/configDefault.js new file mode 100644 index 0000000..0d95883 --- /dev/null +++ b/lib/constants/configDefault.js @@ -0,0 +1,6 @@ +var Immutable = require('immutable'); +var jsonSchemaDefaults = require('json-schema-defaults'); + +var schema = require('./configSchema'); + +module.exports = Immutable.fromJS(jsonSchemaDefaults(schema)); diff --git a/lib/constants/configFiles.js b/lib/constants/configFiles.js new file mode 100644 index 0000000..a67fd74 --- /dev/null +++ b/lib/constants/configFiles.js @@ -0,0 +1,5 @@ +// Configuration files to test (sorted) +module.exports = [ + 'book.js', + 'book.json' +]; diff --git a/lib/constants/configSchema.js b/lib/constants/configSchema.js new file mode 100644 index 0000000..3fb2050 --- /dev/null +++ b/lib/constants/configSchema.js @@ -0,0 +1,188 @@ +module.exports = { + '$schema': 'http://json-schema.org/schema#', + 'id': 'https://gitbook.com/schemas/book.json', + 'title': 'GitBook Configuration', + 'type': 'object', + 'properties': { + 'root': { + 'type': 'string', + 'title': 'Path fro the root folder containing the book\'s content' + }, + 'title': { + 'type': 'string', + 'title': 'Title of the book, default is extracted from README' + }, + 'isbn': { + 'type': 'string', + 'title': 'ISBN for published book' + }, + 'author': { + 'type': 'string', + 'title': 'Name of the author' + }, + 'gitbook': { + 'type': 'string', + 'default': '*', + 'title': 'GitBook version to match' + }, + 'direction': { + 'type': 'string', + 'enum': ['ltr', 'rtl'], + 'title': 'Direction of texts, default is detected in the pages' + }, + 'theme': { + 'type': 'string', + 'default': 'default', + 'title': 'Name of the theme plugin to use' + }, + 'variables': { + 'type': 'object', + 'title': 'Templating context variables' + }, + 'plugins': { + 'oneOf': [ + { '$ref': '#/definitions/pluginsArray' }, + { '$ref': '#/definitions/pluginsString' } + ], + 'default': [] + }, + 'pluginsConfig': { + 'type': 'object', + 'title': 'Configuration for plugins' + }, + 'structure': { + 'type': 'object', + 'properties': { + 'langs': { + 'default': 'LANGS.md', + 'type': 'string', + 'title': 'File to use as languages index', + 'pattern': '^[0-9a-zA-Z ... ]+$' + }, + 'readme': { + 'default': 'README.md', + 'type': 'string', + 'title': 'File to use as preface', + 'pattern': '^[0-9a-zA-Z ... ]+$' + }, + 'glossary': { + 'default': 'GLOSSARY.md', + 'type': 'string', + 'title': 'File to use as glossary index', + 'pattern': '^[0-9a-zA-Z ... ]+$' + }, + 'summary': { + 'default': 'SUMMARY.md', + 'type': 'string', + 'title': 'File to use as table of contents', + 'pattern': '^[0-9a-zA-Z ... ]+$' + } + }, + 'additionalProperties': false + }, + 'pdf': { + 'type': 'object', + 'title': 'PDF specific configurations', + 'properties': { + 'pageNumbers': { + 'type': 'boolean', + 'default': true, + 'title': 'Add page numbers to the bottom of every page' + }, + 'fontSize': { + 'type': 'integer', + 'minimum': 8, + 'maximum': 30, + 'default': 12, + 'title': 'Font size for the PDF output' + }, + 'fontFamily': { + 'type': 'string', + 'default': 'Arial', + 'title': 'Font family for the PDF output' + }, + 'paperSize': { + 'type': 'string', + 'enum': ['a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'legal', 'letter'], + 'default': 'a4', + 'title': 'Paper size for the PDF' + }, + 'chapterMark': { + 'type': 'string', + 'enum': ['pagebreak', 'rule', 'both', 'none'], + 'default': 'pagebreak', + 'title': 'How to mark detected chapters' + }, + 'pageBreaksBefore': { + 'type': 'string', + 'default': '/', + 'title': 'An XPath expression. Page breaks are inserted before the specified elements. To disable use the expression: "/"' + }, + 'margin': { + 'type': 'object', + 'properties': { + 'right': { + 'type': 'integer', + 'title': 'Right Margin', + 'minimum': 0, + 'maximum': 100, + 'default': 62 + }, + 'left': { + 'type': 'integer', + 'title': 'Left Margin', + 'minimum': 0, + 'maximum': 100, + 'default': 62 + }, + 'top': { + 'type': 'integer', + 'title': 'Top Margin', + 'minimum': 0, + 'maximum': 100, + 'default': 56 + }, + 'bottom': { + 'type': 'integer', + 'title': 'Bottom Margin', + 'minimum': 0, + 'maximum': 100, + 'default': 56 + } + } + } + } + } + }, + 'required': [], + 'definitions': { + 'pluginsArray': { + 'type': 'array', + 'items': { + 'oneOf': [ + { '$ref': '#/definitions/pluginObject' }, + { '$ref': '#/definitions/pluginString' } + ] + } + }, + 'pluginsString': { + 'type': 'string' + }, + 'pluginString': { + 'type': 'string' + }, + 'pluginObject': { + 'type': 'object', + 'properties': { + 'name': { + 'type': 'string' + }, + 'version': { + 'type': 'string' + } + }, + 'additionalProperties': false, + 'required': ['name'] + } + } +}; diff --git a/lib/constants/defaultBlocks.js b/lib/constants/defaultBlocks.js new file mode 100644 index 0000000..74d1f1f --- /dev/null +++ b/lib/constants/defaultBlocks.js @@ -0,0 +1,51 @@ +var Immutable = require('immutable'); +var TemplateBlock = require('../models/templateBlock'); + +module.exports = Immutable.Map({ + html: TemplateBlock({ + name: 'html', + process: function(blk) { + return blk; + } + }), + + code: TemplateBlock({ + name: 'code', + process: function(blk) { + return { + html: false, + body: blk.body + }; + } + }), + + markdown: TemplateBlock({ + name: 'markdown', + process: function(blk) { + return this.book.renderInline('markdown', blk.body) + .then(function(out) { + return { body: out }; + }); + } + }), + + asciidoc: TemplateBlock({ + name: 'asciidoc', + process: function(blk) { + return this.book.renderInline('asciidoc', blk.body) + .then(function(out) { + return { body: out }; + }); + } + }), + + markup: TemplateBlock({ + name: 'markup', + process: function(blk) { + return this.book.renderInline(this.ctx.file.type, blk.body) + .then(function(out) { + return { body: out }; + }); + } + }) +}); diff --git a/lib/constants/defaultFilters.js b/lib/constants/defaultFilters.js new file mode 100644 index 0000000..35025cc --- /dev/null +++ b/lib/constants/defaultFilters.js @@ -0,0 +1,15 @@ +var Immutable = require('immutable'); +var moment = require('moment'); + +module.exports = Immutable.Map({ + // Format a date + // ex: 'MMMM Do YYYY, h:mm:ss a + date: function(time, format) { + return moment(time).format(format); + }, + + // Relative Time + dateFromNow: function(time) { + return moment(time).fromNow(); + } +}); diff --git a/lib/constants/defaultPlugins.js b/lib/constants/defaultPlugins.js new file mode 100644 index 0000000..e6ea2bb --- /dev/null +++ b/lib/constants/defaultPlugins.js @@ -0,0 +1,14 @@ +var Immutable = require('immutable'); + +/* + List of default plugins for all books, + default plugins should be installed in node dependencies of GitBook +*/ +module.exports = Immutable.List([ + 'highlight', + 'search', + 'lunr', + 'sharing', + 'fontsettings', + 'theme-default' +]); diff --git a/lib/constants/ignoreFiles.js b/lib/constants/ignoreFiles.js new file mode 100644 index 0000000..aac225e --- /dev/null +++ b/lib/constants/ignoreFiles.js @@ -0,0 +1,6 @@ +// Files containing ignore pattner (sorted by priority) +module.exports = [ + '.ignore', + '.gitignore', + '.bookignore' +]; diff --git a/lib/constants/pluginAssetsFolder.js b/lib/constants/pluginAssetsFolder.js new file mode 100644 index 0000000..cd44722 --- /dev/null +++ b/lib/constants/pluginAssetsFolder.js @@ -0,0 +1,2 @@ + +module.exports = '_assets'; diff --git a/lib/constants/pluginHooks.js b/lib/constants/pluginHooks.js new file mode 100644 index 0000000..2d5dcaa --- /dev/null +++ b/lib/constants/pluginHooks.js @@ -0,0 +1,8 @@ +module.exports = [ + 'init', + 'finish', + 'finish:before', + 'config', + 'page', + 'page:before' +]; diff --git a/lib/constants/pluginPrefix.js b/lib/constants/pluginPrefix.js new file mode 100644 index 0000000..c7f2dd0 --- /dev/null +++ b/lib/constants/pluginPrefix.js @@ -0,0 +1,5 @@ + +/* + All GitBook plugins are NPM packages starting with this prefix. +*/ +module.exports = 'gitbook-plugin-'; diff --git a/lib/constants/pluginResources.js b/lib/constants/pluginResources.js new file mode 100644 index 0000000..ae283bf --- /dev/null +++ b/lib/constants/pluginResources.js @@ -0,0 +1,6 @@ +var Immutable = require('immutable'); + +module.exports = Immutable.List([ + 'js', + 'css' +]); diff --git a/lib/constants/templatesFolder.js b/lib/constants/templatesFolder.js new file mode 100644 index 0000000..aad6a72 --- /dev/null +++ b/lib/constants/templatesFolder.js @@ -0,0 +1,2 @@ + +module.exports = '_layouts'; |