summaryrefslogtreecommitdiffstats
path: root/theme
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-17 11:16:18 +0200
committerSamy Pessé <samypesse@gmail.com>2014-04-17 11:16:18 +0200
commit6e613e9f7138dcf881ad37a6e50b43d5f833aee3 (patch)
treef9279775bac0f93d88011da31cf641c6ff77c055 /theme
parentb698d43d7d0334bdbe3f83ecc4659599ac85c47f (diff)
downloadgitbook-6e613e9f7138dcf881ad37a6e50b43d5f833aee3.zip
gitbook-6e613e9f7138dcf881ad37a6e50b43d5f833aee3.tar.gz
gitbook-6e613e9f7138dcf881ad37a6e50b43d5f833aee3.tar.bz2
Fix #107: Render all the page in single page format
Diffstat (limited to 'theme')
-rw-r--r--theme/templates/page.html84
1 files changed, 38 insertions, 46 deletions
diff --git a/theme/templates/page.html b/theme/templates/page.html
index 1467e68..51c5ea1 100644
--- a/theme/templates/page.html
+++ b/theme/templates/page.html
@@ -7,6 +7,29 @@
<link rel="stylesheet" href="{{ staticBase }}/print.css">
{% endblock %}
+
+{% macro articleContent(content) %}
+ {% for section in content %}
+ {% 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>
+ {% elif section.type == "quiz" %}
+ <div class="quiz">
+ <div class="exercise-header">Exercise #{{ exercise }}</div>
+ {% autoescape false %}{{ section.content }}{% endautoescape %}
+ {% autoescape false %}{{ section.quiz.base }}{% endautoescape %}
+ {% set exercise = exercise + 1 %}
+ </div>
+ {% endif %}
+ {% endfor %}
+{% endmacro %}
+
{% set exercise = 1 %}
{% block content %}
{# Cover #}
@@ -45,61 +68,30 @@
{# Pages content #}
<section>
<article id="README.md">
- {% for section in pages["README.md"].content %}
- {% 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>
- {% elif section.type == "quiz" %}
- <div class="quiz">
- <div class="exercise-header">Exercise #{{ exercise }}</div>
- {% autoescape false %}{{ section.content }}{% endautoescape %}
- {% autoescape false %}{{ section.quiz.base }}{% endautoescape %}
- {% set exercise = exercise + 1 %}
- </div>
- {% endif %}
- {% endfor %}
+ {{ articleContent(pages["README.md"].content) }}
</article>
</section>
{% for item in summary.chapters %}
- {% if item.articles.length > 0 %}
<section>
<article id="{{ item.path }}" class="new-chapter">
<h1>{{ item.title }}</h1>
</article>
- {% for article in item.articles %}
- {% if pages[article.path] %}
- <article id="{{ article.path }}">
- {% for section in pages[article.path].content %}
- {% 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>
- {% elif section.type == "quiz" %}
- <div class="quiz">
- <div class="exercise-header">Exercise #{{ exercise }}</div>
- {% autoescape false %}{{ section.content }}{% endautoescape %}
- {% autoescape false %}{{ section.quiz.base }}{% endautoescape %}
- {% set exercise = exercise + 1 %}
- </div>
- {% endif %}
- {% endfor %}
- </article>
- {% endif %}
- {% endfor %}
+ <article>
+ {{ articleContent(pages[item.path].content) }}
+ </article>
+
+ {% if item.articles.length > 0 %}
+ {% for article in item.articles %}
+ {% if pages[article.path] %}
+ <article id="{{ article.path }}">
+ {{ articleContent(pages[article.path].content) }}
+ </article>
+ {% endif %}
+ {% endfor %}
+ {% endif %}
</section>
- {% endif %}
+ {
{% endfor %}