Skip to content

Commit b53e8a3

Browse files
Automate page generation process. Refs #54.
This commit automates the page generation process by: - Introducing a script that will generate the html pages under _site/ from the markdown files. - Adjusting the Makefile to make use of such script. - Moving all static files into _site/ - Adjusting the templates to be plain files, as opposed to scripts. - Adjusting the permissions of the templates to disable the executable bit.
1 parent 36bd6e0 commit b53e8a3

File tree

9 files changed

+48
-32
lines changed

9 files changed

+48
-32
lines changed

Makefile

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
MAP=map
2-
OUT=html
3-
TEMPLATE=tpl/default
1+
.PHONY: all
42

5-
include Makefile.base
3+
all: _site/about.html \
4+
_site/contact.html \
5+
_site/documentation.html \
6+
_site/download.html \
7+
_site/home.html \
8+
_site/index.html
69

7-
publish: all
8-
git add .
9-
git stash
10-
git checkout master
11-
git checkout --theirs stash -- .
12-
git stash drop
13-
git reset .
14-
git clean -df
15-
git clean -df
10+
_site/about.html: about.md
11+
./compile.sh About $< default
1612

17-
home.html: home.nav home.content tpl/home
18-
web-render tpl/home home home.nav home.content > $@
13+
_site/contact.html: contact.md
14+
./compile.sh Contact $< default
1915

20-
index.html: home.html
21-
ln -s $< $@
16+
_site/documentation.html: documentation.md
17+
./compile.sh Documentation $< default
18+
19+
_site/download.html: download.md
20+
./compile.sh Download $< default
21+
22+
_site/home.html: home.md
23+
./compile.sh Home $< home
24+
25+
_site/index.html: _site/home.html
26+
cp $< $@
File renamed without changes.
File renamed without changes.
File renamed without changes.

compile.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
TITLE="$1"
4+
NAV="$(cat nav)"
5+
CONTENT="$(pandoc $2 -t html)"
6+
TARGET="_site/$(basename $2 .md).html"
7+
TEMPLATE="$3"
8+
mkdir -p _site/
9+
env TITLE="$TITLE" NAV="$NAV" CONTENT="$CONTENT" envsubst '${TITLE}':'${NAV}':'${CONTENT}' < tpl/$TEMPLATE > $TARGET

nav

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<p>
2+
<a href="home.html">Home</a>
3+
<a href="about.html">About</a>
4+
<a href="download.html">Download</a>
5+
<a href="documentation.html">Documentation</a>
6+
<a href="contact.html">Contact</a>
7+
<a href="https://github.com/copilot-language/copilot">Source Code</a>
8+
</p>

tpl/default

100755100644
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/bin/sh
2-
3-
cat <<!
41
<!DOCTYPE html>
52
<html>
63
<head>
@@ -21,4 +18,3 @@ cat <<!
2118
</div>
2219
</body>
2320
</html>
24-
!

tpl/home

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/bin/sh
2-
3-
cat <<!
41
<!DOCTYPE html>
52
<html>
63
<head>
@@ -15,7 +12,9 @@ cat <<!
1512
<a href="index.html">Copilot</a>
1613
<span>Realtime Programming Language and Runtime Verification Framework</span>
1714
</div>
18-
<div id="menu">$NAV</div>
15+
<div id="menu">
16+
$NAV
17+
</div>
1918
<div id="panel">
2019
<div class="left">
2120
<p>
@@ -46,12 +45,11 @@ ctemp = (unsafeCast temp) * (<mark class="literal">150.0</mark> / <mark class="l
4645
spec = do
4746
trigger <mark class="string">"heaton"</mark> (ctemp < <mark class="literal">18.0</mark>) [arg ctemp]
4847
trigger <mark class="string">"heatoff"</mark> (ctemp > <mark class="literal">21.0</mark>) [arg ctemp]</code></pre>
49-
</div>
50-
</div>
51-
<div id="content">
52-
$CONTENT
53-
</div>
5448
</div>
55-
</body>
49+
</div>
50+
<div id="content">
51+
$CONTENT
52+
</div>
53+
</div>
54+
</body>
5655
</html>
57-
!

0 commit comments

Comments
 (0)