diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-10-13 10:41:23 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-10-13 10:41:23 +0200 |
commit | 1da341741b4e5f2cee3bb60fbd3b546708e2ef82 (patch) | |
tree | b047aaca8c26f1316b2f9b4d20b6f1541d34ad67 /theme/templates | |
parent | 6ea5b2b539b107fff094689d0844e661e3260130 (diff) | |
parent | 2dd6192576fe2602d11741c5a9fc17c27ac1ddc3 (diff) | |
download | gitbook-1da341741b4e5f2cee3bb60fbd3b546708e2ef82.zip gitbook-1da341741b4e5f2cee3bb60fbd3b546708e2ef82.tar.gz gitbook-1da341741b4e5f2cee3bb60fbd3b546708e2ef82.tar.bz2 |
Merge pull request #471 from GitbookIO/feature/multipages
Use multiple HTML files for ebook generation
Diffstat (limited to 'theme/templates')
-rw-r--r-- | theme/templates/includes/page/exercise.html | 11 | ||||
-rw-r--r-- | theme/templates/includes/page/quiz.html | 14 | ||||
-rw-r--r-- | theme/templates/page.html | 80 | ||||
-rw-r--r-- | theme/templates/site.html | 3 |
4 files changed, 36 insertions, 72 deletions
diff --git a/theme/templates/includes/page/exercise.html b/theme/templates/includes/page/exercise.html new file mode 100644 index 0000000..96a2c0a --- /dev/null +++ b/theme/templates/includes/page/exercise.html @@ -0,0 +1,11 @@ +<div class="exercise-header">Exercise</div> +<div class="exercise-inner"> + {% autoescape false %}{{ section.content }}{% endautoescape %} +</div> +<div class="exercise-inner"> + <pre><code>{% autoescape false %}{{ section.code.base|code }}{% endautoescape %}</code></pre> +</div> +<hr> +<div class="exercise-inner"> + <pre><code>{% autoescape false %}{{ section.code.solution|code }}{% endautoescape %}</code></pre> +</div> diff --git a/theme/templates/includes/page/quiz.html b/theme/templates/includes/page/quiz.html new file mode 100644 index 0000000..ada363c --- /dev/null +++ b/theme/templates/includes/page/quiz.html @@ -0,0 +1,14 @@ +<div class="exercise-header">Quiz</div> +<div class="exercise-inner">{% autoescape false %}{{ section.content }}{% endautoescape %}</div> +{% for quiz in section.quiz %} +<div class="question exercise-inner"> + <div class="question-header">Question {{ loop.index }} of {{ section.quiz.length }}</div> + + <div class="question-base"> + {% autoescape false %}{{ quiz.base }}{% endautoescape %} + </div> + <div class="question-solution"> + {% autoescape false %}{{ quiz.solution }}{% endautoescape %} + </div> +</div> +{% endfor %} diff --git a/theme/templates/page.html b/theme/templates/page.html index 5966cda..136971a 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,24 @@ {% endfor %} {% endblock %} - -{% macro articleContent(content) %} +{% block content %} +<div class="page"> + <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/page/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/page/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 %} +</div> {% 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 %} |