summaryrefslogtreecommitdiffstats
path: root/lib/parse
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-02 16:38:24 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-02 16:38:24 -0700
commit62a2e8f81c5dff5b47f064b70b6869f6e4b12996 (patch)
treee06291d5b22011980e8983507cc0e3ef3ad69c04 /lib/parse
parent6bcc2d8cf24d62ce7a48895cc8ef085f8bc71e4d (diff)
downloadgitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.zip
gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.tar.gz
gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.tar.bz2
Fix #8: Improve page title
Diffstat (limited to 'lib/parse')
-rw-r--r--lib/parse/navigation.js1
-rw-r--r--lib/parse/progress.js14
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/parse/navigation.js b/lib/parse/navigation.js
index 29b1a0c..9ed82b9 100644
--- a/lib/parse/navigation.js
+++ b/lib/parse/navigation.js
@@ -70,6 +70,7 @@ function navigation(summary, files) {
// Hack for README.html
mapping['README.html'] = {
+ title: README_NAV.title,
prev: null,
next: clean(summary.chapters[0]),
level: '0',
diff --git a/lib/parse/progress.js b/lib/parse/progress.js
index 73fbbe0..7259e07 100644
--- a/lib/parse/progress.js
+++ b/lib/parse/progress.js
@@ -2,7 +2,7 @@ var _ = require("lodash");
var calculProgress = function(navigation, current) {
var n = _.size(navigation);
- var percent = 0, prevPercent = 0;
+ var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = _.chain(navigation)
@@ -20,6 +20,7 @@ var calculProgress = function(navigation, current) {
// Is it done
nav.done = done;
if (nav.path == current) {
+ currentChapter = nav;
percent = nav.percent;
done = false;
} else if (done) {
@@ -30,11 +31,18 @@ var calculProgress = function(navigation, current) {
})
.value();
-
return {
+ // Previous percent
prevPercent: prevPercent,
+
+ // Current percent
percent: percent,
- chapters: chapters
+
+ // List of chapter with progress
+ chapters: chapters,
+
+ // Current chapter
+ current: currentChapter
};
}