Commits

Michael Caron  committed b057801

Initial commit.

  • Participants

Comments (0)

Files changed (4)

+SOBadgeTWMacro
+==============
+
+Stackoverflow Badge Rendering for Trac Wiki.
+
+Ever wanted to show off your Stackoverflow flair on your Trac project's wiki? Now you can easily display it using this Trac macro. Inside your wiki text, simply write
+
+    [[SoBadge(2836)]]
+
+Where 2036 is the userid that you wish to display.
+
+See http://trac.edgewall.org/wiki/TracPlugins for installation instructions.
+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+
+from setuptools import setup
+
+setup(
+    name = 'TracStackOverflowBadge',
+    version = '1.0',
+    packages = ['sobadge'],
+    #package_data = { 'sobadge': ['templates/*.cs', 'htdocs/*.js', 'htdocs/*.css' ] },
+
+    author = 'Michael Caron',
+    author_email = 'mike@cruxus.com',
+    description = 'A Trac wiki macro to display SO badges.',
+    license = 'BSD',
+    keywords = 'trac plugin macro stackoverflow badge',
+    #url = 'http://trac-hacks.org/wiki/OhlohBadgeMacro',
+    classifiers = [
+        'Framework :: Trac',
+    ],
+    
+    install_requires = [],
+
+    entry_points = {
+        'trac.plugins': [
+            'sobadge.macro = sobadge.macro',
+        ]
+    },
+)

File sobadge/__init__.py

Empty file added.

File sobadge/macro.py

+# Created by Michael Caron on 2010-01-20.
+# Copyright (c) 2009 Michael Caron. All rights reserved.
+
+from trac.core import *
+from trac.wiki.macros import WikiMacroBase
+from trac.wiki.formatter import system_message
+from trac.util.html import html as tag
+
+class SoBadgeMacro(WikiMacroBase):
+    """A small maco for showing Stack Overflow (http://stackoverflow.com) statistics badges."""
+    
+    SCRIPT_LOCATION = 'http://stackoverflow.com/users/flair/%s.js'
+    
+    def render_macro(self, req, name, content):
+        content = content.strip()
+        if not content.isdigit():
+            return system_message('Invalid Stackoverflow User', '%s is not a number'%content)
+        return tag.script('', src=self.SCRIPT_LOCATION%content, type='text/javascript')
+
+
+