diff options
author | Case Duckworth | 2023-01-06 22:40:56 -0600 |
---|---|---|
committer | Case Duckworth | 2023-01-06 22:40:56 -0600 |
commit | a1e594bb440bb37ef1c99b68f24f62b4a72a99c7 (patch) | |
tree | e590035d40ce02f9a6d38f1e694865203841dcfe | |
parent | Shorten 'meta' (diff) | |
download | vienna-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-x | vienna | 20 |
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 | ||
348 | genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE... | 348 | genlist() { # 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 | |||
368 | sort_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 | ||
366 | index_item() { # index_item PAGE | 374 | index_item() { # index_item PAGE |