diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-02 16:38:24 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-02 16:38:24 -0700 |
commit | 62a2e8f81c5dff5b47f064b70b6869f6e4b12996 (patch) | |
tree | e06291d5b22011980e8983507cc0e3ef3ad69c04 | |
parent | 6bcc2d8cf24d62ce7a48895cc8ef085f8bc71e4d (diff) | |
download | gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.zip gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.tar.gz gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.tar.bz2 |
Fix #8: Improve page title
-rw-r--r-- | lib/generate/template.js | 1 | ||||
-rw-r--r-- | lib/parse/navigation.js | 1 | ||||
-rw-r--r-- | lib/parse/progress.js | 14 | ||||
-rw-r--r-- | templates/layout.html | 2 | ||||
-rw-r--r-- | templates/page.html | 12 |
5 files changed, 19 insertions, 11 deletions
diff --git a/lib/generate/template.js b/lib/generate/template.js index d8c1f79..3edd4da 100644 --- a/lib/generate/template.js +++ b/lib/generate/template.js @@ -49,7 +49,6 @@ var initTemplate = function(options) { content: sections, basePath: basePath, staticBase: path.join(basePath, "gitbook"), - navigation: options.locals.allNavigation[_output], progress: parse.progress(options.locals.allNavigation, _output) }) ); 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 }; } diff --git a/templates/layout.html b/templates/layout.html index 735f5d3..e07b385 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -3,7 +3,7 @@ <head> {% block head %} <meta charset="UTF-8"> - <title>{% block title %} | GitBook{% endblock %}</title> + <title>{% block title %} | {{ title }}{% endblock %}</title> <meta name="robots" content="{% block robots %}noindex, nofollow{% endblock %}"> <link rel="shortcut icon" href="{{ staticBase }}/images/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="{{ staticBase }}/style.css"> diff --git a/templates/page.html b/templates/page.html index 01868cb..6f27b33 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,10 +1,10 @@ {% extends "layout.html" %} -{% block title %}{{ _input }} {{ title }}{% parent %}{% endblock %} +{% block title %}{{ progress.current.title }}{% parent %}{% endblock %} {% block description %}{% endblock %} {% block robots %}index, follow{% endblock %} {% block content %} -<div class="book {% if _input == "README.md" %}with-summary{% endif %}" data-github="{{ githubId }}" data-level="{{ navigation.level }}"> +<div class="book {% if _input == "README.md" %}with-summary{% endif %}" data-github="{{ githubId }}" data-level="{{ progress.current.level }}"> {% include "includes/book/header.html" %} {% include "includes/book/summary.html" %} <div class="book-body"> @@ -34,11 +34,11 @@ <div class="page-footer"> {% if _input == "README.md" %} - <a href="{{ basePath }}/{{ navigation.next.path }}" class="navigation-link">Start</a> + <a href="{{ basePath }}/{{ progress.current.next.path }}" class="navigation-link">Start</a> {% else %} - {% if navigation.next %} - {% if navigation.next.path %} - <a href="{{ basePath }}/{{ navigation.next.path }}" class="navigation-link next">Next</a> + {% if progress.current.next %} + {% if progress.current.next.path %} + <a href="{{ basePath }}/{{ progress.current.next.path }}" class="navigation-link next">Next</a> {% else %} <div class="navigation-link coming-soon">Coming soon</div> {% endif %} |