From: paul Date: Wed, 29 Jul 2015 21:28:04 +0000 (+0000) Subject: split up functions in tagger X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=1f540143d78c7b001e89df09c57b04c063e79723;p=serve0 split up functions in tagger svn path=/trunk/; revision=66 --- diff --git a/pages/list.sh b/pages/list.sh index f970a32..9cf7e6f 100755 --- a/pages/list.sh +++ b/pages/list.sh @@ -22,6 +22,31 @@ filters="$(echo -E "$_GET[\"f\"]" |sed -r 's;^!*\^*;;; s;\^*!*$;;; s;!+;!;g; s;\^+;^;g')" debug "FILTERS: $filters" +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" + [ "$cat" = "none:" ] && cat='' + + printf %s "$taglist" \ + | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \ + | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \ + | sed 's;^0 ;;' +} + case "$1" in title) echo "Videos" diff --git a/templates/advfilter.html.sh b/templates/advfilter.html.sh index f63d4dc..dbfd323 100755 --- a/templates/advfilter.html.sh +++ b/templates/advfilter.html.sh @@ -15,30 +15,6 @@ # 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 @@ -54,29 +30,30 @@ EOF } 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 + for n in "$@"; 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: + + +
+ $(category_tabs $(list_categories) ) +
+
+ EOF + done } 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 filterbox "$n"; done) + $(filterbox {0..9})

diff --git a/templates/list.html.sh b/templates/list.html.sh index ca875df..a4e50bb 100755 --- a/templates/list.html.sh +++ b/templates/list.html.sh @@ -45,7 +45,7 @@ cat < $(thumblist) - $($_EXEC/templates/tagger.html.sh) + $(. $_EXEC/templates/tagger.html.sh)