diff options
Diffstat (limited to 'build.sh')
| -rwxr-xr-x | build.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..1308a99 --- /dev/null +++ b/build.sh | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | recursivebuild() { | ||
| 4 | local destdir=$(echo $1 | sed 's|^src|http|') | ||
| 5 | mkdir -p "$destdir" | ||
| 6 | for file in $(ls $1); do | ||
| 7 | if [ -d "$1/$file" ]; then | ||
| 8 | mkdir -p "$destdir/$file" | ||
| 9 | recursivebuild "$1/$file" | ||
| 10 | else | ||
| 11 | extension=$(echo "$file" | sed 's/.*\.//') | ||
| 12 | if [ "$extension" = "md" ]; then | ||
| 13 | sed "s/TITLE/$(grep '^\# ' < "$1/$file" \ | ||
| 14 | | sed 's/^\# //')/" < top.html \ | ||
| 15 | > "$destdir/index.html" | ||
| 16 | lowdown "$1/$file" >> "$destdir/index.html" | ||
| 17 | cat bottom.html >> "$destdir/index.html" | ||
| 18 | elif [ "$extension" = "html" ]; then | ||
| 19 | cat top.html "$1/$file" bottom.html \ | ||
| 20 | | sed "s/TITLE/$(grep '<!--TITLE: ' <\ | ||
| 21 | "$1/$file" \ | ||
| 22 | | sed 's/^<!--TITLE: //' \ | ||
| 23 | | sed 's/-->$//')/" \ | ||
| 24 | > "$destdir/index.html" | ||
| 25 | else | ||
| 26 | cp "$1/$file" "$destdir/$file" | ||
| 27 | fi | ||
| 28 | fi | ||
| 29 | done | ||
| 30 | } | ||
| 31 | |||
| 32 | recursivebuild src | ||
