From 18eaa57ea874a8bf1ebae2a0d758a4bb7632cf37 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 29 Jul 2015 18:16:23 +0000 Subject: [PATCH] split up functions in filter box generator svn path=/trunk/; revision=65 --- templates/advfilter.html.sh | 123 +++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 57 deletions(-) diff --git a/templates/advfilter.html.sh b/templates/advfilter.html.sh index 80ec4c2..f63d4dc 100755 --- a/templates/advfilter.html.sh +++ b/templates/advfilter.html.sh @@ -15,6 +15,70 @@ # You should have received a copy of the GNU Affero General Public License # along with Serve0 If not, see . +quicklinks(){ + output='' + tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do + line="$line" + echo "$output" |grep -qF "$line" || output="$output$line\n" + done + echo $output +} + +list_categories(){ + echo none + printf %s "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u +} + +category_selected(){ + cat="$1" + filter="$2" + + printf %s "$taglist" \ + | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \ + | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \ + | sed 's;^0 ;;' +} + +category_tabs(){ + for cat in "$@"; do + cat < + + + + +EOF + done +} + +filterbox(){ + n=$1 + filter="$(printf '%s^' "$filters" |cut -d^ -f$(($n+1)))" + fneg="${filter%%[a-zA-Z]*}" + filter="${filter#!}" + fcat="${filter%%:*}" + [ "$fcat" = "$filter" ] && fcat=none + + debug "fneg: $fneg fcat: $fcat filter: $filter" + + cat < + +
+ + + of the items selected here: + + +
+ $(category_tabs $(list_categories) ) +
+
+EOF +} + cat < @@ -32,56 +96,7 @@ cat <

Up to 10 filter boxes will appear as you start selecting tags. You can select multiple tags in each box by holding down the Ctrl-key. Click the "Filter!" button when you are ready.

- - $(for n in {0..9}; do - filter="$(printf '%s^' "$filters" |cut -d^ -f$(($n+1)))" - fneg="${filter%%[a-zA-Z]*}" - filter="${filter#!}" - fcat="${filter%%:*}" - [ "$fcat" = "$filter" ] && fcat=none - - debug "fneg: $fneg fcat: $fcat filter: $filter" - - cat <<-EOF - - -
- - - of the items selected here: - - -
-
- - - -
- $( echo "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u \ - |while read cat; do echo " -
- - - -
- " - done) -
-
- EOF - done) + $(for n in {0..9}; do filterbox "$n"; done)

@@ -95,13 +110,7 @@ cat < - $(output='' - tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do - line="$line" - echo "$output" |grep -qF "$line" || output="$output$line\n" - done - echo $output - ) + $(quicklinks)

EOF -- 2.39.2