]> git.plutz.net Git - serve0/commitdiff
maintain different top lists for tag selection and setting
authorpaul <paul@plutz.net>
Wed, 20 Apr 2016 13:24:48 +0000 (13:24 +0000)
committerpaul <paul@plutz.net>
Wed, 20 Apr 2016 13:24:48 +0000 (13:24 +0000)
svn path=/trunk/; revision=120

actions/meta.sh
actions/multitag.sh
pages/common.sh
pages/list.sh
pages/quicklinks.sh
templates/playctl.html.sh
templates/tagger.html.sh
templates/view.html.sh

index f2e24317288d6d9b8aabea5b1258d1332ac3e870..127e03e6aac21f7fb7225d32dc24cb293853fb8d 100755 (executable)
@@ -52,7 +52,7 @@ ${description}
 EOF
   rm "${_DATA}/cache/$info.cache" 2>/dev/null
   rm ${_DATA}/cache/\?* 2>/dev/null
-  rm ${_DATA}/cache/taglist 2>/dev/null
+  rm ${_DATA}/cache/taglist_set ${_DATA}/cache/taglist_filter 2>/dev/null
 fi
 
 redirect "?i=&pn=${page}&s=${search}&f=${filter}&o=${order}#${info}"
index c5a8df12c4a3c12a456cac8b359eed1bbbfd4a61..767f289e85665df68b91d7c5e781ffb72049939a 100755 (executable)
@@ -62,6 +62,6 @@ while [ -n "${_POST[tagsel$n]}" ]; do
 done
 
 rm "${_DATA}"/cache/\?* 2>/dev/null
-[ -n "${_POST[tags]}" ] && rm "${_DATA}"/cache/taglist 2>/dev/null
+[ -n "${_POST[tags]}" ] && rm "${_DATA}"/cache/taglist_set "${_DATA}"/cache/taglist_filter 2>/dev/null
 
 redirect "?o=$order&s=$search&f=$filter&pn=$page"
index 0d33ee4e5336f20d2d2f4e5142ec3d72de50bfe3..ba4cf27b5d6bdc2055d57a9e363076901dfd0cf0 100755 (executable)
@@ -33,44 +33,71 @@ page_link=''
 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(){
index 2c4b1f18ee2dd6ecbf58aefd41b0496d2f3328cb..4d25103059d14932a90e552442c7cd152ca41df1 100755 (executable)
@@ -44,7 +44,7 @@ category_selected(){
   filter="$2"
   [ "$cat" = "none:" ] && cat=''
 
-  printf %s "$taglist" \
+  printf %s "$taglist_filter" \
   | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \
   | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \
   | sed 's;^0 ;<option>;;s;^1 ;<option selected>;;s;$;</option>;'
index e46d930a0efa0e3df171c227a7bd2aeb9864634d..f22a412129ee7a7d5adafe7d6b45a70084039957 100755 (executable)
@@ -52,7 +52,7 @@ category_selected(){
   filter="$2"
   [ "$cat" = "none:" ] && cat=''
 
-  printf %s "$taglist" \
+  printf %s "$taglist_filter" \
   | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \
   | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \
   | sed 's;^0 ;<option>;;s;^1 ;<option selected>;;s;$;</option>;'
index f073800948af7e8c8e53fb0686a6cf828f3a1cda..7ef07009db5ffe7d55d64e66cedb3421e15f6d43 100755 (executable)
@@ -78,7 +78,7 @@ cat <<EOF
       catt="${cat}:"
       [ "$catt" = "none:" ] && catt=''
       
-      printf %s "$taglist" |egrep '^'"$catt"'[^:]+$' |while read line; do
+      printf %s "$taglist_set" |egrep '^'"$catt"'[^:]+$' |while read line; do
         printf '<option %s value="%s">%s</option>' \
                "$(egrep -q "(^|.*\|)$line(\|.*|$)" "$meta" && printf selected)" \
                "$line" "${line#*:}"
index 10ed7878b9eb883c71e8b5a68914c648df566321..f92bf0c61083904c41b3ec7eb4b1ba80eff66b89 100755 (executable)
@@ -19,7 +19,7 @@ category_options(){
   cat="${1}:"
   [ "$cat" = "none:" ] && cat=''
 
-  printf %s "$taglist" \
+  printf %s "$taglist_set" \
   | sed -rn 's;^('"$cat"')([^:]+)$;<option value="\1\2">\2</option>;p'
 }
 
index 46a1d412edfd89806bef41ca0ff9f0e1b587588d..8df1b5695061f02e9956dc00f6748bb8393ef7de 100755 (executable)
@@ -64,7 +64,7 @@ cat <<EOF
       catt="${cat}:"
       [ "$catt" = "none:" ] && catt=''
       
-      printf %s "$taglist" |egrep '^'"$catt"'[^:]+$' |while read line; do
+      printf %s "$taglist_set" |egrep '^'"$catt"'[^:]+$' |while read line; do
         printf '<option %s value="%s">%s</option>' \
                "$(egrep -q "(^|.*\|)$line(\|.*|$)" "$meta" && printf selected)" \
                "$line" "${line#*:}"