Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add recommendations macro.

  • Loading branch information...
commit d9d8b4bf09fa009ab965514c1c4b34fcde35c3db 1 parent 173744c
@thijstriemstra authored
Showing with 44 additions and 4 deletions.
  1. +2 −2 doc/conf.py
  2. +41 −1 facebookplugins/__init__.py
  3. +1 −1  setup.py
View
4 doc/conf.py
@@ -47,10 +47,10 @@
time.strftime('%Y'), url, project)
# The full version, including alpha/beta/rc tags.
-version = '0.1a1'
+version = '0.2'
# The short X.Y version.
-release = '0.1'
+release = version
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
View
42 facebookplugins/__init__.py
@@ -16,7 +16,7 @@
from trac.resource import get_resource_url
-__all__ = ['LikeButton', 'ActivityFeed']
+__all__ = ['LikeButton', 'ActivityFeed', 'Recommendations']
class FBWikiMacro(object):
@@ -135,3 +135,43 @@ def expand_macro(self, formatter, name, args):
self.fb_url, self.plugin_name, href, width, height, header, colorscheme, recommendations)
return self.iframe(src, width, height)
+
+
+class Recommendations(ActivityFeed):
+ """
+ The [http://developers.facebook.com/docs/reference/plugins/recommendations Recommendations]
+ plugin shows personalized [http://facebook.com Facebook] recommendations to your users.
+
+ To generate the recommendations, the plugin considers all the social interactions with
+ URLs from your site. For a logged in Facebook user, the plugin will give preference to
+ and highlight objects her friends have interacted with.
+
+ Examples:
+ {{{
+ [[Recommendations]] # current page
+ [[Recommendations(http://python.org)]] # python.org
+ }}}
+ """
+
+ plugin_name = 'recommendations'
+
+ 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.abs_href(formatter)
+ width = '300'
+ height = '300'
+ header = 'true'
+ colorscheme = 'light' # or 'dark'
+
+ if len(options) > 0 and options[0] != "None":
+ href = options[0]
+
+ src = "%s/%s.php?site=%s&width=%s&height=%s&header=%s&colorscheme=%s" % (
+ self.fb_url, self.plugin_name, href, width, height, header, colorscheme)
+
+ return self.iframe(src, width, height)
+
View
2  setup.py
@@ -10,7 +10,7 @@
description='Support for Facebook plugins in Trac.',
url='http://trac-hacks.org/wiki/TracFacebookPluginsMacro',
license='MIT',
- version='0.1a1',
+ version='0.2',
packages=find_packages(exclude=['*.tests*']),
entry_points = """
[trac.plugins]
Please sign in to comment.
Something went wrong with that request. Please try again.