From eec85ea1fe623ac2e2aae698625443a90bbf8fc6 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 20 Apr 2016 11:46:41 +0000 Subject: [PATCH] avoid redundant quicklinks svn path=/trunk/; revision=119 --- pages/quicklinks.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pages/quicklinks.sh b/pages/quicklinks.sh index 2172919..e46d930 100755 --- a/pages/quicklinks.sh +++ b/pages/quicklinks.sh @@ -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;$; \&\; ;g' + | sed -r ':X;N;$!bX;s;\n; \&\; ;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 'by %s: %s' \ - "$line" "${lineo}" "$(present_filter "$linef")" + printf %s "$output" |while read line norm; do + printf '%s' \ + "$line" "${norm}" done } -- 2.39.2