about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-01-06 22:40:56 -0600
committerCase Duckworth2023-01-06 22:40:56 -0600
commita1e594bb440bb37ef1c99b68f24f62b4a72a99c7 (patch)
treee590035d40ce02f9a6d38f1e694865203841dcfe
parentShorten 'meta' (diff)
downloadvienna-a1e594bb440bb37ef1c99b68f24f62b4a72a99c7.tar.gz
vienna-a1e594bb440bb37ef1c99b68f24f62b4a72a99c7.zip
Add sort_items
This allows list functions to work with a sorted list.. whatever that sorting
may be.  The default is 'cat', which is purposefully not very useful.
-rwxr-xr-xvienna20
1 files changed, 14 insertions, 6 deletions
diff --git a/vienna b/vienna index f40f027..e88941d 100755 --- a/vienna +++ b/vienna
@@ -346,6 +346,7 @@ genpage() { # genpage PAGE...
346} 346}
347 347
348genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE... 348genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
349 ## Generate a list.
349 peritem_func="$1" 350 peritem_func="$1"
350 template_file="$2" 351 template_file="$2"
351 tmpf="$TMPD/$1" 352 tmpf="$TMPD/$1"
@@ -355,12 +356,19 @@ genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
355 echo | expand "$template_file" 356 echo | expand "$template_file"
356 return 357 return
357 fi 358 fi
358 for FILE; do 359 printf '%s\n' "$@" | sort_items |
359 log genlist "$peritem_func" "$FILE" 360 while read -r FILE; do
360 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" 361 log genlist "$peritem_func" "$FILE"
361 META="$TMPD/$FILE.meta" 362 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}"
362 "$peritem_func" "$FILE" 363 META="$TMPD/$FILE.meta"
363 done | expand "$template_file" 364 "$peritem_func" "$FILE"
365 done | expand "$template_file"
366}
367
368sort_items() { # sort_items < ITEMS
369 ## Sort ITEMS separated by newlines.
370 # This function assumes that no ITEM contains a newline.
371 cat
364} 372}
365 373
366index_item() { # index_item PAGE 374index_item() { # index_item PAGE