diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-03-06 22:32:25 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-03-06 22:32:25 +0100 |
commit | 55a7b99b4d4b4902bed0d53fb1b219b0c5f4584a (patch) | |
tree | 5e33d27f7a61ee33ec1d341755475c7425a79ffe | |
parent | 8bfba604b3ae1a51012499d726ea99c6f256035d (diff) | |
download | gitbook-55a7b99b4d4b4902bed0d53fb1b219b0c5f4584a.zip gitbook-55a7b99b4d4b4902bed0d53fb1b219b0c5f4584a.tar.gz gitbook-55a7b99b4d4b4902bed0d53fb1b219b0c5f4584a.tar.bz2 |
Fix #227: Add base rtl support for website
-rw-r--r-- | lib/configuration.js | 17 | ||||
-rw-r--r-- | lib/utils/i18n.js | 4 | ||||
-rw-r--r-- | theme/templates/website/layout.html | 2 |
3 files changed, 16 insertions, 7 deletions
diff --git a/lib/configuration.js b/lib/configuration.js index 7316dd8..578f4e2 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -96,17 +96,23 @@ Configuration.prototype.load = function() { } }) .then(function() { + if (!semver.satisfies(pkg.version, that.options.gitbook)) { + throw "GitBook version doesn't satisfy version required by the book: "+that.options.gitbook; + } + 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.output = path.resolve(that.options.output || path.join(that.book.root, "_book")); that.options.plugins = normalizePluginsList(that.options.plugins); that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || ""); that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins); that.options.plugins = _.uniq(that.options.plugins, "name"); - if (!semver.satisfies(pkg.version, that.options.gitbook)) { - throw "GitBook version doesn't satisfy version required by the book: "+that.options.gitbook; - } - 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")); + // Default value for text direction (from language) + if (!that.options.direction) { + var lang = i18n.getByLanguage(that.options.language); + if (lang) that.options.direction = lang.direction; } that.options.gitbook = pkg.version; @@ -141,6 +147,7 @@ Configuration.DEFAULT = { "description": null, "isbn": null, "language": "en", + "direction": null, // version of gitbook to use "gitbook": "*", diff --git a/lib/utils/i18n.js b/lib/utils/i18n.js index d1b8966..d7560bd 100644 --- a/lib/utils/i18n.js +++ b/lib/utils/i18n.js @@ -9,7 +9,9 @@ var getLocales = _.memoize(function() { return _.chain(locales) .map(function(local) { local = path.basename(local, ".json"); - return [local, _.extend(require(path.join(I18N_PATH, local)), { + return [local, _.extend({ + direction: "ltr" + }, require(path.join(I18N_PATH, local)), { id: local })]; }) diff --git a/theme/templates/website/layout.html b/theme/templates/website/layout.html index e412c0c..9107de7 100644 --- a/theme/templates/website/layout.html +++ b/theme/templates/website/layout.html @@ -1,5 +1,5 @@ <!DOCTYPE HTML> -<html lang="{{ language }}"> +<html lang="{{ language }}" {% if options.direction == "rtl" %}dir="rtl"{% endif %}> {{ htmlSnippet("html:start")|default("")|safe }} <head> {{ htmlSnippet("head:start")|default("")|safe }} |