From 6453e62398140be64116ab2c787a433875d1d144 Mon Sep 17 00:00:00 2001 From: Kim Thoenen Date: Wed, 5 Feb 2014 13:19:06 +0100 Subject: [PATCH] moved out of the cms at divio/django-cms@108b07bcc756840a7ef62d254ce82ee9be564878 --- .gitignore | 4 + .tx/config | 10 ++ LICENSE.txt | 24 +++++ MANIFEST.in | 5 + djangocms_video/__init__.py | 1 + djangocms_video/cms_plugins.py | 58 ++++++++++ djangocms_video/forms.py | 9 ++ djangocms_video/migrations/0001_initial.py | 85 +++++++++++++++ djangocms_video/migrations/__init__.py | 0 djangocms_video/models.py | 101 ++++++++++++++++++ djangocms_video/settings.py | 19 ++++ .../templates/cms/plugins/video.html | 69 ++++++++++++ requirements.txt | 1 + schemamigration.py | 60 +++++++++++ setup.py | 35 ++++++ 15 files changed, 481 insertions(+) create mode 100644 .gitignore create mode 100644 .tx/config create mode 100644 LICENSE.txt create mode 100644 MANIFEST.in create mode 100644 djangocms_video/__init__.py create mode 100644 djangocms_video/cms_plugins.py create mode 100644 djangocms_video/forms.py create mode 100644 djangocms_video/migrations/0001_initial.py create mode 100644 djangocms_video/migrations/__init__.py create mode 100644 djangocms_video/models.py create mode 100644 djangocms_video/settings.py create mode 100644 djangocms_video/templates/cms/plugins/video.html create mode 100644 requirements.txt create mode 100644 schemamigration.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9437c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.log +*.pot +*.pyc +local_settings.py diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..f275800 --- /dev/null +++ b/.tx/config @@ -0,0 +1,10 @@ + +[main] +host = https://www.transifex.com + +[django-cms.djangocms-video] +file_filter = djangocms_video/locale//LC_MESSAGES/django.po +source_file = djangocms_video/locale/en/LC_MESSAGES/django.po +source_lang = en +type = PO + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..1d72bfb --- /dev/null +++ b/LICENSE.txt @@ -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. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..2618a45 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include LICENSE.txt +include README.md +recursive-include djangocms_video/locale * +recursive-include djangocms_video/templates * +recursive-exclude * *.py[co] diff --git a/djangocms_video/__init__.py b/djangocms_video/__init__.py new file mode 100644 index 0000000..b8023d8 --- /dev/null +++ b/djangocms_video/__init__.py @@ -0,0 +1 @@ +__version__ = '0.0.1' diff --git a/djangocms_video/cms_plugins.py b/djangocms_video/cms_plugins.py new file mode 100644 index 0000000..3e97ebd --- /dev/null +++ b/djangocms_video/cms_plugins.py @@ -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) \ No newline at end of file diff --git a/djangocms_video/forms.py b/djangocms_video/forms.py new file mode 100644 index 0000000..f7f8002 --- /dev/null +++ b/djangocms_video/forms.py @@ -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') \ No newline at end of file diff --git a/djangocms_video/migrations/0001_initial.py b/djangocms_video/migrations/0001_initial.py new file mode 100644 index 0000000..6e7fa40 --- /dev/null +++ b/djangocms_video/migrations/0001_initial.py @@ -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'] \ No newline at end of file diff --git a/djangocms_video/migrations/__init__.py b/djangocms_video/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djangocms_video/models.py b/djangocms_video/models.py new file mode 100644 index 0000000..a80753c --- /dev/null +++ b/djangocms_video/models.py @@ -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 + diff --git a/djangocms_video/settings.py b/djangocms_video/settings.py new file mode 100644 index 0000000..a941663 --- /dev/null +++ b/djangocms_video/settings.py @@ -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) diff --git a/djangocms_video/templates/cms/plugins/video.html b/djangocms_video/templates/cms/plugins/video.html new file mode 100644 index 0000000..a118f4c --- /dev/null +++ b/djangocms_video/templates/cms/plugins/video.html @@ -0,0 +1,69 @@ +{% load i18n sekizai_tags cms_js_tags %} +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %} + +{% endaddtoblock %} + +
+ + + + + + + + + + + + + + + + + + + + + {% trans "Missing flash plugin. Please download the latest Adobe Flash Player: " %}
+ + {% trans 'Get Adobe Flash Player' %} + + + +
+ +
+
diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a184fd4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +transifex-client \ No newline at end of file diff --git a/schemamigration.py b/schemamigration.py new file mode 100644 index 0000000..6badab6 --- /dev/null +++ b/schemamigration.py @@ -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() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..5610672 --- /dev/null +++ b/setup.py @@ -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 +)