This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
forked from rsdoiel/mkpage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
404 lines (397 loc) · 14.3 KB
/
index.html
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="index.html">README</a>
</li>
<li>
<a href="license.html">LICENSE</a>
</li>
<li>
<a href="install.html">INSTALL</a>
</li>
<li>
<a href="docs/">Documentation</a>
</li>
<li>
<a href="how-to/">HOW TO</a>
</li>
<li>
<a href="RELEASE-NOTES.html">Release Notes</a>
</li>
<li>
<a href="about.html">About</a>
</li>
<li>
<a href="https://github.com/caltechlibrary/mkpage">Github</a>
</li>
</ul>
</nav>
<section>
<p>
<a href="https://www.repostatus.org/#active"><img
src="https://www.repostatus.org/badges/latest/active.svg"
alt="Project Status: Active – The project has reached a stable, usable state and is being actively developed." /></a>
</p>
<h1 id="mkpage-project">
MkPage Project
</h1>
<p>
<strong>MkPage Project</strong> is a collection of tools for rendering
static websites. Featured is the <em>mkpage</em> command, a front end to
<a href="https://pandoc.org">Pandoc</a> (>= v3). Pandoc supports
converting from many <a href="https://pandoc.org/"
title="Pandoc's list of supported formats">lightweight markup
languages</a>. <em>mkpage</em> supports metadata encoded as <a
href="https://www.json.org/json-en.html">JSON</a> front matter<a
href="#fn1" class="footnote-ref" id="fnref1"
role="doc-noteref"><sup>1</sup></a>, as well as additional data sources
expressed on the command line in a simple command language. Content is
rendered using Pandoc’s <a
href="https://pandoc.org/MANUAL.html#templates">template language</a>.
</p>
<p>
<strong>MkPage Project</strong> was inspired by deconstructing more
complex content management systems and distilling the rendering
functions down to a core set of simple command line tools. It is well
suited for building sites hosted on services like GitHub Pages or
Amazon’s S3. It uses the widely adopted <a
href="https://pandoc.org">Pandoc</a> as its markup conversion engine and
<a href="https://pandoc.org/MANUAL.html#templates">template engine</a>.
As such you can create your website using a variety of light weight
markup languages such as <a
href="https://daringfireball.net/projects/markdown/">Markdown</a>, <a
href="http://redcloth.org/textile">Textile</a>, <a
href="https://docutils.sourceforge.io/docs/ref/rst/introduction.html">ReStructureText</a>
and <a
href="https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all">Jira’s</a>
wiki markup.
</p>
<p>
The <strong>MkPage Project</strong>’s tools can run on machines as small
as a Raspberry Pi. Their small foot print and minimal dependencies (only
Pandoc) means installation usually boils down to copying the precompiled
binaries to a bin directory in your path after a installing Pandoc.
Precompiled binaries of <strong>MkPage Project</strong> are available
for Linux, Windows 10 and macOS running on Intel as well as for the ARM7
versions of Raspbian running on Raspberry Pi.
</p>
<p>
<strong>MkPage Project</strong>’s minimalism is an advantage. It plays
nice with the standard suite of text processing tools available with
most Unix/POSIX compatible operating systems<a href="#fn2"
class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a>.
This makes scripting a <strong>MkPage Project</strong> using languages
like Python, Julia, Lua, Make or Bash straight forward. Each
<em>mkpage</em> utility is independent. You can use as few or as many or
as few as you like. You determine the workflow and build process that
best fits your needs.
</p>
<h2 id="a-quick-tour-mkpage-command">
A quick tour <em>mkpage</em> command
</h2>
<p>
The <em>mkpage</em> command accepts key/value pairs as command line
parameters. The pairs can be explicit data types, files on disc or
resources from the web. Additionally <em>mkpage</em> will merge in any
front matter found in your light weight markup such as Markdown
documents. <em>mkpage</em> assembles the all metadata into a JSON
structure which will be processed by Pandoc when rendering a Pandoc
template. Additionally <em>mkpage</em> understands the <a
href="https://fountain.io">Fountain</a> markup language will will handle
conversion before passing to onto Pandoc.
</p>
<h2 id="mkpages-command-language">
<em>mkpage</em>’s command language
</h2>
<p>
The “key” in our key/value pairs is used to map into the <a
href="https://pandoc.org/MANUAL.html">Pandoc</a> templates you want
rendered. If a key was called “content” the template element would be
like <code><span
class="math inline"><em>c</em><em>o</em><em>n</em><em>t</em><em>e</em><em>n</em><em>t</em> < /<em>c</em><em>o</em><em>d</em><em>e</em> > .<em>T</em><em>h</em><em>e</em><em>v</em><em>a</em><em>l</em><em>u</em><em>e</em><em>o</em><em>f</em>“ <em>c</em><em>o</em><em>n</em><em>t</em><em>e</em><em>n</em><em>t</em>” <em>w</em><em>o</em><em>u</em><em>l</em><em>d</em><em>r</em><em>e</em><em>p</em><em>l</em><em>a</em><em>c</em><em>e</em> < <em>c</em><em>o</em><em>d</em><em>e</em>></span>{content}</code>
in the Pandoc template. Pandoc templates can combine logic and iteration
to make more complex pages. See the Pandoc
<a href="https://pandoc.org/MANUAL.html#templates">User Guide</a> for
more details.
</p>
<p>
On the “value” side of the key/value pair you have strings of one of
several formats - plain text, markdown, <a
href="https://fountain.io">fountain</a>, ReStructureText, Jira text and
JSON. The values can be from explicit strings associated with a data
type, data from a file where the file extension identifies the content
type, or content retrieved via a URL based on the mime-type sent from
the web service. Here’s a basic demonstration of sampling of
capabilities and integrating data from the <a
href="http://weather.gov">NOAA weather website</a>.
</p>
<p>
Next is an example of a basic Pandoc template followed by an example
command line for invoking <em>mkpage</em>.
</p>
<h4 id="a-basic-template">
A basic template
</h4>
<pre class="template"><code>
Date: ${now}
Hello ${name},
The weather forecast is
${if(weather.data.weather)}
${weather.data.weather[; ]}
${endif}
Thank you
${signature}
</code></pre>
<p>
To render the template above (i.e. <a
href="examples/weather.tmpl">weather.tmpl</a>) is expecting values from
various data sources broken down as follows.
</p>
<ul>
<li>
“now” and “name” will be explicit strings
<ul>
<li>
“now” integrates getting data from the Unix <em>date</em> command
</li>
</ul>
</li>
<li>
“weather” will come from a URL which returns a JSON document
<ul>
<li>
“.data.weather” is the path into the JSON document
</li>
</ul>
</li>
<li>
“signature” will come from a plain text file in your local disc
</li>
</ul>
<h4 id="typing-the-mkpage-command">
typing the <em>mkpage</em> command
</h4>
<p>
Here is how we would express the key/value pairs on the command line.
</p>
<pre class="shell"><code> mkpage "now=text:$(date)" \
'name=text:Little Frieda' \
'weather=http://forecast.weather.gov/MapClick.php?lat=13.47190933300044&lon=144.74977715100056&FcstType=json' \
'signature=examples/signature.txt' \
'examples/weather.tmpl'</code></pre>
<p>
Notice the two explicit strings are prefixed with “text:” (other formats
include “markdown:” and “json:”). Values without a prefix are assumed to
be local file paths. We see that in testdata/signature.txt is one.
Likewise the weather data is coming from a URL identified by the “http:”
protocol reference . <em>mkpage</em> uses the “protocol” prefix to
distinguish between literals, file paths and URL based based content.
“http:” and “https:” returns an HTTP header the header is used to
identify the content type for processing by <em>mkpage</em> before
handing off to Pandoc. E.g. “Content-Type: text/markdown” tells us to
use Pandoc to translate from Markdown to HTML. For data contained in
files we rely on the file extension to identify content type, e.g. “.md”
is markdown, “.rst” is ReStructureText, “.json” is a JSON document. If
no content type is discernible then we assume the content is plain text.
</p>
<h3 id="mkpage-project-tools">
MkPage Project Tools
</h3>
<h4 id="mkpage">
mkpage
</h4>
<p>
<a href="docs/mkpage/">mkpage</a> is a page renderer and front end to
Pandoc. It is used to aggregate metadata and templates into a complete
website page. It serves as a pre-processor for Markdown, <a
href="https://fountain.io">Fountain</a>, ReStructureText, Textile, Jira
markup, JSON using <a href="https://pandoc.org">Pandoc</a> as conversion
and template engine.
</p>
<h4 id="blogit">
blogit
</h4>
<p>
<a href="docs/blogit/">blogit</a> performs two tasks, first if given a
filename and date (in YYYY-MM-DD format) blogit will copy the file into
an appropriate blog path based on the date provided. The second task it
performs is to maintain a <code>blog.json</code> file describing the
content of the blog. This is placed in the same folder as the where the
year folders for the blog are create.
</p>
<h4 id="mkrss">
mkrss
</h4>
<p>
<a href="docs/mkrss/">mkrss</a> is an RSS feed generator for content
authored in Markdown. It can read a <code>blog.json</code> file created
with the <em>blogit</em> and produce an RSS feed from it or scan the
directory tree for Markdown files with corresponding HTML files and
generate an RSS feed.
</p>
<h4 id="frontmatter">
frontmatter
</h4>
<p>
<a href="docs/frontmatter/">frontmatter</a> will extract JSON front
matter from a plain text file (e.g. a Markdown document).
</p>
<h4 id="byline">
byline
</h4>
<p>
<a href="docs/byline/">byline</a> inside a Markdown file’s front matter
for a “byline” field and return it before scanning the file using a
regular expression for the byline. If nothing is found in either the
front matter or the regular expression then it’ll return an empty
string.
</p>
<h4 id="titleline">
titleline
</h4>
<p>
<a href="docs/titleline/">titleline</a> will look inside a markdown
file’s front matter for a “title” field it if not present in the front
matter it’ll look for the h1 demlimiter (Markdown ‘#’) and return it’s
content. It will return an empty string if it finds none.
</p>
<h4 id="reldocpath">
reldocpath
</h4>
<p>
<a href="docs/reldocpath/">reldocpath</a> is intended to simplify the
calculation of relative asset paths (e.g. common CSS files, images, RSS
files) when working from a common project directory.
</p>
<h5 id="example-reldocpath">
Example reldocpath
</h5>
<p>
You know the path from the source document to target document from the
project root folder.
</p>
<ul>
<li>
Source is <em>course/week/01/readings.html</em>
</li>
<li>
Target is <em>css/site.css</em>.
</li>
</ul>
<p>
In Bash this would look like–
</p>
<pre class="shell"><code> # We know the paths relative to the project directory
DOC_PATH="course/week/01/readings.html"
CSS_PATH="css/site.css"
echo $(reldocpath $DOC_PATH $CSS_PATH)</code></pre>
<p>
the output would look like
</p>
<pre class="shell"><code> ../../../css/site.css</code></pre>
<h4 id="sitemapper">
sitemapper
</h4>
<p>
<a href="docs/sitemapper/">sitemapper</a> a simplistic XML Sitemap
generator. Sitemaps are used by web crawls to find content in your
website and can help your website be more search-able by modern full
text search engines.
</p>
<h4 id="ws">
ws
</h4>
<p>
<a href="docs/ws/">ws</a> is a simple static file web server. It is
suitable for viewing your local copy of your static website on your
machine. It runs with minimal resources and by default will serve
content out to the URL http://localhost:8000. It is a fast, small, web
server for site development and copyedit work.
</p>
<h5 id="example">
Example
</h5>
<pre class="shell"><code> ws Sites/mysite.example.org</code></pre>
<p>
This would start the web server up listen for browser requests on
<em>http://localhost:8000</em>. The content viewable by your web browser
would be the files inside the <em>Sites/mysite.example.org</em>
directory.
</p>
<pre class="shell"><code> ws -url http://mysite.example.org:80 Sites/mysite.example.org</code></pre>
<p>
Assume the machine where you are running <em>ws</em> has the name
mysite.example.org then your could point your web browser at
<em>http://mysite.example.org</em> and see the web content you have in
<em>Site/mysite.example.org</em> directory.
</p>
<h2 id="problem-reporting-and-lending-a-hand">
Problem Reporting and lending a hand
</h2>
<p>
<strong>MkPage</strong> project is hosted at <a
href="https://github.com/caltechlibrary/mkpage">GitHub</a> and bugs can
be reported via the <a
href="https://github.com/caltechlibrary/mkpage/issues">Issue
Tracker</a>. As an open source project pull requests as well as bug
reports are appreciated.
</p>
<h2 id="getting-your-copy-of-mkpage-project">
Getting your copy of <strong>MkPage Project</strong>
</h2>
<p>
You can find releases of <strong>MkPage Project</strong> at <a
href="https://github.com/caltechlibrary/mkpage/releases">github.com/caltechlibrary/mkpage</a>
</p>
<h2 id="license">
License
</h2>
<p>
<strong>MkPage Project</strong> is released under an open source <a
href="license.html">license</a>.
</p>
<section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
<hr />
<ol>
<li id="fn1">
<p>
Front matter in light weight markup languages like Markdown start at the
top of the file and begin and end with a simple set of delimiters. JSON
front matter uses open and close curly braces are used by
JSON.<a href="#fnref1" class="footnote-back"
role="doc-backlink">↩︎</a>
</p>
</li>
<li id="fn2">
<p>
Common POSIX compatible systems include macOS, Linux, and recent
versions of Windows 10<a href="#fnref2" class="footnote-back"
role="doc-backlink">↩︎</a>
</p>
</li>
</ol>
</section>
</section>
<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>© 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:library@caltech.edu">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>