page_this="${page_link}pn=$page"
taglist=$(
- [ -r ${_DATA}/cache/taglist ] && cat ${_DATA}/cache/taglist ||\
- for each in ${_DATA}/meta/*.meta; do
+if [ -r ${_DATA}/cache/taglist ]; then
+ cat ${_DATA}/cache/taglist
+else
+ truncate -s0 ${_DATA}/cache/taglist
+ truncate -s0 ${_DATA}/cache/tagnorm
+ (for each in ${_DATA}/meta/*.meta; do
sed -n '2s:|:\n:gp' "$each"
- done |sort -u |grep -xv '' |tee ${_DATA}/cache/taglist
+ done \
+ | sort
+ echo
+ ) | (while read tag; do
+ if [ "$tag" = "$lasttag" ]; then
+ tagcount=$(( ${tagcount:-0} + 1 ))
+ else
+ [ -n "$lasttag" ] && printf %s\\t%s\\n "$tagcount" "$lasttag"
+ tagcount=1
+ fi
+ lasttag="$tag"
+ done \
+ | sort -rn
+ echo
+ ) | while read x tag; do
+ topcnt=$(grep "${tag%%:*}" ${_DATA}/cache/taglist |wc -l)
+ [ $topcnt -lt 10 ] \
+ && printf %s\\n "$tag" >>${_DATA}/cache/taglist \
+ || printf %s\\n "$tag" >>${_DATA}/cache/tagnorm
+ done
+ cat ${_DATA}/cache/taglist
+ sort ${_DATA}/cache/tagnorm \
+ | tee -a ${_DATA}/cache/taglist
+ rm ${_DATA}/cache/tagnorm
+fi
)
list_categories(){