This commit is contained in:
Kim Thoenen 2014-02-05 13:19:06 +01:00
parent 2773f9e836
commit 6453e62398
15 changed files with 481 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.log
*.pot
*.pyc
local_settings.py

10
.tx/config Normal file
View File

@ -0,0 +1,10 @@
[main]
host = https://www.transifex.com
[django-cms.djangocms-video]
file_filter = djangocms_video/locale/<lang>/LC_MESSAGES/django.po
source_file = djangocms_video/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

24
LICENSE.txt Normal file
View File

@ -0,0 +1,24 @@
Copyright (c) 2011, Divio AG
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Djeese Factory GmbH nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DJEESE FACTORY GMBH BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

5
MANIFEST.in Normal file
View File

@ -0,0 +1,5 @@
include LICENSE.txt
include README.md
recursive-include djangocms_video/locale *
recursive-include djangocms_video/templates *
recursive-exclude * *.py[co]

View File

@ -0,0 +1 @@
__version__ = '0.0.1'

View File

@ -0,0 +1,58 @@
from django.utils.translation import ugettext_lazy as _
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from . import settings
from forms import VideoForm
from models import Video
class VideoPlugin(CMSPluginBase):
model = Video
name = _("Video")
form = VideoForm
render_template = "cms/plugins/video.html"
general_fields = [
('movie', 'movie_url'),
'image',
('width', 'height'),
'auto_play',
'auto_hide',
'fullscreen',
'loop',
]
color_fields = [
'bgcolor',
'textcolor',
'seekbarcolor',
'seekbarbgcolor',
'loadingbarcolor',
'buttonoutcolor',
'buttonovercolor',
'buttonhighlightcolor',
]
fieldsets = [
(None, {
'fields': general_fields,
}),
]
if settings.VIDEO_PLUGIN_ENABLE_ADVANCED_SETTINGS:
fieldsets += [
(_('Color Settings'), {
'fields': color_fields,
'classes': ('collapse',),
}),
]
def render(self, context, instance, placeholder):
context.update({
'object': instance,
'placeholder': placeholder,
})
return context
plugin_pool.register_plugin(VideoPlugin)

9
djangocms_video/forms.py Normal file
View File

@ -0,0 +1,9 @@
from django import forms
from models import Video
class VideoForm(forms.ModelForm):
class Meta:
model = Video
exclude = ('page', 'position', 'placeholder', 'language',
'plugin_type')

View File

@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Video'
db.create_table(u'djangocms_video_video', (
(u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
('movie', self.gf('django.db.models.fields.files.FileField')(max_length=100, null=True, blank=True)),
('movie_url', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
('image', self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True)),
('width', self.gf('django.db.models.fields.PositiveSmallIntegerField')()),
('height', self.gf('django.db.models.fields.PositiveSmallIntegerField')()),
('auto_play', self.gf('django.db.models.fields.BooleanField')(default=False)),
('auto_hide', self.gf('django.db.models.fields.BooleanField')(default=False)),
('fullscreen', self.gf('django.db.models.fields.BooleanField')(default=True)),
('loop', self.gf('django.db.models.fields.BooleanField')(default=False)),
('bgcolor', self.gf('django.db.models.fields.CharField')(default='000000', max_length=6)),
('textcolor', self.gf('django.db.models.fields.CharField')(default='FFFFFF', max_length=6)),
('seekbarcolor', self.gf('django.db.models.fields.CharField')(default='13ABEC', max_length=6)),
('seekbarbgcolor', self.gf('django.db.models.fields.CharField')(default='333333', max_length=6)),
('loadingbarcolor', self.gf('django.db.models.fields.CharField')(default='828282', max_length=6)),
('buttonoutcolor', self.gf('django.db.models.fields.CharField')(default='333333', max_length=6)),
('buttonovercolor', self.gf('django.db.models.fields.CharField')(default='000000', max_length=6)),
('buttonhighlightcolor', self.gf('django.db.models.fields.CharField')(default='FFFFFF', max_length=6)),
))
db.send_create_signal(u'djangocms_video', ['Video'])
def backwards(self, orm):
# Deleting model 'Video'
db.delete_table(u'djangocms_video_video')
models = {
'cms.cmsplugin': {
'Meta': {'object_name': 'CMSPlugin'},
'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
},
u'djangocms_video.video': {
'Meta': {'object_name': 'Video', '_ormbases': ['cms.CMSPlugin']},
'auto_hide': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'auto_play': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'bgcolor': ('django.db.models.fields.CharField', [], {'default': "'000000'", 'max_length': '6'}),
'buttonhighlightcolor': ('django.db.models.fields.CharField', [], {'default': "'FFFFFF'", 'max_length': '6'}),
'buttonoutcolor': ('django.db.models.fields.CharField', [], {'default': "'333333'", 'max_length': '6'}),
'buttonovercolor': ('django.db.models.fields.CharField', [], {'default': "'000000'", 'max_length': '6'}),
u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'fullscreen': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'height': ('django.db.models.fields.PositiveSmallIntegerField', [], {}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'loadingbarcolor': ('django.db.models.fields.CharField', [], {'default': "'828282'", 'max_length': '6'}),
'loop': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'movie': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'movie_url': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'seekbarbgcolor': ('django.db.models.fields.CharField', [], {'default': "'333333'", 'max_length': '6'}),
'seekbarcolor': ('django.db.models.fields.CharField', [], {'default': "'13ABEC'", 'max_length': '6'}),
'textcolor': ('django.db.models.fields.CharField', [], {'default': "'FFFFFF'", 'max_length': '6'}),
'width': ('django.db.models.fields.PositiveSmallIntegerField', [], {})
}
}
complete_apps = ['djangocms_video']

View File

101
djangocms_video/models.py Normal file
View File

@ -0,0 +1,101 @@
import os
from django.db import models
from django.utils.translation import ugettext_lazy as _
from cms.utils.compat.dj import python_2_unicode_compatible
from cms.models import CMSPlugin
from . import settings
@python_2_unicode_compatible
class Video(CMSPlugin):
# player settings
movie = models.FileField(
_('movie file'), upload_to=CMSPlugin.get_media_path,
help_text=_('use .flv file or h264 encoded video file'), blank=True,
null=True)
movie_url = models.CharField(
_('movie url'), max_length=255,
help_text=_('vimeo or youtube video url. '
'Example: http://www.youtube.com/watch?v=-iJ7bs4mTUY'),
blank=True, null=True)
image = models.ImageField(
_('image'), upload_to=CMSPlugin.get_media_path,
help_text=_('preview image file'), null=True, blank=True)
width = models.PositiveSmallIntegerField(_('width'))
height = models.PositiveSmallIntegerField(_('height'))
auto_play = models.BooleanField(
_('auto play'), default=settings.VIDEO_AUTOPLAY)
auto_hide = models.BooleanField(
_('auto hide'), default=settings.VIDEO_AUTOHIDE)
fullscreen = models.BooleanField(
_('fullscreen'), default=settings.VIDEO_FULLSCREEN)
loop = models.BooleanField(_('loop'), default=settings.VIDEO_LOOP)
# plugin settings
bgcolor = models.CharField(
_('background color'), max_length=6, default=settings.VIDEO_BG_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
textcolor = models.CharField(
_('text color'), max_length=6, default=settings.VIDEO_TEXT_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
seekbarcolor = models.CharField(
_('seekbar color'), max_length=6, default=settings.VIDEO_SEEKBAR_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
seekbarbgcolor = models.CharField(
_('seekbar bg color'), max_length=6,
default=settings.VIDEO_SEEKBARBG_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
loadingbarcolor = models.CharField(
_('loadingbar color'), max_length=6,
default=settings.VIDEO_LOADINGBAR_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
buttonoutcolor = models.CharField(
_('button out color'), max_length=6,
default=settings.VIDEO_BUTTON_OUT_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
buttonovercolor = models.CharField(
_('button over color'), max_length=6,
default=settings.VIDEO_BUTTON_OVER_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
buttonhighlightcolor = models.CharField(
_('button highlight color'), max_length=6,
default=settings.VIDEO_BUTTON_HIGHLIGHT_COLOR,
help_text=_('Hexadecimal, eg ff00cc'))
def __str__(self):
if self.movie:
name = self.movie.path
else:
name = self.movie_url
return u"%s" % os.path.basename(name)
def get_height(self):
return "%s" % self.height
def get_width(self):
return "%s" % self.width
def get_movie(self):
if self.movie:
return self.movie.url
else:
return self.movie_url

View File

@ -0,0 +1,19 @@
from django.conf import settings
VIDEO_AUTOPLAY = getattr(settings, "VIDEO_AUTOPLAY", False)
VIDEO_AUTOHIDE = getattr(settings, "VIDEO_AUTOHIDE", False)
VIDEO_FULLSCREEN = getattr(settings, "VIDEO_FULLSCREEN", True)
VIDEO_LOOP = getattr(settings, "VIDEO_LOOP", False)
VIDEO_AUTOPLAY = getattr(settings, "VIDEO_AUTOPLAY", False)
VIDEO_AUTOPLAY = getattr(settings, "VIDEO_AUTOPLAY", False)
VIDEO_BG_COLOR = getattr(settings, "VIDEO_BG_COLOR", "000000")
VIDEO_TEXT_COLOR = getattr(settings, "VIDEO_TEXT_COLOR", "FFFFFF")
VIDEO_SEEKBAR_COLOR = getattr(settings, "VIDEO_SEEKBAR_COLOR", "13ABEC")
VIDEO_SEEKBARBG_COLOR = getattr(settings, "VIDEO_SEEKBARBG_COLOR", "333333")
VIDEO_LOADINGBAR_COLOR = getattr(settings, "VIDEO_LOADINGBAR_COLOR", "828282")
VIDEO_BUTTON_OUT_COLOR = getattr(settings, "VIDEO_BUTTON_OUT_COLOR", "333333")
VIDEO_BUTTON_OVER_COLOR = getattr(settings, "VIDEO_BUTTON_OVER_COLOR", "000000")
VIDEO_BUTTON_HIGHLIGHT_COLOR = getattr(settings, "VIDEO_BUTTON_HIGHLIGHT_COLOR", "FFFFFF")
VIDEO_PLUGIN_ENABLE_ADVANCED_SETTINGS = getattr(settings, "VIDEO_PLUGIN_ENABLE_ADVANCED_SETTINGS", True)

View File

@ -0,0 +1,69 @@
{% load i18n sekizai_tags cms_js_tags %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/swfobject.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}
<script type="text/javascript">
//<![CDATA[
(function () {
var flashvars = {
'movie': '{{ object.get_movie }}',
{% if object.image %}
'image': '{{ object.image.url }}',
{% endif %}
'autoplay': '{{ object.auto_play|bool }}',
'loop': '{{ object.loop|bool }}',
'autohide': '{{ object.auto_hide|bool }}',
'fullscreen': '{{ object.fullscreen|bool }}',
'color_text': '0x{{ object.textcolor }}',
'color_seekbar': '0x{{ object.seekbarcolor }}',
'color_loadingbar': '0x{{ object.loadingbarcolor }}',
'color_seekbarbg': '0x{{ object.seekbarbgcolor }}',
'color_button_out': '0x{{ object.buttonoutcolor }}',
'color_button_over': '0x{{ object.buttonovercolor }}',
'color_button_highlight': '0x{{ object.buttonhighlightcolor }}'
};
var params = {
allowfullscreen: 'true',
allowscriptaccess: 'always',
bgcolor: '#{{ object.bgcolor }}',
wmode: 'opaque'
};
var attributes = { align: 'middle' };
// load
swfobject.embedSWF('{{ STATIC_URL }}cms/swf/player.swf', 'video-plugin-{{ object.id }}', '{{ object.get_width }}', '{{ object.get_height }}', '9', '{{ STATIC_URL }}cms/swf/expressInstall.swf', flashvars, params, attributes);
})();
//]]>
</script>
{% endaddtoblock %}
<div class="plugin_video">
<object id="video-plugin-{{ object.id }}" width="{{ object.get_width }}" height="{{ object.get_height }}" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >
<param name="movie" value="{{ STATIC_URL }}cms/swf/player.swf"/>
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
<param name="quality" value="autohigh" />
<param name="wmode" value="opaque" />
<param name="bgcolor" value="#{{ object.bgcolor }}" />
<param name="flashvars" value="movie={{ object.get_movie }}&amp;{% if object.image %}image={{ object.image.url }}&amp;{% endif %}autoplay={{ object.auto_play|bool }}&amp;loop={{ object.loop|bool }}&amp;autohide={{ object.auto_hide|bool }}&amp;fullscreen={{ object.fullscreen|bool }}&amp;color_text=0x{{ object.textcolor }}&amp;color_seekbar=0x{{ object.seekbarcolor }}&amp;color_loadingbar=0x{{ object.loadingbarcolor }}&amp;color_seekbarbg=0x{{ object.seekbarbgcolor }}&amp;color_button_out=0x{{ object.buttonoutcolor }}&amp;color_button_over=0x{{ object.buttonovercolor }}&amp;color_button_highlight=0x{{ object.buttonhighlightcolor }}" />
<!--[if !IE]>-->
<object width="{{ object.get_width }}" height="{{ object.get_height }}" data="{{ STATIC_URL }}cms/swf/player.swf" type="application/x-shockwave-flash">
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
<param name="quality" value="autohigh" />
<param name="wmode" value="opaque" />
<param name="bgcolor" value="#{{ object.bgcolor }}" />
<param name="flashvars" value="movie={{ object.get_movie }}&amp;{% if object.image %}image={{ object.image.url }}&amp;{% endif %}autoplay={{ object.auto_play|bool }}&amp;loop={{ object.loop|bool }}&amp;autohide={{ object.auto_hide|bool }}&amp;fullscreen={{ object.fullscreen|bool }}&amp;color_text=0x{{ object.textcolor }}&amp;color_seekbar=0x{{ object.seekbarcolor }}&amp;color_loadingbar=0x{{ object.loadingbarcolor }}&amp;color_seekbarbg=0x{{ object.seekbarbgcolor }}&amp;color_button_out=0x{{ object.buttonoutcolor }}&amp;color_button_over=0x{{ object.buttonovercolor }}&amp;color_button_highlight=0x{{ object.buttonhighlightcolor }}" />
<!--<![endif]-->
<!-- alternate content -->
{% trans "Missing flash plugin. Please download the latest Adobe Flash Player: " %}<br />
<a href="https://www.adobe.com/go/getflashplayer">
<img alt="{% trans 'Get Adobe Flash Player' %}" src="{{ STATIC_URL }}cms/img/icons/plugins/get_flash_player.gif" />
</a>
<!-- /alternate content -->
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
transifex-client

60
schemamigration.py Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'mptt',
'cms',
'menus',
'djangocms_video',
'south',
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
TEMPLATE_CONTEXT_PROCESSORS = [
'django.core.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static',
'cms.context_processors.media',
'sekizai.context_processors.sekizai',
]
ROOT_URLCONF = 'cms.urls'
def schemamigration():
# turn ``schemamigration.py --initial`` into
# ``manage.py schemamigration cmsplugin_disqus --initial`` and setup the
# enviroment
from django.conf import settings
from django.core.management import ManagementUtility
settings.configure(
INSTALLED_APPS=INSTALLED_APPS,
ROOT_URLCONF=ROOT_URLCONF,
DATABASES=DATABASES,
TEMPLATE_CONTEXT_PROCESSORS=TEMPLATE_CONTEXT_PROCESSORS
)
argv = list(sys.argv)
argv.insert(1, 'schemamigration')
argv.insert(2, 'djangocms_video')
utility = ManagementUtility(argv)
utility.execute()
if __name__ == "__main__":
schemamigration()

35
setup.py Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
from djangocms_video import __version__
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Communications',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
]
setup(
name='djangocms-video',
version=__version__,
description='Video plugin for django CMS',
author='Divio AG',
author_email='info@divio.ch',
url='https://github.com/divio/djangocms-video',
packages=['djangocms_video', 'djangocms_video.migrations'],
license='LICENSE.txt',
platforms=['OS Independent'],
classifiers=CLASSIFIERS,
long_description=open('README.md').read(),
include_package_data=True,
zip_safe=False
)