slitaz-forge rev 312
pkgs/search.sh: add tag cloud
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jun 10 19:04:52 2012 +0200 (2012-06-10) |
parents | 4b8f5923e787 |
children | 199cafb53ba9 |
files | pkgs/search.sh |
line diff
1.1 --- a/pkgs/search.sh Tue May 29 07:25:25 2012 +0000 1.2 +++ b/pkgs/search.sh Sun Jun 10 19:04:52 2012 +0200 1.3 @@ -786,20 +786,50 @@ 1.4 1.5 ### Tags 1.6 Tags) 1.7 - cat << _EOT_ 1.8 + if [ -n "$SEARCH" ]; then 1.9 + cat << _EOT_ 1.10 1.11 <h3>$(eval_gettext "Result for: \$SEARCH")</h3> 1.12 <table> 1.13 _EOT_ 1.14 - last="" 1.15 - grep ^TAGS= $WOK/*/receipt | grep -i "$SEARCH" | \ 1.16 - sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do 1.17 - . $WOK/$pkg/receipt 1.18 - package_entry 1.19 - done 1.20 - cat << _EOT_ 1.21 + last="" 1.22 + grep ^TAGS= $WOK/*/receipt | grep -i "$SEARCH" | \ 1.23 + sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do 1.24 + . $WOK/$pkg/receipt 1.25 + package_entry 1.26 + done 1.27 + cat << _EOT_ 1.28 </table> 1.29 _EOT_ 1.30 + else 1.31 + # Display tag cloud 1.32 + grep -l ^TAGS= $WOK/*/receipt | while read file; do 1.33 + TAGS= 1.34 + . $file 1.35 + echo $TAGS 1.36 + done | awk ' 1.37 +{ 1.38 + for (i = 1; $i != ""; i++) 1.39 + count[$i]++ 1.40 +} 1.41 +END { 1.42 + min=10000 1.43 + max=0 1.44 + for (i in count) { 1.45 + if (count[i] < min) min = count[i] 1.46 + if (count[i] > max) max = count[i] 1.47 + } 1.48 + for (i in count) 1.49 + print count[i] " " min " " max " " i 1.50 +}' | while read cnt min max tag ; do 1.51 + cat <<EOT 1.52 +<span style="color:#99f; font-size:9pt; padding-left:5px; padding-right:2px;">\ 1.53 +$cnt</span><a href="?tags=$tag&version=$SLITAZ_VERSION" style="\ 1.54 +font-size:$((8+(($cnt-$min)*10)/($max-$min)))pt; font-weight:bold; \ 1.55 +color:black; text-decoration:none">$tag</a> 1.56 +EOT 1.57 + done 1.58 + fi 1.59 ;; 1.60 1.61