diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-10-12 11:32:45 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-10-12 11:32:45 +0200 |
commit | 7cee2484266bba3ec64e494f996d0514b716ec83 (patch) | |
tree | c063695eaa9fa9ce76411a21b37cfc516e0c5408 | |
parent | df1a82e0e4c45c314b941488a2c7e22e6fe5b55a (diff) | |
download | gitbook-7cee2484266bba3ec64e494f996d0514b716ec83.zip gitbook-7cee2484266bba3ec64e494f996d0514b716ec83.tar.gz gitbook-7cee2484266bba3ec64e494f996d0514b716ec83.tar.bz2 |
Generate multiple page for ebook
-rw-r--r-- | lib/generate/ebook/index.js | 3 | ||||
-rw-r--r-- | lib/generate/page/index.js | 16 | ||||
-rw-r--r-- | theme/templates/page.html | 78 | ||||
-rw-r--r-- | theme/templates/site.html | 3 |
4 files changed, 20 insertions, 80 deletions
diff --git a/lib/generate/ebook/index.js b/lib/generate/ebook/index.js index 0e1cd4e..5557559 100644 --- a/lib/generate/ebook/index.js +++ b/lib/generate/ebook/index.js @@ -40,7 +40,8 @@ Generator.prototype.finish = function() { "--level1-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]", "--level2-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]", "--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]", - "--no-chapters-in-toc": true + "--no-chapters-in-toc": true, + "--max-levels": "1000" }; if (format == "pdf") { diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js index 9e48a5e..33c489a 100644 --- a/lib/generate/page/index.js +++ b/lib/generate/page/index.js @@ -29,7 +29,7 @@ Generator.prototype.loadTemplates = function() { this.plugins.template("page") || path.resolve(this.options.theme, 'templates/page.html') ); }; - +/* Generator.prototype.convertFile = function(content, input) { var that = this; var json = { @@ -43,10 +43,7 @@ Generator.prototype.convertFile = function(content, input) { }); }; -// Generate languages index -Generator.prototype.langsIndex = function(langs) { - return Q(); -}; +*/ Generator.prototype.finish = function() { var that = this; @@ -58,13 +55,13 @@ Generator.prototype.finish = function() { return Q() // Generate html .then(function(pages) { - return that._writeTemplate(that.template, { + /* return that._writeTemplate(that.template, { pages: that.pages, progress: progress, basePath: basePath, staticBase: path.join(basePath, "gitbook"), - }, output); + }, output);*/ }) // Copy cover @@ -78,4 +75,9 @@ Generator.prototype.finish = function() { }); }; +// Generate languages index +Generator.prototype.langsIndex = function(langs) { + return Q(); +}; + module.exports = Generator;
\ No newline at end of file diff --git a/theme/templates/page.html b/theme/templates/page.html index 5966cda..2f74fcf 100644 --- a/theme/templates/page.html +++ b/theme/templates/page.html @@ -1,6 +1,6 @@ {% extends "layout.html" %} -{% block title %}{{ title }}{% endblock %} +{% block title %}{{ progress.current.title }} | {{ title }}{% endblock %} {% block style %} <link rel="stylesheet" href="{{ staticBase }}/print.css"> @@ -13,82 +13,22 @@ {% endfor %} {% endblock %} - -{% macro articleContent(content) %} +{% block content %} + <h1 class="book-chapter book-chapter-{{ progress.current.level|lvl }}">{{ progress.current.title }}</h1> {% for section in content %} + <section class="{{ section.type }}" id="section-{{ section.id }}"> {% if section.type == "normal" %} {% autoescape false %}{{ section.content }}{% endautoescape %} {% elif section.type == "exercise" %} - <div class="exercise"> - <div class="exercise-header">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - <pre><code>{% autoescape false %}{{ section.code.base|code }}{% endautoescape %}</code></pre> - {% set exercise = exercise + 1 %} - </div> + {% include "./includes/book/exercise.html" with {section: section} %} {% elif section.type == "quiz" %} - <div class="quiz"> - <div class="exercise-header">Quiz #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% for quiz in section.quiz %} - <div class="question"> - <div class="question-header">Question {{ loop.index }} of {{ section.quiz.length }}</div> - {% autoescape false %}{{ quiz.base }}{% endautoescape %} - </div> - {% endfor %} - {% set exercise = exercise + 1 %} - </div> + {% include "./includes/book/quiz.html" with {section: section} %} {% endif %} + </section> {% endfor %} -{% endmacro %} - -{% set exercise = 1 %} -{% block content %} - {# Pages content #} - {% for item in progress.chapters %} - <article id="{{ article.path }}"> - <h1 class="book-chapter book-chapter-{{ item.level|lvl }}">{{ item.title }}</h1> - {% if pages[item.path] %} - {{ articleContent(pages[item.path].sections) }} - {% endif %} - </article> - {% endfor %} - - - {# Exercise solutions #} - {% if exercise > 1 %} - {% set exercise = 1 %} - <article> - <h1 class="book-chapter book-chapter-1">Exercise Solutions</h1> - <h1>Exercise Solutions</h1> - {% for item in progress.chapters %} - {% if pages[item.path] %} - {% for section in pages[item.path].sections %} - {% if section.type == "exercise" %} - <div class="exercise"> - <div class="exercise-header">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - <pre><code>{% autoescape false %}{{ section.code.solution|code }}{% endautoescape %}</code></pre> - {% set exercise = exercise + 1 %} - </div> - {% elif section.type == "quiz" %} - <div class="quiz"> - <div class="exercise-header">Quiz #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% for quiz in section.quiz %} - <div class="question"> - <div class="question-header">Question {{ loop.index }} of {{ section.quiz.length }}</div> - {% autoescape false %}{{ quiz.solution }}{% endautoescape %} - </div> - {% endfor %} - {% set exercise = exercise + 1 %} - </div> - {% endif %} - {% endfor %} - {% endif %} - {% endfor %} - </article> + {% if progress.current.next and progress.current.next.path %} + <a href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" /> {% endif %} {% endblock %} -{% block javascript %}{% endblock %} diff --git a/theme/templates/site.html b/theme/templates/site.html index cf90c9a..c0b4183 100644 --- a/theme/templates/site.html +++ b/theme/templates/site.html @@ -2,9 +2,6 @@ {% block head %} {% parent %} - {% if githubAuthor %} - <meta name="author" content="{{ githubAuthor }}"> - {% endif %} {% if progress.current.next and progress.current.next.path %} <link rel="next" href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" /> {% endif %} |