Donald Stufft avatar Donald Stufft committed 2fd35cb

brought in initial files

Comments (0)

Files changed (5)

cmsplugin_youtube/__init__.py

+VERSION = (0,1,1,'alpha')
+__version__ = '.'.join(map(str, VERSION))

cmsplugin_youtube/cms_plugins.py

+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+
+from cmsplugin_youtube.models import YouTube as YouTubeModel
+
+from django.utils.translation import ugettext as _
+
+class YouTube(CMSPluginBase):
+    model = YouTubeModel
+    name = _("YouTube")
+    render_template = "cmsplugin_youtube/embed.html"
+
+    def render(self, context, instance, placeholder):
+        context.update({
+            'object': instance,
+            'placeholder': placeholder
+        })
+        return context
+
+plugin_pool.register_plugin(YouTube)

cmsplugin_youtube/models.py

+from django.db import models
+from django.utils.translation import ugettext as _
+
+from cms.models import CMSPlugin
+
+from cmsplugin_youtube import settings
+
+class YouTube(CMSPlugin):
+    video_id = models.CharField(_('video id'), max_length=60)
+
+    autoplay = models.BooleanField(
+        _('autoplay'),
+        default=settings.CMS_YOUTUBE_DEFAULT_AUTOPLAY
+    )
+
+    width = models.IntegerField(_('width'),
+            default=settings.CMS_YOUTUBE_DEFAULT_WIDTH)
+    height = models.IntegerField(_('height'),
+            default=settings.CMS_YOUTUBE_DEFAULT_HEIGHT)
+    border = models.BooleanField(_('border'),
+            default=settings.CMS_YOUTUBE_DEFAULT_BORDER)
+
+    allow_fullscreen = models.BooleanField(
+        _('allow fullscreen'),
+        default=settings.CMS_YOUTUBE_DEFAULT_FULLSCREEN
+    )
+
+    loop = models.BooleanField(_('loop'),
+            default=settings.CMS_YOUTUBE_DEFAULT_LOOP)
+
+    display_related_videos = models.BooleanField(
+        _('display related videos'),
+        default=settings.CMS_YOUTUBE_DEFAULT_RELATED
+    )
+
+    high_quality = models.BooleanField(
+        _('high quality'),
+        default=settings.CMS_YOUTUBE_DEFAULT_HIGHQUALITY
+    )
+
+    def __unicode__(self):
+        return u'%s' % (self.video_id,)

cmsplugin_youtube/settings.py

+"""
+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_YOUTUBE_DEFAULT_AUTOPLAY = getattr(settings,
+                                       'CMS_YOUTUBE_DEFAULT_AUTOPLAY', False)
+
+# Width & Height
+CMS_YOUTUBE_DEFAULT_WIDTH = getattr(settings, 'CMS_YOUTUBE_DEFAULT_WIDTH', 425)
+CMS_YOUTUBE_DEFAULT_HEIGHT = getattr(settings, 'CMS_YOUTUBE_DEFAULT_HEIGHT', 
+                                     344)
+
+# Border
+CMS_YOUTUBE_DEFAULT_BORDER = getattr(settings, 'CMS_YOUTUBE_DEFAULT_BORDER',
+                                     False)
+
+# Full Screen
+CMS_YOUTUBE_DEFAULT_FULLSCREEN = getattr(settings,
+                                         'CMS_YOUTUBE_DEFAULT_FULLSCREEN',
+                                         True)
+
+# Loop
+CMS_YOUTUBE_DEFAULT_LOOP = getattr(settings, 'CMS_YOUTUBE_DEFAULT_LOOP', False)
+
+# Display Related Videos
+CMS_YOUTUBE_DEFAULT_RELATED = getattr(settings, 'CMS_YOUTUBE_DEFAULT_RELATED',
+                                      False)
+
+# High Quality
+CMS_YOUTUBE_DEFAULT_HIGHQUALITY = getattr(settings,
+                                          'CMS_YOUTUBE_DEFAULT_HIGHQUALITY',
+                                          False)
+

cmsplugin_youtube/templates/cmsplugin_youtube/embed.html

+<object width="{{ object.width }}" height="{{ object.height }}">
+	<param name="movie" value="http://www.youtube.com/v/{{ object.video_id }}&autoplay={{ object.autoplay|yesno:"1,0" }}&fs={{ object.full_screen|yesno:"1,0" }}&border={{ object.border|yesno:"1,0" }}&loop={{ object.loop|yesno:"1,0" }}&rel={{ object.display_related_videos|yesno:"1,0" }}">
+	</param>
+
+	<param name="allowFullScreen" value="{{ object.full_screen|yesno:"true,false" }}"></param>
+
+	<embed src="http://www.youtube.com/v/{{ object.video_id }}&autoplay={{ object.autoplay|yesno:"1,0" }}&fs={{ object.full_screen|yesno:"1,0" }}&border={{ object.border|yesno:"1,0" }}&loop={{ object.loop|yesno:"1,0" }}&rel={{ object.display_related_videos|yesno:"1,0" }}" type="application/x-shockwave-flash" allowfullscreen="{{ object.full_screen|yesno:"true,false" }}" width="{{ object.width }}" height="{{ object.height }}">
+	</embed>
+</object>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.