From 515c2d0ff3d2858990a1d8343467191b8484268f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 25 Jul 2018 03:24:26 +0200 Subject: [PATCH] bugfix: allow index generation --- index.cgi | 26 ++++++++++++++------------ list.sh | 3 +-- widgets.sh | 5 +++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/index.cgi b/index.cgi index fa342bb..8367f92 100755 --- a/index.cgi +++ b/index.cgi @@ -18,8 +18,9 @@ SEARCH="$(GET s)" ORDER="$(GET o |grep -m1 -axE 'Date|Name|Length' || printf Name)" LISTSIZE="$(COOKIE pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)" ITEM="$(PATH "${PATH_INFO#/}")" +ACTION="$(GET a)" -case $(GET a) in +case $ACTION in setprefs) SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)" SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -axE 'browse|index' || printf browse)" @@ -48,7 +49,7 @@ if [ "$ITEM" = "/style.css" ]; then [ -r "$_DATA/$ITEM" ] && FILE "$_DATA/$ITEM" \ || FILE "$_EXEC/style.css" elif [ -f "$_DATA/$ITEM" ]; then - case $(GET a) in + case $ACTION in tag) ;; thumbnail) @@ -67,21 +68,22 @@ elif [ -f "$_DATA/$ITEM" ]; then ;; esac elif [ -d "$_DATA/$ITEM" ]; then - case $(GET a) in + case $ACTION in advsearch) . "$_EXEC/advsearch.sh" ;; - spawnindex) - if [ "$(POST recursive)" = yes ]; then - find "$_DATA/$ITEM" -depth -type d \! -name .index \ - -exec mkdir -p '{}'/.index \; - else - mkdir -p "$_DATA/$ITEM/.index" - fi - REDIRECT "$(POST ref)" - ;; multitag) + if [ "$(POST spawn)" = spawn ]; then + case "$(POST recursive)" in + yes) find "$_DATA/$ITEM" \ + -depth -type d \! -name .index \ + -exec mkdir -p '{}'/.index \; + ;; + *) mkdir -p "$_DATA/$ITEM/.index";; + esac + else . "$_EXEC/multitag.sh" + fi REDIRECT "$(POST ref)" ;; *) . "$_EXEC/list.sh" diff --git a/list.sh b/list.sh index 71f70f9..778ea11 100644 --- a/list.sh +++ b/list.sh @@ -191,8 +191,7 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' list_items \ | list_paginate printf ' - [div #editing - [a href="#multitag" Add Tags]' + [div #editing' w_index || w_tagging printf ' ] diff --git a/widgets.sh b/widgets.sh index 446b5d2..27f5c5b 100644 --- a/widgets.sh +++ b/widgets.sh @@ -148,7 +148,7 @@ w_prefs(){ w_index(){ [ -d "$_DATA/$ITEM/.index" ] && return 1 || printf ' - [form #index method="POST" action="?a=spawnindex" + [form #index method="POST" action="?a=multitag" [hidden "ref" "%s"] [label Set up for Index view: ] [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories] @@ -225,7 +225,8 @@ w_advsearch(){ w_tagging(){ local tag category - printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri" + printf '[a href="#multitag" Add Tags] + [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri" printf '[a href="#" Hide][br]' printf 'Tags\n%s\n' "$w_tagcategories" \ -- 2.39.2