X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=widgets.sh;h=4e93629165dedb3386802eb692e8bd33399917ca;hb=09b108b3ecd6c49467d0030576468c6cbf93c2f0;hp=6af562e84cb4f4e7fa6e3d703472e8df144737db;hpb=cfb24f8d9e3106608a08603d22f67816621dc807;p=serve0 diff --git a/widgets.sh b/widgets.sh old mode 100644 new mode 100755 index 6af562e..4e93629 --- a/widgets.sh +++ b/widgets.sh @@ -4,6 +4,7 @@ include_widgets="$0" . "$_EXEC/cgilite/storage.sh" +. "$_EXEC/db_meta.sh" w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")" @@ -14,23 +15,14 @@ c_tags="$_DATA/.index/tags.cache"; c_tagcategories="$_DATA/.index/tagcategories. if [ ! -s "$c_tags" -o ! -s "$c_tagcategories" ] \ || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$c_tags")" ] then - w_tags="$( cn=1 - find "$_DATA/" -path '*/.index/meta' -print0 \ - | xargs -0 -r sed -E ' - s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;; - s;,;\n;g;' \ - | { sort; printf '\n'; } \ - | while read -r tag; do - if [ "$tag" = "$otag" ]; then - cn=$((cn + 1)) - else - printf "%i %s\n" "$cn" "$(UNSTRING "$otag")" - cn=1 - fi - otag="$tag" - done \ - |sort -rn |cut -f2- |HTML \ - |sed "s- -\n-g; s;\n\n;\n;g;" + w_tags="$( + list_meta |sed -E ' + s;^.*\ttags=([^\t]*)\t.*$;\1;; + s;,;\n;g; + ' \ + | sort |uniq -c |sort -rn |sed -E 's;^ *[0-9]+ ;;;' \ + | 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"