Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
doki_pen committed Jan 19, 2010
0 parents commit f586d76
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.pyc
*.egg-info
build
dist
29 changes: 29 additions & 0 deletions setup.py
@@ -0,0 +1,29 @@
#!/usr/bin/env python
"""
License: BSD
(c) 2009 ::: Robert Corsaro (doki_pen@doki-pen.org)
"""

from setuptools import setup, find_packages

setup(
name='TracXspfPlugin',
version='0.11',
license='BSD',
author='Robert Corsaro',
author_email='doki_pen@doki-pen.org',
url='http://github.com/dokipen',
description='Xspf flash mp3 player macros',
zip_safe=True,
packages=['tracxspf'],
package_data={
'tracxspf': ['templates/*.html', 'htdocs/*.swf']
},
entry_points={
'trac.plugins': [
'tracxspf.macros = tracxspf.macros',
'tracxspf.web_ui = tracxspf.web_ui',
]
},
)
Empty file added tracxspf/__init__.py
Empty file.
Binary file added tracxspf/htdocs/button_player.swf
Binary file not shown.
Binary file added tracxspf/htdocs/slim_player.swf
Binary file not shown.
25 changes: 25 additions & 0 deletions tracxspf/macros.py
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from trac.core import *

from trac.web.chrome import Chrome
from trac.wiki.api import parse_args
from trac.wiki.macros import WikiMacroBase
from trac.util.html import escape

class XspfButtonMacro(WikiMacroBase):
def expand_macro(self, formatter, name, content):
_, kw = parse_args(content)
song_url = "/raw-attachment/wiki"\
"/%s/%s"%(formatter.resource.id, kw.get('attachment'))
name = kw.get('name', 'Unknown')
artist = kw.get('artist', 'Unknown')
song_title = escape("%s - %s"%(name, artist))
data = Chrome(self.env).populate_data(formatter.req, {
'song_url': song_url,
'song_title': song_title,
'name': name,
'artist': artist
});
return Chrome(self.env).load_template('xspf.html').\
generate(**data)

9 changes: 9 additions & 0 deletions tracxspf/templates/xspf.html
@@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:strip="True">
<a href="${song_url}"><b>${name}</b></a> - <em>${artist}</em> <a href="${song_url}"><img src="${href('chrome', 'common', 'download.png')}"/></a><br/>
<object width="400" height="20" data="${href('chrome', 'tracxspf', 'slim_player.swf')}?song_url=${song_url}&amp;song_title=${song_title}" type="application/x-shockwave-flash">
<param name="player_title" value="Xspf : ${song_title}" />
<param name="movie" value="${href('chrome', 'tracxspf', 'slim_player.swf')}?song_url=${song_url}&amp;song_title=${song_title}" />
</object>
</html>
13 changes: 13 additions & 0 deletions tracxspf/web_ui.py
@@ -0,0 +1,13 @@
from trac.core import *
from trac.web.chrome import ITemplateProvider

class XspfView(Component):
implements(ITemplateProvider)

def get_templates_dirs(self):
from pkg_resources import resource_filename
return [resource_filename(__name__, 'templates')]

def get_htdocs_dirs(self):
from pkg_resources import resource_filename
return [('tracxspf', resource_filename(__name__, 'htdocs'))]

0 comments on commit f586d76

Please sign in to comment.