summaryrefslogtreecommitdiff
path: root/make_site_index.sh
blob: 8a00018ab4abd7fad82fd4c4ba4b1e651306e3c3 (plain)
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
#!/bin/sh

SPECVERSION=$1
SITE=_site
VERSIONS=`cd $SITE; ls -d -1 0.* | sort -r -g`

echo "% CommonMark Spec"
echo ""
date=`grep '<div class="version">' $SITE/$SPECVERSION/index.html | perl  -pe 's/^.*(\d\d\d\d-\d\d-\d\d).*$/\1/'`
echo "[**Latest version ($SPECVERSION)**](/$SPECVERSION/) ($date)"
echo ""
echo "[discussion forum](http://talk.commonmark.org/) | "
echo "[interactive dingus](/dingus.html) | "
echo "[repository](https://github.com/jgm/CommonMark/)"
echo ""
echo "Older versions:"
echo ""
for vers in $VERSIONS
  do
    date=`grep '<div class="version">' $SITE/$vers/index.html | perl  -pe 's/^.*(\d\d\d\d-\d\d-\d\d).*$/\1/'`
    if [ "$vers" != "$SPECVERSION" ]; then
	perl -p -i -e 's/<div id="watermark">.*?<\/div>/<div id="watermark" style="background-color:black">This is an older version of the spec. For the most recent version, see <a href="http:\/\/spec.commonmark.org">http:\/\/spec.commonmark.org<\/a>.<\/div>/' $SITE/$vers/index.html
        echo "- [$vers](/$vers/) ($date)"
    fi
  done