From b8e2146aaabd7acdff878cd3061de7e24a0a91b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 16 Jul 2018 10:47:31 +0200 Subject: [PATCH] localize function variables --- cgilite | 2 +- indexmeta.sh | 5 +++++ list.sh | 8 +++++++- widgets.sh | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cgilite b/cgilite index a55a4d8..318867d 160000 --- a/cgilite +++ b/cgilite @@ -1 +1 @@ -Subproject commit a55a4d8fb1dae783a93492c7d9b55d042791864f +Subproject commit 318867de22a49dc1e348cc1173ee4cdeb977d7b1 diff --git a/indexmeta.sh b/indexmeta.sh index 30bf32d..2e4e74f 100644 --- a/indexmeta.sh +++ b/indexmeta.sh @@ -7,6 +7,7 @@ include_indexmeta="$0" file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$' meta_name() { + local fn fn="$1" fn="${fn##*/}" fn="${fn%.*}" @@ -15,6 +16,7 @@ meta_name() { } meta_line() { + local video l w h video="$1" read l h w <<__EOF @@ -32,6 +34,7 @@ __EOF } meta_file(){ + local file meta name file="$1" meta="${file%/*}/.index/meta" name="$(meta_name "$file")" @@ -46,6 +49,7 @@ meta_file(){ } meta_info(){ + local file meta file="$1" meta="${file%/*}/.index/meta" @@ -59,6 +63,7 @@ meta_info(){ } meta_dir(){ + local dir meta v dir="${1}" meta="${dir}/.index/meta" diff --git a/list.sh b/list.sh index 18dc98d..03b9845 100644 --- a/list.sh +++ b/list.sh @@ -4,6 +4,7 @@ . "$_EXEC/widgets.sh" list_item() { + local name path length width height tags comment n name="$(HTML "$1")" path="$(HTML "$ITEM/$1")" @@ -37,6 +38,7 @@ list_fs_browse(){ ) } list_fs_index(){ + local d find "$_DATA/$ITEM" -type d -name .index \ | while d="$(line)"; do meta_dir "${d%/.index}" @@ -48,6 +50,7 @@ list_fs_index(){ } list_browse(){ + local meta f fn file meta="$_DATA/$ITEM/.index/meta" meta_dir "$_DATA/$ITEM" (cd "$_DATA/$ITEM"; @@ -58,12 +61,13 @@ list_browse(){ fn="$(UNSTRING "${f#* }")"; fn="${fn%${CR}}"; file="$(printf '%s\n' "$_DATA/$ITEM/${fn}".*)" file="${file##*/}" - [ -e "$_DATA/$ITEM/$base/${file}" ] \ + [ -e "$_DATA/$ITEM/${file}" ] \ && printf '%s\n' "${file}" done } list_index(){ + local meta base fn file (cd "$_DATA/$ITEM"; find ./ -path '*/.index/meta' ) | while meta="$(line)"; do @@ -83,6 +87,7 @@ list_index(){ } list_items() { + local mode mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )" [ "$mode" = browse -a "$ITEM" ] && printf '..\n' @@ -103,6 +108,7 @@ list_items() { } list_paginate() { + local page i c n page="$(GET p |grep -xE '[0-9]+' || printf 1)" printf '[div .itemlist ' diff --git a/widgets.sh b/widgets.sh index dc16b30..bb3ac22 100644 --- a/widgets.sh +++ b/widgets.sh @@ -25,6 +25,7 @@ w_search(){ } w_prefs(){ + local fakemp4 mode fakemp4="$(COOKIE fakemp4)" mode="$(COOKIE mode)" printf ' @@ -57,6 +58,7 @@ w_index(){ } w_tagging(){ + local tag category printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$(HTML "$REQUEST_URI")" printf '[a href="#" Hide][br]' -- 2.39.2