From: <de...@de...> - 2007-04-30 21:00:57
|
Author: ArthurClemens Date: 2007-04-30 16:00:57 -0500 (Mon, 30 Apr 2007) New Revision: 13597 Modified: twiki/branches/MAIN/twikiplugins/TagMePlugin/data/TWiki/TagMePlugin.txt twiki/branches/MAIN/twikiplugins/TagMePlugin/lib/TWiki/Plugins/TagMePlugin.pm Log: Item3919: update calculation of sizes in tag cloud so that only sizes of shown tags are calculated Modified: twiki/branches/MAIN/twikiplugins/TagMePlugin/data/TWiki/TagMePlugin.txt =================================================================== --- twiki/branches/MAIN/twikiplugins/TagMePlugin/data/TWiki/TagMePlugin.txt 2007-04-30 15:47:52 UTC (rev 13596) +++ twiki/branches/MAIN/twikiplugins/TagMePlugin/data/TWiki/TagMePlugin.txt 2007-04-30 21:00:57 UTC (rev 13597) @@ -268,8 +268,9 @@ | Plugin Author: | TWiki:Main.PeterThoeny ([[http://www.structuredwikis.com/peter.html][blog]]) | | Copyright: | © 2006, Peter@Thoeny.org, [[http://www.structuredwikis.com/][StructuredWikis LLC]] | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | -| Plugin Version: | 18 Apr 2006 (V1.037) | +| Plugin Version: | 30 Apr 2006 (V1.037) | | Change History: | <!-- versions below in reverse order --> | +| 30 Apr 2007: | Arthur Clemens: fixed calculation of sizes in tag cloud; if =mincount= is passed only the shown tags are calculated. | | 18 Apr 2007: | Arthur Clemens: added permissions for rename and delete; added TagMeChangeRequests. | | 17 Apr 2007: | TWiki:Main.CrawfordCurrie for [[http://www.escapestudios.co.uk/][Escape Studios]]: contributed support for incremental refinement of tag searches. | | 12 Apr 2007: | TWiki:Main.CrawfordCurrie contributed ability to search for multiple tags. TWiki:Main.SvenDowideit for [[http://www.escapestudios.co.uk/][Escape Studios]]: added parameters needed for custom search result display. | Modified: twiki/branches/MAIN/twikiplugins/TagMePlugin/lib/TWiki/Plugins/TagMePlugin.pm =================================================================== --- twiki/branches/MAIN/twikiplugins/TagMePlugin/lib/TWiki/Plugins/TagMePlugin.pm 2007-04-30 15:47:52 UTC (rev 13596) +++ twiki/branches/MAIN/twikiplugins/TagMePlugin/lib/TWiki/Plugins/TagMePlugin.pm 2007-04-30 21:00:57 UTC (rev 13597) @@ -479,18 +479,25 @@ . "a topic of interest, and add a tag from the list, or put your " . "vote on an existing tag."; } - my $max = 1; - - my %order = map { ( $_, $max++ ) } - sort { $tagCount{$a} <=> $tagCount{$b} } - keys(%tagCount); + + # calculate the relative sizes + # we need to map size to tag count: + # + # $minSize -- $maxSize + # | | + # smallest count -- largest count + # + my @orderedKeys = sort { $tagCount{$a} <=> $tagCount{$b} } keys(%allTags); + my $smallestCount = $tagCount{$orderedKeys[0]}; + my $largestCount = $tagCount{$orderedKeys[-1]} || $smallestCount; + my $sizeStep = ($maxSize - $minSize) / ($largestCount - $smallestCount); + my $size = 0; my $tmpSep = '_#_'; $text = join( $separator, map { - $size = int( $maxSize * ( $order{$_} + 1 ) / $max ); - $size = $minSize if ( $size < $minSize ); + $size = int( $minSize + $sizeStep * ($tagCount{$_} - $smallestCount) ); $line = $format; $line =~ s/(tag\=)\$tag/$1$tmpSep\$tag$tmpSep/go; $line =~ s/$tmpSep\$tag$tmpSep/&_urlEncode($_)/geo; |