about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xvienna49
1 files changed, 34 insertions, 15 deletions
diff --git a/vienna b/vienna index 90e5c03..8c3c92f 100755 --- a/vienna +++ b/vienna
@@ -109,15 +109,15 @@ main() {
109 mkdir -p "$TMPD" || exit 2 109 mkdir -p "$TMPD" || exit 2
110 # Build pages 110 # Build pages
111 alias pagep=true 111 alias pagep=true
112 build *."$PAGE_RAW_EXT" || exit 2 112 genpage *."$PAGE_RAW_EXT" || exit 2
113 alias pagep=false 113 alias pagep=false
114 # Build index 114 # Build index
115 alias indexp=true 115 alias indexp=true
116 index *."$PAGE_RAW_EXT" || exit 2 116 genlist index_item "$INDEX_TEMPLATE" *."$PAGE_RAW_EXT" >"$OUTD/index.html" || exit 2
117 alias indexp=false 117 alias indexp=false
118 # Build feed 118 # Build feed
119 alias feedp=true 119 alias feedp=true
120 feed *."$PAGE_RAW_EXT" || exit 2 120 genlist feed_item "$FEED_TEMPLATE" *."$PAGE_RAW_EXT" >"$OUTD/feed.xml" || exit 2
121 alias feedp=false 121 alias feedp=false
122 # Copy static files 122 # Copy static files
123 static * || exit 2 123 static * || exit 2
@@ -261,12 +261,12 @@ filters() { # filters < INPUT
261 261
262### Site building 262### Site building
263 263
264build() { # build PAGE... 264genpage() { # genpage PAGE...
265 ## Compile PAGE(s) into $OUTD for publication. 265 ## Compile PAGE(s) into $OUTD for publication.
266 # Outputs a file of the format $OUTD/<PAGE>/index.html. 266 # Outputs a file of the format $OUTD/<PAGE>/index.html.
267 test -f "$PAGE_TEMPLATE" || return 1 267 test -f "$PAGE_TEMPLATE" || return 1
268 for FILE; do 268 for FILE; do
269 log build "$FILE" 269 log genpage "$FILE"
270 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}" 270 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}"
271 outf="$outd/index.html" 271 outf="$outd/index.html"
272 tmpf="$TMPD/$FILE.tmp" 272 tmpf="$TMPD/$FILE.tmp"
@@ -276,14 +276,40 @@ build() { # build PAGE...
276 done 276 done
277} 277}
278 278
279genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
280 peritem_func="$1"
281 template_file="$2"
282 shift 2 || return 2
283 test -f "$template_file" || return 1
284 for FILE; do
285 log genlist "$peritem_func/$template_file: $FILE"
286 LINK="$DOMAIN${DOMAIN:+/}${1%.PAGE_RAW_EXT}"
287 done | expand "$template_file"
288}
289
290index_item() { # index_item PAGE
291 ## Construct a single item in an index.html.
292 echo "<li><a href=\"$LINK\">$(meta title "$1")</a></li>"
293}
294
295feed_item() { # feed_item PAGE
296 ## Construct a single item in an RSS feed.
297 date="$(pubdate "$1")"
298 echo "<item>"
299 echo "<title>$(meta title "$1")</title>"
300 echo "<link>$LINK</link>"
301 echo "<guid>$LINK</guid>"
302 test -n "$date" && echo "<pubDate>$date</pubDate>"
303 echo "</item>"
304}
305
279index() { # index PAGE... 306index() { # index PAGE...
280 ## Build a site index from all PAGE(s) passed to it. 307 ## Build a site index from all PAGE(s) passed to it.
281 # Wraps each PAGE in a <li><a> structure. 308 # Wraps each PAGE in a <li><a> structure.
282 test -f "$INDEX_TEMPLATE" || return 1 309 test -f "$INDEX_TEMPLATE" || return 1
283 for FILE; do 310 for FILE; do
284 log index "$FILE" 311 log index "$FILE"
285 link="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" 312 index_item "$FILE"
286 echo "<li><a href=\"$link\">$(meta title "$FILE")</a></li>"
287 done | expand "$INDEX_TEMPLATE" >"$OUTD/index.html" 313 done | expand "$INDEX_TEMPLATE" >"$OUTD/index.html"
288} 314}
289 315
@@ -292,14 +318,7 @@ feed() { # feed PAGE...
292 test -f "$FEED_TEMPLATE" || return 1 318 test -f "$FEED_TEMPLATE" || return 1
293 for FILE; do 319 for FILE; do
294 log feed "$FILE" 320 log feed "$FILE"
295 link="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" 321 feed_item "$FILE"
296 date="$(meta pubdate "$FILE")"
297 echo "<item>"
298 echo "<title>$(meta title "$FILE")</title>"
299 echo "<link>$link</link>"
300 echo "<guid>$link</guid>"
301 test -n "$date" && echo "<pubDate>$date</pubDate>"
302 echo "</item>"
303 done | expand "$FEED_TEMPLATE" >"$OUTD/feed.xml" 322 done | expand "$FEED_TEMPLATE" >"$OUTD/feed.xml"
304} 323}
305 324