page_next="${page_link}pn=$(($page + $pagesize))"
page_this="${page_link}pn=$page"
-taglist=$(
-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
- printf \\n
- ) | (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
- printf \\n
- ) | 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
+taglist_set=$(
+ if [ -r ${_DATA}/cache/taglist_set ]; then
+ cat ${_DATA}/cache/taglist_set
+ else
+ truncate -s0 ${_DATA}/cache/taglist_set
+ truncate -s0 ${_DATA}/cache/tagnorm
+
+ ( sed -sn '2s;|;\n;gp' "${_DATA}/meta/"*.meta \
+ | sort
+ printf \\n
+ ) | 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 \
+ | while read x tag; do
+ topcnt=$(grep -c "${tag%%:*}" ${_DATA}/cache/taglist_set)
+ [ $topcnt -lt 10 ] \
+ && printf %s\\n "$tag" >>${_DATA}/cache/taglist_set \
+ || printf %s\\n "$tag" >>${_DATA}/cache/tagnorm
+ done
+
+ cat ${_DATA}/cache/taglist_set
+ sort ${_DATA}/cache/tagnorm \
+ | tee -a ${_DATA}/cache/taglist_set
+ rm ${_DATA}/cache/tagnorm
+ fi
+)
+
+taglist_filter=$(
+ if [ -r ${_DATA}/cache/taglist_filter ]; then
+ cat ${_DATA}/cache/taglist_filter
+ else
+ truncate -s0 ${_DATA}/cache/taglist_filter
+ truncate -s0 ${_DATA}/cache/tagnorm
+
+ sed -sn '2s;|;\n;gp' "${_DATA}/meta/"*.meta \
+ | sort -u \
+ | while read tag; do
+ cnt="$(grep -cF "$tag" ${_DATA}/meta/recent)"
+ printf '%s\t%s\n' "$cnt" "$tag"
+ done \
+ | sort -rn \
+ | while read x tag; do
+ topcnt=$(grep -c "${tag%%:*}" ${_DATA}/cache/taglist_filter)
+ [ $topcnt -lt 10 ] \
+ && printf %s\\n "$tag" >>${_DATA}/cache/taglist_filter \
+ || printf %s\\n "$tag" >>${_DATA}/cache/tagnorm
+ done
+
+ cat ${_DATA}/cache/taglist_filter
+ sort ${_DATA}/cache/tagnorm \
+ | tee -a ${_DATA}/cache/taglist_filter
+ rm ${_DATA}/cache/tagnorm
+ fi
)
list_categories(){
printf none\\n
- printf %s "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u
+ printf %s "$taglist_filter" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u
}
genthumb(){