Wiki source code of TwitterMacros

Version 16.1 by Ludovic Dubost on 2009/01/02 17:03

Hide last authors
Ludovic Dubost 1.1 1 #**
2 * Twitter macros allowing to display twitter data
3 *#
4
Ludovic Dubost 14.1 5 #**
6 * Display a list of statuses
7 * @param list list or array of twitter4j status objects
8 * @param nb maximum number of status to display
9 * @param withuser display or not the user name
10 *#
Ludovic Dubost 9.1 11 #macro(twitter_display $list $nb $withuser)
Ludovic Dubost 8.1 12 {pre}
Ludovic Dubost 2.1 13 #foreach($msg in $list)
Ludovic Dubost 9.1 14 #if($velocityCount<$nb)
Ludovic Dubost 12.1 15 <div style="border: 0px; border-bottom:1px dashed #D2DADA;">
Ludovic Dubost 7.1 16 #if($withuser)<a href="$msg.user.URL">$msg.user.name</a>#end $msg.text
Ludovic Dubost 1.1 17 <span style="color: #A2AAAA; font-size: 10px;">$xwiki.formatDate($msg.createdAt) #if($msg.source!="")from $msg.source #end</span>
Ludovic Dubost 12.1 18 </div>
Ludovic Dubost 9.1 19 #end
Ludovic Dubost 13.1 20 #end
Ludovic Dubost 8.1 21 {/pre}
Ludovic Dubost 1.1 22 #end
23
Ludovic Dubost 14.1 24 #**
25 * Twitter display of the last 'n' statuses containing a text
26 * @param text text to search for
27 * @param nb maximum number of status to display
28 *#
Ludovic Dubost 9.1 29 #macro(twitter_search $text $nb)
Ludovic Dubost 4.1 30 #if(!$twitter)
Ludovic Dubost 1.1 31 #set($tg = $xwiki.parseGroovyFromPage("Twitter.TwitterGroovy", "Twitter.TwitterGroovy"))
32 #set($twitter = $tg.getTwitter("xwikiapi", "xwapi2008"))
Ludovic Dubost 4.1 33 #end
Ludovic Dubost 9.1 34 #twitter_display($tg.search($text) $nb true)
Ludovic Dubost 1.1 35 #end
36
Ludovic Dubost 14.1 37 #**
38 * Twitter display of the last 'n' statuses of a user
39 * @param user twitter user id
40 * @param nb maximum number of status to display
41 *#
Ludovic Dubost 9.1 42 #macro(twitter_user $user $nb)
Ludovic Dubost 4.1 43 #if(!$twitter)
Ludovic Dubost 1.1 44 #set($tg = $xwiki.parseGroovyFromPage("Twitter.TwitterGroovy", "Twitter.TwitterGroovy"))
45 #set($twitter = $tg.getTwitter("xwikiapi", "xwapi2008"))
Ludovic Dubost 4.1 46 #end
Ludovic Dubost 9.1 47 #twitter_display($twitter.getUserTimeline($user) $nb false)
Ludovic Dubost 1.1 48 #end
49
Ludovic Dubost 14.1 50 #**
51 * Twitter Badge displaying the last status of a user
52 * @param user twitter user id
53 *#
54 #macro(twitter_badge $user)
55 {pre}
Ludovic Dubost 16.1 56 <div style="width:176px;text-align:center"><embed src="http://twitter.com/flash/twitter_badge.swf" flashvars="color1=3368652&type=user&id=1749071" quality="high" width="176" height="176" name="twitter_badge" align="middle" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br><a style="font-size: 10px; color: #3366CC; text-decoration: none" href="http://twitter.com/$user">follow $user at http://twitter.com</a></div>
Ludovic Dubost 14.1 57 #end
58