blob: 1308a9927129eac0ce6f2151f78e9428b7d6d276 (
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
26
27
28
29
30
31
32
|
#!/bin/sh
recursivebuild() {
local destdir=$(echo $1 | sed 's|^src|http|')
mkdir -p "$destdir"
for file in $(ls $1); do
if [ -d "$1/$file" ]; then
mkdir -p "$destdir/$file"
recursivebuild "$1/$file"
else
extension=$(echo "$file" | sed 's/.*\.//')
if [ "$extension" = "md" ]; then
sed "s/TITLE/$(grep '^\# ' < "$1/$file" \
| sed 's/^\# //')/" < top.html \
> "$destdir/index.html"
lowdown "$1/$file" >> "$destdir/index.html"
cat bottom.html >> "$destdir/index.html"
elif [ "$extension" = "html" ]; then
cat top.html "$1/$file" bottom.html \
| sed "s/TITLE/$(grep '<!--TITLE: ' <\
"$1/$file" \
| sed 's/^<!--TITLE: //' \
| sed 's/-->$//')/" \
> "$destdir/index.html"
else
cp "$1/$file" "$destdir/$file"
fi
fi
done
}
recursivebuild src
|