FILTER="$(GET f)"
SEARCH="$(GET s)"
-ORDER="$(GET o |grep -m1 -axE 'Date|Name|Length' || printf Name)"
+ORDER="$(GET o |grep -m1 -axE 'Date|Name|Length|Group' || printf Name)"
LISTSIZE="$(COOKIE pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
ITEM="$(PATH "${PATH_INFO#/}")"
ACTION="$(GET a)"
fi
}
+groupmatch(){
+ if [ ${#1} -gt ${#2} ]; then
+ long="$1" short="$2"
+ else
+ long="$2" short="$1"
+ fi
+ com="$(expr substr "$long" 1 $((${#long} * 3 / 4)))"
+ cut="${short#$com}"
+ if [ ${#cut} -lt ${#short} ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
list_order(){
- local fm fn fn
+ local fm fn fn al length ln h w t c name buffer l
if [ $ORDER = Name ]; then
sort -k6 |sed 's;^;metashort\t;;'
+ elif [ $ORDER = Group ]; then
+ { sort -k6; echo '0 0 0 tags= comment= _'; } \
+ | while read -r length h w t c name; do
+ if groupmatch "$ln" "$name"; then
+ al=$((al + length))
+ buffer="${buffer}${BR}$length $h $w $t $c $name"
+ else
+ printf %s\\n "$buffer" |while read -r l; do
+ [ "$l" ] && printf '%s %s\n' "$al" "$l"
+ done
+ al="$length"
+ buffer="$length $h $w $t $c $name"
+ fi
+ ln="$name"
+ done \
+ | sort -n -k1 |cut -f2- |sed 's;^;metashort\t;;'
elif [ $ORDER = Length ]; then
sort -n -k1 |sed 's;^;metashort\t;;'
elif [ $ORDER = Date ]; then
printf '%i %s %s\n' \
"$(stat -c %Y "$fn")" "${fm% *}" "$fn"
done \
- | sort -rn -k1 |cut -f2- |sed 's;^;metalong\t;;'
+ | sort -rn -k1 |sed -r 's;^[0-9]+\t;metalong\t;;'
fi
}
[ "$ORDER" = Name ] && w_coname=checked
[ "$ORDER" = Date ] && w_codate=checked
[ "$ORDER" = Length ] && w_colength=checked
+[ "$ORDER" = Group ] && w_cogroup=checked
w_bookmarks(){
local name='' cf='' cs='' bm="$_DATA/.index/bookmarks" proposed_name=''
[option value=Name %s Name]
[option value=Date %s Date]
[option value=Length %s Length]
+ [option value=Group %s Grouplength]
]
[input name=s placeholder=Search value="%s"]
]
' \
- "$w_coname" "$w_codate" "$w_colength" \
+ "$w_coname" "$w_codate" "$w_colength" "$w_cogroup" \
"$(HTML "$SEARCH")"
}
[option value=Name %s Name]
[option value=Date %s Date]
[option value=Length %s Length]
+ [option value=Group %s Grouplength]
][button type=submit Apply Filter]]
]' \
- "$w_coname" \
- "$w_codate" \
- "$w_colength"
+ "$w_coname" "$w_codate" \
+ "$w_colength" "$w_cogroup"
}
w_tagging(){