Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pep8 rules

  • Loading branch information...
commit 00d393a8310b8bca436a004a98233aed4cb13fdb 1 parent 4a905b3
@TigorC authored
Showing with 23 additions and 22 deletions.
  1. +23 −22 flowplayer/templatetags/flowplayer_tags.py
View
45 flowplayer/templatetags/flowplayer_tags.py
@@ -1,6 +1,6 @@
from django.conf import settings
from django.db.models.query import QuerySet
-from django.template import TemplateSyntaxError, VariableDoesNotExist, Node
+from django.template import Node, TemplateSyntaxError
from django.template import Library, Variable, loader, Context
# ID of current flowplayer being rendered (global to ensure unique)
@@ -8,9 +8,10 @@
register = Library()
+
class FlowPlayerNode(Node):
"Renderer class for the flowplayer template tag."
-
+
def __init__(self, media, player_class, player_id=None):
"""
Constructor.
@@ -49,13 +50,13 @@ def render(self, context):
else:
context['flowplayer_iterator'] = 0
- try:
+ try:
# Try resolve this variable in the template context
- self.media_element = self.media.resolve(context)
+ self.media_element = self.media.resolve(context)
except:
# Cannot resolve, therefore treat as url string
self.media_element = self.media
-
+
try:
self.extra_id = self.player_id.resolve(context)
except:
@@ -73,18 +74,19 @@ def render(self, context):
else:
self.media_url = self.media_element
self.media_playlist = False
-
+
t = loader.get_template('flowplayer/flowplayer.html')
code_context = Context(
{"player_url": self.player_url,
- "player_id": '%s%s' % (context['flowplayer_iterator'],self.extra_id),
+ "player_id": '%s%s' % (context['flowplayer_iterator'], self.extra_id),
"player_class": self.player_class,
"player_config": self.player_config,
"media_url": self.media_url,
- "media_playlist":self.media_playlist
+ "media_playlist": self.media_playlist
}, autoescape=context.autoescape)
return t.render(code_context)
+
def do_flowplayer(parser, token):
"""
This will insert an flash-based flv videoplayer (flowplayer) in form of an <object>
@@ -95,28 +97,28 @@ def do_flowplayer(parser, token):
{% flowplayer media_url %}
Example::
-
- {% flowplayer video.flv %}
-
- By default, 'flowplayer' tag will use FlowPlayerLight.swf found at
+
+ {% flowplayer video.flv %}
+
+ By default, 'flowplayer' tag will use FlowPlayerLight.swf found at
``{{ MEDIA_URL }}flowplayer/FlowPlayerLight.swf``.
-
+
To change this add FLOWPLAYER_URL to your settings.py file
Pass a dict of urls to the player to get a playlisted player instance
-
- """
-
+
+ """
+
args = token.split_contents()
-
+
if len(args) < 2:
- raise TemplateSyntaxError, "'flowplayer' tag requires at least one argument."
-
+ raise TemplateSyntaxError("'flowplayer' tag requires at least one argument.")
+
if len(args) == 3:
player_class = args[2]
else:
player_class = None
-
+
if len(args) == 4:
player_id = args[3]
else:
@@ -127,6 +129,5 @@ def do_flowplayer(parser, token):
return FlowPlayerNode(media, player_class, player_id)
-# register the tag
+# register the tag
register.tag('flowplayer', do_flowplayer)
-
Please sign in to comment.
Something went wrong with that request. Please try again.