From 1080e9fd3aa41b46964fa49dac06130a3abd8d44 Mon Sep 17 00:00:00 2001 From: Thijs Triemstra Date: Mon, 20 Sep 2010 01:49:15 +0200 Subject: [PATCH] Add activity feed plugin. --- FacebookPlugins.py | 56 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/FacebookPlugins.py b/FacebookPlugins.py index 174fb6e..06e797b 100644 --- a/FacebookPlugins.py +++ b/FacebookPlugins.py @@ -1,5 +1,5 @@ """ -@note: enable X +@note: also support XFBML? """ from trac.core import Component @@ -18,14 +18,15 @@ class FacebookPlugins(Component): class LikeButton(WikiMacroBase): """ The [http://developers.facebook.com/docs/reference/plugins/like Like button] lets - users share pages from your site back to their Facebook profile with one click. + users share pages from your site back to their [http://facebook.com Facebook] + profile with one click. Examples: {{{ [[LikeButton]] # current page - [[LikeButton(http://google.nl)]] # google.nl with default layout - [[LikeButton(http://google.com,button)]] # google.com with button layout - [[LikeButton(http://google.com,box)]] # google.com with box layout + [[LikeButton(http://google.com)]] # google.com with default layout + [[LikeButton(http://google.com,button)]] # button layout + [[LikeButton(http://google.com,box)]] # box layout }}} """ @@ -33,8 +34,7 @@ class LikeButton(WikiMacroBase): url = "$URL$" def expand_macro(self, formatter, name, args): - """Description here. - + """ @param name: the actual name of the macro @param args: text enclosed in parenthesis at the call of the macro """ @@ -57,3 +57,45 @@ def expand_macro(self, formatter, name, args): href, layout, show_faces, width, action, colorscheme, height, width, height) return iframe_code + + +class ActivityFeed(WikiMacroBase): + """ + The [http://developers.facebook.com/docs/reference/plugins/activity Activity Feed] + plugins displays the most interesting recent [http://facebook.com Facebook] activity + taking place on your site. + + Examples: + {{{ + [[ActivityFeed]] # current page + [[ActivityFeed(http://google.com)]] # google.com with recommendations + [[ActivityFeed(http://google.com,false)]] # without recommendations + }}} + """ + + revision = "$Rev$" + url = "$URL$" + + def expand_macro(self, formatter, name, args): + """ + @param name: the actual name of the macro + @param args: text enclosed in parenthesis at the call of the macro + """ + options = unicode(args).split(",") + href = self.url + width = '300' + height = '300' + header = 'true' + colorscheme = 'light' # or 'dark' + recommendations = 'true' + + if len(options) > 0: + href = options[0] + + if len(options) > 1: + recommendations = 'false' + + iframe_code = '' % ( + href, width, height, header, colorscheme, recommendations, width, height) + + return iframe_code