Permalink
Browse files

Working release for cmsplugin-vimeo

This version has been tested with the latest stable version of Django
CMS.
  • Loading branch information...
1 parent 0c3b9c6 commit f23b3e17f1928e575cc834d3a46b23a4c0e4d61b @facconi facconi committed Sep 19, 2012
Showing with 160 additions and 1 deletion.
  1. +6 −0 .gitignore
  2. +4 −1 README.md
  3. +13 −0 __init__.py
  4. +20 −0 cms_plugins.py
  5. +62 −0 migrations/0001_initial.py
  6. 0 migrations/__init__.py
  7. +27 −0 models.py
  8. +19 −0 settings.py
  9. +9 −0 templates/cmsplugin_vimeo/embed.html
View
@@ -25,3 +25,9 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
+
+#PyCharm
+.idea
+
+#Mac Os X
+.DS_Store
View
@@ -1,4 +1,7 @@
cmsplugin_vimeo
===============
-Plugin for Django CMS that makes easy to embed Vimeo movies.
+Plugin for Django CMS that makes easy to embed Vimeo movies.
+
+This plugin derives from [cmsplugin-youtube](https://bitbucket.org/xenofox/cmsplugin-youtube) and has been customized for Vimeo movies.
+
View
@@ -0,0 +1,13 @@
+VERSION = (0,1,0,'final',1)
+__version__ = '.'.join(map(str, VERSION))
+
+def get_version():
+ version = '%s.%s' % (VERSION[0], VERSION[1])
+ if VERSION[2]:
+ version = '%s.%s' % (version, VERSION[2])
+ if VERSION[3:] == ('alpha', 0):
+ version = '%s pre-alpha' % version
+ else:
+ if VERSION[3] != 'final':
+ version = '%s %s %s' % (version, VERSION[3], VERSION[4])
+ return version
View
@@ -0,0 +1,20 @@
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+
+from cmsplugin_vimeo.models import Vimeo as VimeoModel
+
+from django.utils.translation import ugettext as _
+
+class VimeoPlugin(CMSPluginBase):
+ model = VimeoModel
+ name = _("Vimeo")
+ render_template = "cmsplugin_vimeo/embed.html"
+
+ def render(self, context, instance, placeholder):
+ context.update({
+ 'object': instance,
+ 'placeholder': placeholder
+ })
+ return context
+
+plugin_pool.register_plugin(VimeoPlugin)
View
@@ -0,0 +1,62 @@
+# -*- 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 'Vimeo'
+ db.create_table('cmsplugin_vimeo', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('video_id', self.gf('django.db.models.fields.CharField')(max_length=60)),
+ ('autoplay', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('width', self.gf('django.db.models.fields.IntegerField')(default=510)),
+ ('height', self.gf('django.db.models.fields.IntegerField')(default=300)),
+ ('border', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('loop', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ))
+ db.send_create_signal('cmsplugin_vimeo', ['Vimeo'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'Vimeo'
+ db.delete_table('cmsplugin_vimeo')
+
+
+ models = {
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ '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'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'cmsplugin_vimeo.vimeo': {
+ 'Meta': {'object_name': 'Vimeo', 'db_table': "'cmsplugin_vimeo'", '_ormbases': ['cms.CMSPlugin']},
+ 'autoplay': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'border': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'height': ('django.db.models.fields.IntegerField', [], {'default': '300'}),
+ 'loop': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'video_id': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+ 'width': ('django.db.models.fields.IntegerField', [], {'default': '510'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_vimeo']
View
No changes.
View
@@ -0,0 +1,27 @@
+from django.db import models
+from django.utils.translation import ugettext as _
+
+from cms.models import CMSPlugin
+
+from cmsplugin_vimeo import settings
+
+class Vimeo(CMSPlugin):
+ video_id = models.CharField(_('video id'), max_length=60)
+
+ autoplay = models.BooleanField(
+ _('autoplay'),
+ default=settings.CMS_VIMEO_DEFAULT_AUTOPLAY
+ )
+
+ width = models.IntegerField(_('width'),
+ default=settings.CMS_VIMEO_DEFAULT_WIDTH)
+ height = models.IntegerField(_('height'),
+ default=settings.CMS_VIMEO_DEFAULT_HEIGHT)
+ border = models.BooleanField(_('border'),
+ default=settings.CMS_VIMEO_DEFAULT_BORDER)
+
+ loop = models.BooleanField(_('loop'),
+ default=settings.CMS_VIMEO_DEFAULT_LOOP)
+
+ def __unicode__(self):
+ return u'%s' % (self.video_id,)
View
@@ -0,0 +1,19 @@
+"""
+Convenience module for access of custom youtube application settings,
+which enforces default settings when the main settings module does not
+contain the appropriate settings.
+"""
+from django.conf import settings
+
+# Autoplay
+CMS_VIMEO_DEFAULT_AUTOPLAY = getattr(settings, 'CMS_VIMEO_DEFAULT_AUTOPLAY', False)
+
+# Width & Height
+CMS_VIMEO_DEFAULT_WIDTH = getattr(settings, 'CMS_VIMEO_DEFAULT_WIDTH', 425)
+CMS_VIMEO_DEFAULT_HEIGHT = getattr(settings, 'CMS_VIMEO_DEFAULT_HEIGHT', 344)
+
+# Border
+CMS_VIMEO_DEFAULT_BORDER = getattr(settings, 'CMS_VIMEO_DEFAULT_BORDER', False)
+
+# Loop
+CMS_VIMEO_DEFAULT_LOOP = getattr(settings, 'CMS_VIMEO_DEFAULT_LOOP', False)
@@ -0,0 +1,9 @@
+<div class='vimeo' style='width: {{ object.width }}px; height: {{ object.height }}px;'>
+ <iframe src="http://player.vimeo.com/video/{{ object.video_id }}?autoplay={{ object.autoplay|yesno:"1,0" }}&amp;loop={{ object.loop|yesno:"1,0" }}"
+ width="{{ object.width }}" height="{{ object.height }}"
+ frameborder="{{ object.border|yesno:"1,0" }}"
+ webkitAllowFullScreen
+ mozallowfullscreen
+ allowFullScreen>
+ </iframe>
+</div>

0 comments on commit f23b3e1

Please sign in to comment.