about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-09-22 14:48:04 -0500
committerCase Duckworth2022-09-22 14:48:04 -0500
commit61329065110b7ab978a2ccc02ea3dd95dbdaf344 (patch)
treedf08796bc239dc7235eba449168d90dbb508e016
parentFix bug (diff)
downloadshite-61329065110b7ab978a2ccc02ea3dd95dbdaf344.tar.gz
shite-61329065110b7ab978a2ccc02ea3dd95dbdaf344.zip
Add cleanup and better logging
-rwxr-xr-xshite22
1 files changed, 15 insertions, 7 deletions
diff --git a/shite b/shite index 3c90130..74bd9af 100755 --- a/shite +++ b/shite
@@ -30,10 +30,10 @@ phtml() {
30 30
31meta() { 31meta() {
32 tmp="/tmp/$file.meta" 32 tmp="/tmp/$file.meta"
33 echo "$tmp" >>/tmp/shite 33 echo "$tmp" >>/tmp/shite.tmp
34 trap 'rm /tmp/shite' EXIT INT 34 test -f "$tmp" ||
35 test -f "$tmp" || sed -n '/<!--/,/-->/p' >"$tmp" 35 sed -n '/<!--/,/-->/p' >"$tmp"
36 sed -n "s/^$1:[ \t]*//p" "$tmp" 36 sed -n "s/^[ \t]*$1:[ \t]*//p" "$tmp"
37} 37}
38 38
39title() { 39title() {
@@ -50,7 +50,7 @@ filters() {
50 50
51pages() { 51pages() {
52 for file; do 52 for file; do
53 echo >&2 "$file" 53 echo >&2 "[build] $file"
54 mkdir -p "$OUT"/"${file%.htm}" 54 mkdir -p "$OUT"/"${file%.htm}"
55 filters <"$file" | 55 filters <"$file" |
56 expand .template.html >"$OUT"/"${file%.htm}"/index.html 56 expand .template.html >"$OUT"/"${file%.htm}"/index.html
@@ -59,14 +59,14 @@ pages() {
59 59
60index() { 60index() {
61 for file; do 61 for file; do
62 echo >&2 "index: $file" 62 echo >&2 "[index] $file"
63 echo "<li><a href=\"$file\">$(title "$file")</a></li>" 63 echo "<li><a href=\"$file\">$(title "$file")</a></li>"
64 done | expand .index.html >"$OUT"/index.html 64 done | expand .index.html >"$OUT"/index.html
65} 65}
66 66
67feed() { 67feed() {
68 for file; do 68 for file; do
69 echo >&2 "feed: $file" 69 echo >&2 "[feed] $file"
70 echo "<item>" 70 echo "<item>"
71 echo " <title>$(title "$file")</title>" 71 echo " <title>$(title "$file")</title>"
72 echo " <link>$DOMAIN/${file%.htm}/</link>" 72 echo " <link>$DOMAIN/${file%.htm}/</link>"
@@ -98,7 +98,15 @@ EOF
98 exit ${1:-0} 98 exit ${1:-0}
99} 99}
100 100
101cleanup() {
102 while read f; do
103 rm "$f"
104 done </tmp/shite.tmp
105 rm /tmp/shite.tmp
106}
107
101main() { 108main() {
109 trap cleanup EXIT INT
102 DOMAIN="${SHITE_DOMAIN:-${PWD##*/}}" 110 DOMAIN="${SHITE_DOMAIN:-${PWD##*/}}"
103 SOURCE="$PWD" 111 SOURCE="$PWD"
104 OUT=out 112 OUT=out