-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathput-together.html
More file actions
120 lines (120 loc) · 7.6 KB
/
put-together.html
File metadata and controls
120 lines (120 loc) · 7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style type="text/css">
/*<![CDATA[*/
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
code.sourceCode span.kw { color: #007020; font-weight: bold; }
code.sourceCode span.dt { color: #902000; }
code.sourceCode span.dv { color: #40a070; }
code.sourceCode span.bn { color: #40a070; }
code.sourceCode span.fl { color: #40a070; }
code.sourceCode span.ch { color: #4070a0; }
code.sourceCode span.st { color: #4070a0; }
code.sourceCode span.co { color: #60a0b0; font-style: italic; }
code.sourceCode span.ot { color: #007020; }
code.sourceCode span.al { color: red; font-weight: bold; }
code.sourceCode span.fu { color: #06287e; }
code.sourceCode span.re { }
code.sourceCode span.er { color: red; font-weight: bold; }
/*]]>*/
</style>
<link rel="stylesheet" href="../styles/tutorial.css">
<title>From here to Cloudfour.com: Let's put stuff together</title>
</head>
<body>
<nav id="TOC" class="toc">
<header>
<h1>On This Page</h1>
</header>
<ul>
<li><a href="#puttin-it-together">Puttin' it together</a><ul>
<li><a href="#pandoc-and-css-sittin-in-a-tree">Pandoc and CSS, sittin' in a tree</a></li>
<li><a href="#sometimes-you-want-to-use-things-more-than-once">Sometimes you want to use things more than once</a><ul>
<li><a href="#reusable-elements-how-about-some-footer-links">Reusable elements: how about some footer links?</a><ul>
<li><a href="#create-the-links">Create the links</a></li>
<li><a href="#create-the-template">Create the template</a></li>
<li><a href="#update-our-main-page-template">Update our main page template</a></li>
<li><a href="#update-our-pandoc-command-and-go">Update our pandoc command and GO!</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</nav>
<h1 id="puttin-it-together"><a href="#TOC">Puttin' it together</a></h1>
<h2 id="pandoc-and-css-sittin-in-a-tree"><a href="#TOC">Pandoc and CSS, sittin' in a tree</a></h2>
<ol type="1">
<li><code>cd</code> to the <code>content</code> directory.</li>
<li><p>Run this honker:</p>
<p><code>pandoc --from markdown --to html --standalone --html5 --section-divs --template=../templates/page.html --css=styles/styles.css index.mdown > ../index.html</code></p></li>
</ol>
<p>(The only thing different here from our last pandoc command is the <code>--css</code> flag).</p>
<p>How do you like them apples (that is, the apples should be viewed in a web browser)?</p>
<p>Resize your window down to smallish to see the poo.</p>
<h2 id="sometimes-you-want-to-use-things-more-than-once"><a href="#TOC">Sometimes you want to use things more than once</a></h2>
<p>What about things like:</p>
<ul>
<li>Footer links?</li>
<li>Nav?</li>
</ul>
<p><em>This all seems a bit simplistic, doesn't it?</em></p>
<p>This is when we start piling on the layers, either in pandoc (that kind I'll show you) or using our general scripting smarts.</p>
<h3 id="reusable-elements-how-about-some-footer-links"><a href="#TOC">Reusable elements: how about some footer links?</a></h3>
<p>We're going to create a reusable chunk. These are the steps we'll follow:</p>
<ol type="1">
<li>Create the content of the links. As always, content first!</li>
<li>Create a template HTML file in which we want to render those links.</li>
<li>Update our <code>page.html</code> template to display the chunk.</li>
<li>Run a slightly different pandoc command to get the footer chunk in our <code>index.html</code> document.</li>
</ol>
<h4 id="create-the-links"><a href="#TOC">Create the links</a></h4>
<ol type="1">
<li><code>cd</code> to the <code>content</code> directory.</li>
<li>In the interest of purity, <code>mkdir common</code>. That is, create a subdirectory called <code>common</code>.</li>
<li>In the <code>common</code> directory, create a file called <code>footer.mdown</code>.</li>
<li>This is what should go in the file:</li>
</ol>
<pre><code><br /> * [Our Projects](http://www.cloudfour.com/projects "Our Projects")
* [Our Team](http://www.cloudfour.com/about "About us and our team")
* [Mobile Portland](http://www.mobileportland.com "Mobile Portland")
* [Future Friendly](http://futurefriend.ly "Future Friendly")
</code></pre>
<h4 id="create-the-template"><a href="#TOC">Create the template</a></h4>
<p>Let's be all hip and use HTML5.</p>
<ol type="1">
<li><code>cd</code> to the <code>templates</code> directory now.</li>
<li>Create a new file called <code>footer.html</code>.</li>
<li>Put this in the file:</li>
</ol>
<pre class="sourceCode"><code class="sourceCode html"><br /> <span class="kw"><footer></span><br /> <span class="kw"><nav></span><br /> $body$<br /> <span class="kw"></nav></span><br /> <span class="kw"></footer></span></code></pre>
<p>Spend a moment ruminating about what you think it might do.</p>
<h4 id="update-our-main-page-template"><a href="#TOC">Update our main page template</a></h4>
<p>OK, a confession. We made our <code>page.html</code> file a bit simpler than it really needs to be. We didn't include all of pandoc's default variables. Let's update it. Add this section to the area indicated (right after the <code>$body</code> variable):</p>
<pre class="sourceCode"><code class="sourceCode html"><br /> <span class="kw"></head></span><br /> <span class="kw"><body></span><br /> $body$<br /> $for(include-after)$<br /> $include-after$<br /> $endfor$<br /> <span class="kw"></body></span><br /> <span class="kw"></html></span></code></pre>
<h4 id="update-our-pandoc-command-and-go"><a href="#TOC">Update our pandoc command and GO!</a></h4>
<p>That sort of inscrutable bit of pandoc loop means "for each defined section that is declared to be something that should show up <em>after</em> the main body content...well, print that out now, ok?"</p>
<p>So, what we need to do to sew this up is:</p>
<ol type="1">
<li>Convert the <code>footer.mdown</code> file to HTML using our <code>footer.html</code> template.</li>
<li>Update our main whopper of a pandoc command to output our <code>index.html</code> file with the new, reusable footer.</li>
</ol>
<p>Ready?</p>
<p><code>cd</code> to the <code>content</code> directory, where your <code>index.html</code> file and <code>common</code> directory should be.</p>
<p>Now, run this command:</p>
<pre><code>pandoc --from markdown --to html --html5 --template=../templates/footer.html common/footer.mdown > common/footer.html
</code></pre>
<p>That takes our <code>footer.mdown</code> content, uses <code>../templates/footer.html</code> as a template, and outputs HTML into <code>common/footer.html</code>. Now we have a footer we can stick into content!</p>
<p>And then run this:</p>
<pre><code>pandoc --from markdown --to html --standalone --html5 --section-divs --template=../templates/page.html --css=styles/styles.css --include-after-body=common/footer.html index.mdown > ../index.html
</code></pre>
<p>We're using <code>--include-after-body</code> to stick <code>common/footer.html</code> into the resulting HTML file <em>after</em> the main body content.</p>
<p>View the result in a web browser! DO IT!!!!!</p>
<p><a href="now-what.html">And now we talk about the big picture</a></p>
</nav>
</body>
</html>