Hi Thomas,

I didn't see your email below (was it sent to the list?).

I'm all for offering a default tag cloud page/panel.

The notion of tag is not something known to XWiki core. Currently tags are only known at the level of the default wiki so we should probably put the tag cloud code there. As your code below requires some logic, maybe the best is to use Groovy to replace the Java part. You could then have everything located on a single page.

The next question is: a Panel or a Page?

I'm tempted to say both. I think we should include the tag cloud in the Main.Tags page and we could provide a Panel too.

WDYT?

I have created a jira issue for this:
http://jira.xwiki.org/jira/browse/XWIKI-1311

Would you be interested in working on this and finishing this?

If so, could you please attach the result to that JIRA issue for inclusion in SVN?

Thanks a lot
-Vincent

On May 31, 2007, at 1:42 AM, Guillaume Lerouge wrote:

Hi Thomas,
 
this looks quite cool!
 
There is a place on XWiki.org for this kind of contributions (http://www.xwiki.org/xwiki/bin/view/Code/), it would be very cool if you could add it there with a step by step explanation of how to use it (for instance in my case I have no idea where I am supposed to put the Java code - though I'm not actually a developer).
 
Even better would be to export the XAR of your XWiki, customize it to keep only the Main.TagCloud , Panels.TagCloud
(and other pages required to make it work) and then upload it to XWiki.org like it is done for other applications already. To do so easily you can even download first the Packager Application here: http://www.xwiki.org/xwiki/bin/view/Code/PackagerApplication and use it to generate your XAR (which at the same time gives you an example of the page you could create for yours :-)
 
Funny thing is that I was wondering about tag cluds this afternoon but had no idea how to implement one :-) Thanks!
 
Guillaume
 
On 30/05/07, Thomas Drevon <thomas.drevon@intermedia.uio.no> wrote:
Hi!

Tag clouds (http://en.wikipedia.org/wiki/Tag_cloud ) seem so in these
days, so I made a simple implementation using the Main.Tags in xwiki.
The styling isn't too sexy, but that should be easy to configure.

Here is the code for use in a panel or similar place:

#panelheader('Tag cloud')

#set($query = "select elements(prop.list) from BaseObject as obj,
DBStringListProperty as prop where obj.className='XWiki.TagClass' and
obj.id=prop.id.id and prop.id.name='tags'")

#set( $allTags = $xwiki.sort($xwiki.search($query)))

#set( $tagsWithCount = $xwiki.metawiki.getTagsWithCount($allTags))

#set($query = "select distinct elements( prop.list) from BaseObject as
obj, DBStringListProperty as prop where obj.className='XWiki.TagClass'
and obj.id=prop.id.id and prop.id.name='tags'")

#set( $tagsDistinct = $xwiki.sort($xwiki.search($query)))

#foreach($tag in $tagsDistinct)
<span style="#getStyle($tagsWithCount.get($tag))"><a
href="$xwiki.getURL("Main.Tags", "view", "tag=$tag")")>$tag</a></span>
#end

#panelfooter()


#macro( getStyle $count )
  #if ($count < 2) "font-size: 0.80em;"
  #elseif ($count < 3) font-size: 1.00em; }
  #elseif ($count < 4) font-size: 1.20em; }
  #elseif ($count < 5) font-size: 1.40em; }
  #elseif ($count < 6) font-size: 1.60em; }
  #elseif ($count < 7) font-size: 1.80em; }
  #elseif ($count < 8) font-size: 2.00em; }
  #else font-size: 2.50em; }
  #end
#end


And here's the java code invoked:

public static HashMap<String, Integer>
getTagsWithCount(ArrayList<String> allTags) {
  String tag = null;
  String previousTag = null;
  HashMap<String, Integer> tagsWithCount = new HashMap<String, Integer>();
  int count = 1;
  for (int i = 0; i < allTags.size(); i++) {
    previousTag = tag;
    tag = allTags.get(i);
    if ( tag.equals(previousTag)) {
      count++;
    } else {
      count = 1;
      previousTag = null;
    }
    tagsWithCount.put(tag, new Integer(count));
  }
  return tagsWithCount;
}


Is this anything you would want to include in xwiki, or is it too
trivial to bother with? See the attached file for a sample screenshot.



best regards :-)
Thomas Drevon


--
You receive this message as a subscriber of the xwiki-dev@objectweb.org mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto: sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws





--
http://wikibc.blogspot.com/

--
You receive this message as a subscriber of the xwiki-dev@objectweb.org mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws