Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Init.

  • Loading branch information...
commit 9cc18883d783cb5f485432355d4b80cdd6ab6cbe 0 parents
@mfitzp authored
10 INSTALL.txt
@@ -0,0 +1,10 @@
+Thanks for downloading django-flowplayer.
+
+To install it, run the following command inside this directory:
+
+ python setup.py install
+
+Or if you'd prefer you can simply place the included ``flowplayer``
+directory somewhere on your Python path, or symlink to it from
+somewhere on your Python path; this is useful if you're working from a
+Subversion checkout.
24 LICENSE.txt
@@ -0,0 +1,24 @@
+Django Flowplayer
+--------------
+
+Copyright (c) 2007, Martin Fitzpatrick
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Initially based on code from Gilang Chandrasa django-videoplayer:
+http://code.google.com/p/django-videoplayer/
10 README.txt
@@ -0,0 +1,10 @@
+=================
+Django Flowplayer
+=================
+
+This is a mediaplayer app for Django projects using the flowplayer flash player
+
+For installation instructions, see the file "INSTALL.txt" in this
+directory; for instructions on how to use this application, and on
+what it provides, see the file "overview.txt" in the "docs/"
+directory.
123 docs/overview.txt
@@ -0,0 +1,123 @@
+=================
+Django Flowplayer
+=================
+
+A mediaplayer application for `Django`_ projects using the flowplayer flash player
+to display media files of different types on your site. Originally based on the
+django-videoplayer application this has support for display of audio-specific players
+with the aim being to allow complete control of the flowplayer instances via Django.
+
+.. _`Django`: http://www.djangoproject.com
+
+.. contents::
+ :depth: 3
+
+
+Installation
+============
+
+Installing an official release
+------------------------------
+
+Official releases are made available from
+http://github.com/mfitzp/django-flowplayer
+
+Source distribution
+~~~~~~~~~~~~~~~~~~~
+
+Download the .zip distribution file and unpack it. Inside is a script
+named ``setup.py``. Enter this command::
+
+ python setup.py install
+
+...and the package will install automatically.
+
+Alternatively just copy the ``flowplayer`` directory into your path.
+
+Installing the development version
+----------------------------------
+
+To get the development version for development you can git clone from the public url:
+
+ git clone git://github.com/mfitzp/django-flowplayer.git
+
+Add the resulting folder to your `PYTHONPATH`_ or symlink (`junction`_,
+if you're on Windows) the ``flowplayer`` directory inside it into a
+directory which is on your PYTHONPATH, such as your Python
+installation's ``site-packages`` directory.
+
+You can verify that the application is available on your PYTHONPATH by
+opening a Python interpreter and entering the following commands::
+
+ >>> import flowplayer
+ >>> flowplayer.VERSION
+ (0, 3, 'pre')
+
+.. caution::
+
+ The development version may contain bugs which are not present in the
+ release version and introduce backwards-incompatible changes.
+
+.. _`PYTHONPATH`: http://www.python.org/doc/2.5.2/tut/node8.html#SECTION008120000000000000000
+.. _`junction`: http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx
+
+Using Django Flowplayer in your applications
+-----------------------------------------
+
+Once you've installed Django Flowplayer and want to use it in your Django
+applications, do the following:
+
+ 1. Put ``'flowplayer'`` in your ``INSTALLED_APPS`` setting.
+ 2. Download the latest version of flowplayer from flowplayer.org
+ 3. Streaming audio? Download http://flowplayer.org/plugins/streaming/audio.html
+ 4. Unpack the files and pull all of them in a directory in your media path (e.g. /media/flowplayer)
+ 5. Add a script tag to your template head, pointing at the .js file (in /media/flowplayer)
+ 6. In your settings.py set the correct value for FLOWPLAYER_URL
+ 7. Add the css ( /media/css/example.css ) to your site css or roll your own
+ 8. Load the tags into a template and try it out!
+
+That's it!
+
+
+Settings
+========
+
+Some of the application's behaviour can be configured by adding the
+appropriate settings to your project's settings file.
+
+The following settings are available:
+
+FLOWPLAYER_URL
+--------------
+
+The url to the flowplayer flash file (and -controls and audio plugins).
+
+
+Template tags
+=============
+
+The ``flowplayer.templatetags.flowplayer_tags`` module defines the
+(only!) flowplayer tag for displaying a mediaplayer instance.
+
+Tag reference
+-------------
+
+flowplayer
+~~~~~~~~~~
+
+Outputs a flowplayer mediaplayer instance for a given url, with an optional
+'classtype' parameter for specifying audio player display. When provided
+classtype is used to add an additional CSS class to the player, in the form
+flowplayer<classtype>, allowing for specific layouts for given mediatypes.
+
+See example.css in the media/css folder for a demonstration.
+
+Usage::
+
+ {% flowplayer url classtype %}
+
+Examples::
+
+ {% flowplayer object.url %}
+ {% flowplayer http://example.com/video.flv %}
+ {% flowplayer http://example.com/audio.mp3 audio %}
0  flowplayer/__init__.py
No changes.
15 flowplayer/media/css/example.css
@@ -0,0 +1,15 @@
+
+
+
+.flowplayer {
+ display: block;
+ width: 520px;
+ height: 330px;
+}
+
+.flowplayeraudio {
+ display: block;
+ width: 520px;
+ height: 24px;
+}
+
3  flowplayer/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
10 flowplayer/templates/flowplayer/flowplayer.html
@@ -0,0 +1,10 @@
+ <a
+ href="{{ media_url }}"
+ class="flowplayer{% if player_class %} flowplayer{{ player_class }}{% endif %}"
+ id="flowplayer{{ player_id }}">
+ </a>
+
+ <!-- this will install flowplayer inside previous A- tag. -->
+ <script>
+ flowplayer("flowplayer{{ player_id }}", "{{ player_url }}");
+ </script>
0  flowplayer/templatetags/__init__.py
No changes.
91 flowplayer/templatetags/flowplayer_tags.py
@@ -0,0 +1,91 @@
+from django.conf import settings
+from django.template import TemplateSyntaxError, VariableDoesNotExist, Node
+from django.template import Library, Variable, loader, Context
+
+# ID of current flowplayer being rendered (global to ensure unique)
+FLOWPLAYER_ITERATOR =0
+
+register = Library()
+
+class FlowPlayerNode(Node):
+ "Renderer class for the flowplayer template tag."
+
+ def __init__(self, media_url, player_class):
+ """
+ Constructor.
+
+ Parameters:
+
+ file_url
+ Video url.
+ player_url
+ Flowplayer url.
+ """
+ self.player_class = player_class
+ self.media_url = Variable(media_url)
+
+ global FLOWPLAYER_ITERATOR
+ FLOWPLAYER_ITERATOR += 1
+ self.player_id = FLOWPLAYER_ITERATOR
+
+ if settings.FLOWPLAYER_URL:
+ self.player_url = settings.FLOWPLAYER_URL
+ else:
+ self.player_url = "%sflowplayer/FlowPlayerLight.swf" % (settings.MEDIA_URL)
+
+ def render(self, context):
+
+ try:
+ media_url = self.media_url.resolve(context)
+ except VariableDoesNotExist:
+ media_url = self.media_url
+
+ t = loader.get_template('flowplayer/flowplayer.html')
+ code_context = Context(
+ {"player_url": self.player_url,
+ "player_id": self.player_id,
+ "player_class": self.player_class,
+ "media_url": media_url,
+ }, 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>
+ code block.
+
+ Usage::
+
+ {% flowplayer media_url %}
+
+ Example::
+
+ {% 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."
+
+ if len(args) == 3:
+ player_class = args[2]
+ else:
+ player_class = None
+
+ media_url = args[1]
+
+ return FlowPlayerNode(media_url, player_class)
+
+
+# register the tag
+register.tag('flowplayer', do_flowplayer)
+
1  flowplayer/views.py
@@ -0,0 +1 @@
+# Create your views here.
72 setup.py
@@ -0,0 +1,72 @@
+"""
+Based entirely on Django's own ``setup.py``.
+"""
+import os
+from distutils.command.install import INSTALL_SCHEMES
+from distutils.core import setup
+
+def fullsplit(path, result=None):
+ """
+ Split a pathname into components (the opposite of os.path.join) in a
+ platform-neutral way.
+ """
+ if result is None:
+ result = []
+ head, tail = os.path.split(path)
+ if head == '':
+ return [tail] + result
+ if head == path:
+ return result
+ return fullsplit(head, [tail] + result)
+
+# Tell distutils to put the data_files in platform-specific installation
+# locations. See here for an explanation:
+# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
+for scheme in INSTALL_SCHEMES.values():
+ scheme['data'] = scheme['purelib']
+
+# Compile the list of packages available, because distutils doesn't have
+# an easy way to do this.
+packages, data_files = [], []
+root_dir = os.path.dirname(__file__)
+flowplayer_dir = os.path.join(root_dir, 'flowplayer')
+pieces = fullsplit(root_dir)
+if pieces[-1] == '':
+ len_root_dir = len(pieces) - 1
+else:
+ len_root_dir = len(pieces)
+
+for dirpath, dirnames, filenames in os.walk(flowplayer_dir):
+ # Ignore dirnames that start with '.'
+ for i, dirname in enumerate(dirnames):
+ if dirname.startswith('.'): del dirnames[i]
+ if '__init__.py' in filenames:
+ packages.append('.'.join(fullsplit(dirpath)[len_root_dir:]))
+ elif filenames:
+ data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
+
+# Dynamically calculate the version based on flowplayer.VERSION
+version_tuple = (0, 3, None)
+if version_tuple[2] is not None:
+ version = "%d.%d_%s" % version_tuple
+else:
+ version = "%d.%d" % version_tuple[:2]
+
+setup(
+ name = 'django-flowplayer',
+ version = version,
+ description = 'Mediaplayer application for Django based on flowplayer flash player',
+ author = 'Martin Fitzpatrick',
+ author_email = 'martin.fitzpatrick@gmail.com',
+ url = 'http://github.com/mfitzp/django-flowplayer',
+ packages = packages,
+ data_files = data_files,
+ classifiers = ['Development Status :: 4 - Beta',
+ 'Environment :: Web Environment',
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Utilities'],
+)
Please sign in to comment.
Something went wrong with that request. Please try again.