-w_tags="$( {
- find "$_DATA/" -path '*/.index/meta' -print0 \
- | xargs -r0 sed -r '
- s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;;
- s;,;\n;g;'"$UNSTRING" \
- | sort \
- | while read tag; do
- [ "$tag" = "$otag" ] \
- && cn=$((${cn:-0} + 1)) \
- || {
- printf "%i %s\n" "$cn" "$otag"
- cn=1
- }
- otag="$tag"
- done
- printf "%i %s\n" "$cn" "$otag"
-} |sort -rn |cut -f2- )"
-w_tagcategories="$(printf %s "$w_tags" | cut -sd: -f1 | sort -u \
- |HTML |sed 's;:\;;:;g; s;
\;;\n;g;')"
-w_tags="$( printf %s "$w_tags" |HTML |sed 's;:\;;:;g; s;
\;;\n;g;')"
+w_str_s="$(STRING "$SEARCH")"
+w_str_f="$(STRING "$FILTER")"
+
+c_tags="$_DATA/.index/tags.cache"; c_tagcategories="$_DATA/.index/tagcategories.cache"
+if [ ! -s "$c_tags" -o ! -s "$c_tagcategories" ] \
+ || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$c_tags")" ]
+ then
+ w_tags="$(
+ list_meta |sed -E '
+ s;^.*\ttags=([^\t]*)\t.*$;\1;;
+ s;,;\n;g;
+ ' \
+ | sort |uniq -c |sed -E 's;^ *[0-9]+ ;;;' |sort -rn \
+ | UNSTRING | HTML \
+ | sed -E 's;
\;;\n;g; s;\n+;\n;g;'
+ )"
+ w_tagcategories="$(printf %s "$w_tags" | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u )"
+ printf %s "$w_tags" >"$c_tags"
+ printf %s "$w_tagcategories" >"$c_tagcategories"
+else
+ w_tags="$(cat "$c_tags")"
+ w_tagcategories="$(cat "$c_tagcategories")"
+fi
+