diff options
author | Shaform <shaform@gmail.com> | 2014-06-17 22:08:46 +0800 |
---|---|---|
committer | Shaform <shaform@gmail.com> | 2014-06-17 22:08:46 +0800 |
commit | 6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41 (patch) | |
tree | d2efbbb62f9746b19b683c11a302c9afe385a2be /theme/templates | |
parent | 1f4cf33dd08b439cadb5c649654ecd6d3f4b399d (diff) | |
parent | d6eb8e4c6042262408c3c0b8d67bccecfa4bf882 (diff) | |
download | gitbook-6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41.zip gitbook-6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41.tar.gz gitbook-6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41.tar.bz2 |
Merge remote-tracking branch 'upstream/master' into ref_links
Diffstat (limited to 'theme/templates')
-rw-r--r-- | theme/templates/includes/book/summary.html | 26 | ||||
-rwxr-xr-x | theme/templates/langs.html | 6 | ||||
-rwxr-xr-x | theme/templates/layout.html | 44 | ||||
-rw-r--r-- | theme/templates/page.html | 140 | ||||
-rw-r--r-- | theme/templates/site.html | 23 |
5 files changed, 98 insertions, 141 deletions
diff --git a/theme/templates/includes/book/summary.html b/theme/templates/includes/book/summary.html index 697cce8..2f9dc3f 100644 --- a/theme/templates/includes/book/summary.html +++ b/theme/templates/includes/book/summary.html @@ -1,10 +1,25 @@ {% macro articles(_articles) %} {% for item in _articles %} - <li class="chapter {% if item._path == _input %}active{% endif %}" data-level="{{ item.level }}" {% if item.path %}data-path="{{ item.path|mdLink }}"{% endif %}> + {% set externalLink = item.path|isExternalLink %} + <li class="chapter {% if item._path == _input %}active{% endif %}" data-level="{{ item.level }}" {% if item.path && !externalLink %}data-path="{{ item.path|mdLink }}"{% endif %}> {% if item.path %} - <a href="{{ basePath }}/{{ item.path|mdLink }}"> - <i class="fa fa-check"></i> <b>{{ item.level }}.</b> {{ item.title }} - </a> + {% if !externalLink %} + <a href="{{ basePath }}/{{ item.path|mdLink }}"> + <i class="fa fa-check"></i> + {% if item.level !== "0" %} + <b>{{ item.level }}.</b> + {% endif %} + {{ item.title }} + </a> + {% else %} + <a target="_blank" href="{{ item.path }}"> + <i class="fa fa-check"></i> + {% if item.level !== "0" %} + <b>{{ item.level }}.</b> + {% endif %} + {{ item.title }} + </a> + {% endif %} {% else %} <span><b>{{ item.level }}.</b> {{ item.title }}</span> {% endif %} @@ -48,9 +63,6 @@ <li class="divider"></li> {% endif %} - <li data-level="0" data-path="index.html"> - <a href="{{ basePath }}/"><i class="fa fa-check"></i> Introduction</a> - </li> {{ articles(summary.chapters) }} {% if options.links.gitbook !== false %} diff --git a/theme/templates/langs.html b/theme/templates/langs.html index 21bf64f..dd8c96b 100755 --- a/theme/templates/langs.html +++ b/theme/templates/langs.html @@ -2,6 +2,10 @@ {% block title %}{{ title }}{% endblock %} +{% block style %} +<link rel="stylesheet" href="{{ staticBase }}/style.css"> +{% endblock %} + {% block content %} <div class="book-langs-index"> <div class="inner"> @@ -10,7 +14,7 @@ <ul class="languages"> {% for lang in langs %} <li> - <a href="{{ basePath}}/{{ lang.path }}">{{ lang.title }}</a> + <a href="{{ basePath}}/{{ lang.path|pathJoin("/index.html") }}">{{ lang.title }}</a> </li> {% endfor %} </ul> diff --git a/theme/templates/layout.html b/theme/templates/layout.html index 5f76e5e..7f0a83f 100755 --- a/theme/templates/layout.html +++ b/theme/templates/layout.html @@ -1,54 +1,26 @@ <!DOCTYPE HTML> <html lang="en-US" {% block htmlTag %}{% endblock %}> {{ htmlSnippet("html:start")|default("") }} - <head prefix="og: http://ogp.me/ns# book: http://ogp.me/ns/book#"> + <head> {{ htmlSnippet("head:start")|default("") }} - {% block head %} <meta charset="UTF-8"> - <title>{% block title %} | {{ title }}{% endblock %}</title> - + <title>{% block title %}{% endblock %}</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> - <meta name="robots" content="index, follow"> - <meta name="author" content="{{ githubAuthor }}"> - <meta name="description" content="{{ description }}"> - <meta name="keywords" content="gitbook,github" > - <meta name="generator" content="www.gitbook.io"> - - {% if progress.current.next and progress.current.next.path %} - <link rel="next" href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" /> - {% endif %} - {% if progress.current.prev and progress.current.prev.path %} - <link rel="prev" href="{{ basePath }}/{{ progress.current.prev.path|mdLink }}" /> - {% endif %} - - <meta property="og:title" content="{% block title %} | {{ title }}{% endblock %}"> - <meta property="og:site_name" content="{{ title }}"> - <meta property="og:type" content="book"> - <meta property="og:locale" content="en_US"> - - <meta property="book:author" content="{{ githubHost }}{{ githubAuthor }}"> - <meta property="book:tag" content="GitBook"> - + <meta name="description" content="{% block description %}{% endblock %}"> + <meta name="generator" content="GitBook {{ gitbook.version }}"> + <meta name="HandheldFriendly" content="true"/> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> - <link rel="shortcut icon" href="{{ staticBase }}/images/favicon.ico" type="image/x-icon"> - {% endblock %} + {% block head %}{% endblock %} {{ htmlSnippet("head:end")|default("") }} </head> <body> {{ htmlSnippet("body:start")|default("") }} - {% block style %} - <link rel="stylesheet" href="{{ staticBase }}/style.css"> - {% endblock %} + {% block style %}{% endblock %} {% block content %}{% endblock %} - {% block javascript %} - <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/mode-javascript.js"></script> - <script src="{{ staticBase }}/jsrepl/jsrepl.js" id="jsrepl-script"></script> - <script src="{{ staticBase }}/app.js"></script> - {% endblock %} + {% block javascript %}{% endblock %} {{ htmlSnippet("body:end")|default("") }} </body> {{ htmlSnippet("html:end")|default("") }} diff --git a/theme/templates/page.html b/theme/templates/page.html index 061df6d..9c58ab1 100644 --- a/theme/templates/page.html +++ b/theme/templates/page.html @@ -20,10 +20,15 @@ </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 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> {% endif %} {% endfor %} @@ -31,104 +36,51 @@ {% set exercise = 1 %} {% block content %} - {# Cover #} - <section id="cover"> - <h1>{{ title }}</h1> - {% if githubId %} - <h2>By <a href="{{ githubHost }}{{ githubAuthor }}">@{{ githubAuthor }}</a></h2> - {% endif %} - </section> - - {# Summary #} - <section id="summary"> - <h1>Table of Contents</h1> - <ol> - <li> - <a href="#README.md"> - <h2>Introduction</h2> - </a> - </li> - {% for item in summary.chapters %} - <li> - <h2><span>{{ item.level }}.</span> <a href="#{{ item.path }}">{{ item.title }}</a></h2> - {% if item.articles.length > 0 %} - <ol> - {% for article in item.articles %} - <li> - <span>{{ article.level }}</span> <a href="#{{ article.path }}">{{ article.title }}</a> - </li> - {% endfor %} - </ol> - {% endif %} - </li> - {% endfor %} - </ol> - </section> - {# Pages content #} - <section> - <article id="README.md"> - {{ articleContent(pages["README.md"].content) }} - </article> - </section> - {% for item in summary.chapters %} - <section> - <article id="{{ item.path }}" class="new-chapter"> - <h1>{{ item.title }}</h1> - </article> - - {% if pages[item.path] %} - <article> - {{ articleContent(pages[item.path].content) }} - </article> - {% endif %} - - {% 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> + {% 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].content) }} + {% endif %} + </article> {% endfor %} {# Exercise solutions #} {% if exercise > 1 %} {% set exercise = 1 %} - <section> - <article class="new-chapter"> - <h1>Exercise Solutions</h1> - </article> - <article> - {% for item in summary.chapters %} - {% for article in item.articles %} - {% if pages[article.path] %} - {% for section in pages[article.path].content %} - {% 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">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% autoescape false %}{{ section.quiz.solution }}{% endautoescape %} - {% set exercise = exercise + 1 %} - </div> - {% endif %} - {% endfor %} - {% endif %} - {% endfor %} + <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].content %} + {% 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> - </section> + </article> {% endif %} {% endblock %} diff --git a/theme/templates/site.html b/theme/templates/site.html index b0a2ba4..6fcbebd 100644 --- a/theme/templates/site.html +++ b/theme/templates/site.html @@ -1,7 +1,23 @@ {% extends "layout.html" %} {% block htmlTag %}{% if options.cache !== false %}manifest="{{ basePath }}/manifest.appcache"{% endif %}{% endblock %} -{% block title %}{{ progress.current.title }}{% parent %}{% endblock %} + +{% 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 %} + {% if progress.current.prev and progress.current.prev.path %} + <link rel="prev" href="{{ basePath }}/{{ progress.current.prev.path|mdLink }}" /> + {% endif %} +{% endblock %} + +{% block title %}{{ progress.current.title }} | {{ title }}{% endblock %} +{% block description %}{% if progress.current.level == "0" %}{{ description }}{% endif %}{% endblock %} + {% block content %} <div class="book" {% if githubId %}data-github="{{ githubId }}"{% endif %} data-level="{{ progress.current.level }}" data-basepath="{{ basePath }}" data-revision="{{ revision }}"> {% include "includes/book/header.html" %} @@ -38,7 +54,8 @@ {% endblock %} {% block javascript %} -{% parent %} +<script src="{{ staticBase }}/jsrepl/jsrepl.js" id="jsrepl-script"></script> +<script src="{{ staticBase }}/app.js"></script> {% for resource in plugins.resources.js %} {% if resource.url %} <script src="{{ resource.url }}"></script> @@ -55,7 +72,7 @@ require(["gitbook"], function(gitbook) { {% endblock %} {% block style %} -{% parent %} +<link rel="stylesheet" href="{{ staticBase }}/style.css"> {% for resource in plugins.resources.css %} {% if resource.url %} <link rel="stylesheet" href="{{ resource.url }}"> |