Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add wiki macro for the Like button.

  • Loading branch information...
commit 9b48cb18980ae2e55ce02a84576f65f0bd8a27bb 0 parents
@thijstriemstra authored
Showing with 59 additions and 0 deletions.
  1. +59 −0 FacebookPlugins.py
59 FacebookPlugins.py
@@ -0,0 +1,59 @@
+"""
+@note: enable X
+"""
+
+from trac.core import Component
+from trac.wiki.macros import WikiMacroBase
+
+
+class FacebookPlugins(Component):
+ """
+ Support for Facebook plugins.
+ """
+
+ revision = "$Rev$"
+ url = "$URL$"
+
+
+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.
+
+ 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
+ }}}
+ """
+
+ 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
+ """
+ options = unicode(args).split(",")
+ href = self.url
+ layout = 'standard' # options: 'button_count', 'box_count'
+ show_faces = 'true'
+ width = '450'
+ height = '80'
+ colorscheme = 'light' # or 'dark'
+ action = 'like' # or 'recommend'
+
+ if len(options) > 0:
+ href = options[0]
+
+ if len(options) > 1:
+ layout = options[1] + "_count"
+
+ iframe_code = '<iframe src="http://www.facebook.com/plugins/like.php?href=%s&layout=%s&show_faces=%s&width=%s&action=%s&colorscheme=%s&height=%s" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:%spx; height:%spx;" allowTransparency="true"></iframe>' % (
+ href, layout, show_faces, width, action, colorscheme, height, width, height)
+
+ return iframe_code
Please sign in to comment.
Something went wrong with that request. Please try again.