Skip to content

Commit

Permalink
Add activity feed plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Sep 19, 2010
1 parent 9b48cb1 commit 1080e9f
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions FacebookPlugins.py
@@ -1,5 +1,5 @@
"""
@note: enable X
@note: also support XFBML?
"""

from trac.core import Component
Expand All @@ -18,23 +18,23 @@ 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
}}}
"""

revision = "$Rev$"
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
"""
Expand All @@ -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 = '<iframe src="http://www.facebook.com/plugins/activity.php?site=%s&width=%s&height=%s&header=%s&colorscheme=%s&recommendations=%s" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:%spx; height:%spx;" allowTransparency="true"></iframe>' % (
href, width, height, header, colorscheme, recommendations, width, height)

return iframe_code

0 comments on commit 1080e9f

Please sign in to comment.