summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-04 16:40:21 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-04 16:40:21 -0700
commit9fbe2408432bfeed1db330bc69372a43f0bb0506 (patch)
treeabd6902eb4b6a8bcc8c4a90e332330ace97c1c19
parent0c7e2b3557526bf74842096f5af0bba911380662 (diff)
downloadgitbook-9fbe2408432bfeed1db330bc69372a43f0bb0506.zip
gitbook-9fbe2408432bfeed1db330bc69372a43f0bb0506.tar.gz
gitbook-9fbe2408432bfeed1db330bc69372a43f0bb0506.tar.bz2
Add summary to page generator
-rw-r--r--lib/generate/page/index.js2
-rw-r--r--theme/assets/print.css2
-rw-r--r--theme/stylesheets/print.less10
-rw-r--r--theme/templates/page.html28
4 files changed, 38 insertions, 4 deletions
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index 111bb1e..a8fc866 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -94,7 +94,7 @@ Generator.prototype.finish = function() {
);
})
- //
+ // Copy assets
.then(function() {
return fs.copy(
path.join(that.options.theme, "assets"),
diff --git a/theme/assets/print.css b/theme/assets/print.css
index 98d113c..69aaa8b 100644
--- a/theme/assets/print.css
+++ b/theme/assets/print.css
@@ -1 +1 @@
-.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}body{font:12pt Georgia,"Times New Roman",Times,serif;line-height:1.3}@page{margin:1.5cm} \ No newline at end of file
+.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}body{font:12pt Georgia,"Times New Roman",Times,serif;line-height:1.3}@page{margin:1.5cm}section{page-break-after:always}section article:after{border-bottom:1px solid #ccc} \ No newline at end of file
diff --git a/theme/stylesheets/print.less b/theme/stylesheets/print.less
index 5a4d06f..ca2dc3f 100644
--- a/theme/stylesheets/print.less
+++ b/theme/stylesheets/print.less
@@ -7,4 +7,14 @@ body {
@page {
margin: 1.5cm;
+}
+
+section {
+ page-break-after: always;
+
+ article {
+ &:after {
+ border-bottom: 1px solid #ccc;
+ }
+ }
} \ No newline at end of file
diff --git a/theme/templates/page.html b/theme/templates/page.html
index 7af99fb..13e8f51 100644
--- a/theme/templates/page.html
+++ b/theme/templates/page.html
@@ -9,13 +9,37 @@
{% block content %}
{# Cover #}
+ <section id="cover">
+ <h1>{{ title }}</h1>
+ <h2>By @{{ githubAuthor }}</h2>
+ </section>
{# Summary #}
-
+ <section id="summary">
+ <ul class="summary">
+ <li>
+ <a href="#README.md">Introduction</a>
+ </li>
+ {% for item in summary.chapters %}
+ <li>
+ <a href="#{{ item.path }}"><b>{{ item.level }})</b> {{ item.title }}</a>
+ {% if item.articles.length > 0 %}
+ <ul>
+ {% for article in item.articles %}
+ <li>
+ <a href="#{{ article.path }}"><b>{{ article.level }})</b> {{ article.title }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+ </section>
{# Pages content #}
{% for page in pages %}
- <article id="{{ page.path }}" style="page-break-after: always;">
+ <article id="{{ page.path }}">
{% for section in page.content %}
{% if section.type == "normal" %}
{% autoescape false %}{{ section.content }}{% endautoescape %}