summaryrefslogtreecommitdiffstats
path: root/theme
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-11-25 10:05:05 +0100
committerSamy Pessé <samypesse@gmail.com>2015-11-25 10:05:05 +0100
commitd5d6b3673ebccc2650bd03841011b1c7b11d8fd6 (patch)
tree2eae2df343ce0b5cc9261591f83d2c632088cf81 /theme
parentd2a2fe88d1a9e10df031216d90e17a57df513952 (diff)
downloadgitbook-d5d6b3673ebccc2650bd03841011b1c7b11d8fd6.zip
gitbook-d5d6b3673ebccc2650bd03841011b1c7b11d8fd6.tar.gz
gitbook-d5d6b3673ebccc2650bd03841011b1c7b11d8fd6.tar.bz2
Add bookRoot to gitbook.state
Diffstat (limited to 'theme')
-rw-r--r--theme/assets/website/app.js8
-rw-r--r--theme/javascript/state.js8
-rw-r--r--theme/templates/website/page.html8
3 files changed, 21 insertions, 3 deletions
diff --git a/theme/assets/website/app.js b/theme/assets/website/app.js
index 2434ad2..c9353c4 100644
--- a/theme/assets/website/app.js
+++ b/theme/assets/website/app.js
@@ -24743,6 +24743,9 @@ state.update = function(dom) {
state.level = $book.data('level');
state.basePath = $book.data('basepath');
+ // If book is multilingual, language of this book
+ state.innerlanguage = $book.data('innerlanguage');
+
// Date of build
state.revision = $book.data('revision');
@@ -24752,11 +24755,14 @@ state.update = function(dom) {
// Title of the chapter
state.chapterTitle = $book.data('chapter-title');
- // Absolute url to the root of the book
+ // Absolute url to the root of the book (inner book)
state.root = url.resolve(
location.protocol+'//'+location.host,
path.dirname(path.resolve(location.pathname.replace(/\/$/, '/index.html'), state.basePath))
);
+
+ // Absolute root to the language (for multilingual book)
+ state.bookRoot = state.innerlanguage? url.resolve(state.root, '..') : state.root;
};
state.update($);
diff --git a/theme/javascript/state.js b/theme/javascript/state.js
index fb91f7a..a6a7877 100644
--- a/theme/javascript/state.js
+++ b/theme/javascript/state.js
@@ -11,6 +11,9 @@ state.update = function(dom) {
state.level = $book.data('level');
state.basePath = $book.data('basepath');
+ // If book is multilingual, language of this book
+ state.innerlanguage = $book.data('innerlanguage');
+
// Date of build
state.revision = $book.data('revision');
@@ -20,11 +23,14 @@ state.update = function(dom) {
// Title of the chapter
state.chapterTitle = $book.data('chapter-title');
- // Absolute url to the root of the book
+ // Absolute url to the root of the book (inner book)
state.root = url.resolve(
location.protocol+'//'+location.host,
path.dirname(path.resolve(location.pathname.replace(/\/$/, '/index.html'), state.basePath))
);
+
+ // Absolute root to the language (for multilingual book)
+ state.bookRoot = state.innerlanguage? url.resolve(state.root, '..') : state.root;
};
state.update($);
diff --git a/theme/templates/website/page.html b/theme/templates/website/page.html
index 5b609ae..6c29164 100644
--- a/theme/templates/website/page.html
+++ b/theme/templates/website/page.html
@@ -14,7 +14,13 @@
{% block description %}{% if progress.current.level == "0" %}{{ description }}{% endif %}{% endblock %}
{% block content %}
- <div class="book" data-level="{{ progress.current.level }}" data-chapter-title="{{ progress.current.title }}" data-filepath="{{ progress.current.path }}" data-basepath="{{ basePath }}" data-revision="{{ revision }}">
+ <div class="book"
+ data-level="{{ progress.current.level }}"
+ data-chapter-title="{{ progress.current.title }}"
+ data-filepath="{{ progress.current.path }}"
+ data-basepath="{{ basePath }}"
+ data-revision="{{ revision }}"
+ data-innerlanguage="{{ innerlanguage }}">
{% include "includes/summary.html" %}
<div class="book-body">
<div class="body-inner">