]> git.plutz.net Git - serve0/blobdiff - pages/quicklinks.sh
styling for pagination links
[serve0] / pages / quicklinks.sh
index 21729197590428c16eea49c65fd105d06537595b..f22a412129ee7a7d5adafe7d6b45a70084039957 100755 (executable)
@@ -25,23 +25,25 @@ filters="${_GET[f]}"
 debug "FILTERS: $filters"
 
 present_filter(){
-  printf %s\\n "$*" \
+  printf %s "$*" |sed -nr '1s;^.*(\?|&)o=([^&]+)&?.*$;by \2: ;p'
+
+  printf %s "$*" \
+  | sed -nr '1s;^.*(\?|&)f=([^&]+)&?.*$;\2;p' \
   | sed -r 's;(^|!|\^|\|)([^!\^\|:]+:);\1;g;s;\^;\n;g' \
   | sort -r \
-  | sed -r '$q;s;$; \&amp\; ;g'
+  | sed -r ':X;N;$!bX;s;\n; \&amp\; ;g'
 }
 
 quicklinks(){
   output=''
   tac ${_DATA}/meta/recent \
   | while [ "$(printf %s "$output" |wc -l)" -lt 30 ] && read line; do
-    printf %s "$output" |grep -qF "$line" || output="$output$line$LF"
+    norm="$(present_filter "$line")"
+    printf %s "$output" |grep -qF "$norm" || output="$output$line $norm$LF"
   done 
-  printf %s "$output" |while read line; do
-    linef=$(printf %s "$line" |sed -r 's;^.*(\?|&)f=([^&]+)&?.*$;\2;g')
-    lineo=$(printf %s "$line" |sed -r 's;^.*(\?|&)o=([^&]+)&?.*$;\2;g')
-    printf '<input type="checkbox"><a target="blank" href="%s">by %s: %s</a>' \
-           "$line" "${lineo}" "$(present_filter "$linef")"
+  printf %s "$output" |while read line norm; do
+    printf '<input type="checkbox"><a target="blank" href="%s">%s</a>' \
+           "$line" "${norm}"
   done
 }
 
@@ -50,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>;'