Changes for page Tag Cloud
Last modified by Mark Kohlmann on 2024/07/26 08:06
From version 7.1
edited by Mark Kohlmann
on 2024/07/26 08:06
on 2024/07/26 08:06
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-tag-ui/16.5.0]
To version 6.1
edited by Mark Kohlmann
on 2024/07/26 07:52
on 2024/07/26 07:52
Change comment:
Migrated property [defaultCategories] from class [XWiki.WikiMacroClass]
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 1 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. mark\.kohlmann@chiefintegrations\.com1 +XWiki.MarkKohlmann
- XWiki.WikiMacroClass[0]
-
- Cached
-
... ... @@ -1,1 +1,0 @@ 1 -No - Asynchronous rendering
-
... ... @@ -1,1 +1,0 @@ 1 -No - Macro code
-
... ... @@ -3,10 +3,6 @@ 3 3 ## tagCloudSpace - the space to display the tag cloud for. If blank, display cloud for the whole wiki. Default is blank. 4 4 #set ($tagCloudSpace = $xcontext.macro.params.get('space')) 5 5 #set ($tagCloudSpaces = $xcontext.macro.params.get('spaces')) 6 -#set ($limit = $xcontext.macro.params.get('limit')) 7 -#if ("$!limit" != '' && $limit < 0) 8 - #set ($limit = 0) 9 -#end 10 10 ## 11 11 ## Configurable popularity levels. You must enter an even number of levels. Default: 6. 12 12 #set ($popularityLevels = ["notPopular", "notVeryPopular", "somewhatPopular", "popular", "veryPopular", "ultraPopular"]) ... ... @@ -30,35 +30,22 @@ 30 30 ## Get tag count map. Key: tag, value: number of occurrences. 31 31 #set ($tagCount = $xwiki.tag.getTagCount("$!tagCloudSpace")) 32 32 #end 33 -## Organize tags as a list of {name, count} object so that it is easier to handle (sorting, limiting, ...) 34 -#set ($tagCountList = []) 35 -#foreach ($tagName in $tagCount.keySet()) 36 - #set ($discard = $tagCountList.add({ 37 - "name": $tagName, 38 - "count": $tagCount[$tagName] 39 - })) 40 -#end 41 -## If a limit is set, only keep n most occurring tags 42 -## If tags have the same occurrence, limit them in alphabetical order 43 -#set ($tagCountListSorted = $collectiontool.sort($tagCountList, ['count:desc', 'name'])) 44 -#if ("$!limit" != '') 45 - #set ($tagCountListSorted = $tagCountListSorted.subList(0, $mathtool.min($tagCountListSorted.size(), $limit))) 46 -#end 47 47 ## 48 48 ## Only build popularity map if at least one tag exists 49 -#if ($tagCount ListSorted.size() > 0)31 +#if ($tagCount.size() > 0) 50 50 ## 51 51 ## Store the minimum and maximum number of occurrences. 52 - #set ($maxIndex = $tagCountListSorted.size() - 1) 53 - #set ($maxCount = $tagCountListSorted[0].count) 54 - #set ($minCount = $tagCountListSorted[$maxIndex].count) 34 + #set ($sortedTagCounts = $collectiontool.sort($tagCount.values())) 35 + #set ($maxIndex = $sortedTagCounts.size() - 1) 36 + #set ($minCount = $sortedTagCounts[0]) 37 + #set ($maxCount = $sortedTagCounts[$maxIndex]) 55 55 ## 56 56 ## Calculate the total number of tags in the wiki. 57 57 #set ($totalTagNumber = 0) 58 - #foreach ($currentTag in $tagCount ListSorted)59 - #set ($totalTagNumber = $totalTagNumber + $currentTag .count)41 + #foreach ($currentTagCount in $sortedTagCounts) 42 + #set ($totalTagNumber = $totalTagNumber + $currentTagCount) 60 60 #end 61 - #set ($countAverage = $mathtool.div($totalTagNumber, $tagCount ListSorted.size()))44 + #set ($countAverage = $mathtool.div($totalTagNumber, $tagCount.size())) 62 62 ## 63 63 ## Build popularity map using the difference between minimum / maximum tag occurrences counts, and the average tag occurences count. 64 64 #set ($firstHalfIntervalSize = $mathtool.div($mathtool.sub($countAverage, $minCount), $levelsHalf)) ... ... @@ -85,17 +85,17 @@ 85 85 ## 86 86 ## Display tag cloud. 87 87 {{html}} 88 -#if ($tagCount ListSorted.size() > 0)71 +#if ($tagCount.size() > 0) 89 89 <ol class="tagCloud"> 90 - #foreach ($tagEntry in $ collectiontool.sort($tagCountListSorted, 'name'))73 + #foreach ($tagEntry in $tagCount.entrySet()) 91 91 #foreach ($popularityEntry in $popularityMap.entrySet()) 92 - #if ($popularityEntry.Key >= $tagEntry. count)75 + #if ($popularityEntry.Key >= $tagEntry.Value) 93 93 #set ($liClass = $popularityEntry.Value) 94 94 #break 95 95 #end 96 96 #end 97 97 <li class="$liClass"> 98 - <a class="tag" href="$xwiki.getURL('Main.Tags', 'view', "do=viewTag&tag=$escapetool.url($tagEntry. name)")" title="$services.localization.render('xe.tag.tooltip', [$tagEntry.count])">$escapetool.xml($tagEntry.name)</a>81 + <a class="tag" href="$xwiki.getURL('Main.Tags', 'view', "do=viewTag&tag=$escapetool.url($tagEntry.Key)")" title="$services.localization.render('xe.tag.tooltip', [$tagEntry.Value])">$escapetool.xml($tagEntry.Key)</a> 99 99 </li> 100 100 #end 101 101 </ol> - Default categories
-
... ... @@ -1,1 +1,0 @@ 1 -Content - Default category
-
... ... @@ -1,0 +1,1 @@ 1 +Content
- XWiki.WikiMacroParameterClass[2]
-
- Parameter name
-
... ... @@ -1,1 +1,0 @@ 1 -limit - Parameter description
-
... ... @@ -1,1 +1,0 @@ 1 -Max count of tags to be displayed in the cloud - Parameter type
-
... ... @@ -1,1 +1,0 @@ 1 -java.lang.Integer - Parameter mandatory
-
... ... @@ -1,1 +1,0 @@ 1 -No