Permalink
Browse files

plugin

  • Loading branch information...
1 parent 3e301f9 commit 7b44988b6fca8d79552dc9d5d294a727ecdb3183 Denys Chmeliuk committed Apr 22, 2012
View
@@ -0,0 +1 @@
+.idea
View
@@ -1,2 +1,2 @@
cmsplugin-simple-youtube
-========================
+========================
No changes.
@@ -0,0 +1,8 @@
+from django.contrib import admin
+from models import SimpleYouTube
+
+class SimpleYouTubeAdmin(admin.ModelAdmin):
+ list_display = ('thumbnail','name', 'video_url', 'autoplay',)
+ pass
+
+admin.site.register(SimpleYouTube, SimpleYouTubeAdmin)
@@ -0,0 +1,22 @@
+from django.utils.translation import ugettext as _
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+from models import SimpleYoutubePointer
+
+class SimpleYouTubePlugin(CMSPluginBase):
+ model = SimpleYoutubePointer
+ name = _("Simple: YouTube")
+ render_template = "cmsplugin_simple_youtube/fancy_iframe.html"
+ text_enabled = True
+
+ def render(self, context, instance, placeholder):
+ context.update({
+ 'object': instance.youtube,
+ 'placeholder': placeholder
+ })
+ return context
+
+ def icon_src(self, instance):
+ return u'http://i4.ytimg.com/vi/%s/default.jpg' % instance.youtube.video_id
+
+plugin_pool.register_plugin(SimpleYouTubePlugin)
@@ -0,0 +1,30 @@
+from cms.models import CMSPlugin
+from django.db import models
+from django.utils.translation import ugettext as _
+import settings
+
+class SimpleYouTube(models.Model):
+ name = models.CharField(_('name'), max_length=255, blank=False, null=False)
+ video_id = models.CharField(_('video id'), max_length=60)
+ autoplay = models.BooleanField(_('autoplay'),default=settings.CMS_SIMPLEYOUTUBE_AUTOPLAY)
+
+ def __unicode__(self):
+ return u'%s' % (self.name,)
+
+ def video_url(self):
+ return u'http://www.youtube.com/watch?v=%s' % self.video_id
+
+ def thumbnail(self):
+ return u'<img src="http://i4.ytimg.com/vi/%s/default.jpg" />' % self.video_id
+ thumbnail.allow_tags = True
+
+
+class SimpleYoutubePointer(CMSPlugin):
+ youtube = models.ForeignKey(SimpleYouTube)
+ class Meta:
+ verbose_name = _("SimpleYoutube")
+
+ def __unicode__(self):
+ return self.youtube.name
+
+#reversion_register(YouTube)
@@ -0,0 +1,5 @@
+from django.conf import settings
+
+CMS_SIMPLEYOUTUBE_AUTOPLAY = getattr(settings, 'CMS_CMS_SIMPLEYOUTUBE_AUTOPLAY', True)
+
+
@@ -0,0 +1,11 @@
+<a href="http://www.youtube.com/embed/{{ object.video_id }}?autoplay={{ object.autoplay|yesno:"1,0" }}&wmode=opaque"
+ class="cmsplugin_simple_youtube_{{ object.video_id }}"><img src="http://i4.ytimg.com/vi/{{ object.video_id}}/default.jpg" /></a>
+<script type="text/javascript">
+ $(".cmsplugin_simple_youtube_{{ object.video_id }}").fancybox({
+ 'transitionIn': 'none',
+ 'transitionOut': 'none',
+ 'type': 'iframe',
+ 'width': 640,
+ 'height': 360
+ });
+</script>
View
@@ -0,0 +1,22 @@
+from setuptools import setup, find_packages
+
+setup(
+ name='cmsplugin-simple-youtube',
+ version='0.1',
+ description='Simple django cms plugin which allow you insert video in to your page.',
+ author='D.Chmelyuk',
+ author_email='d.chmeluyk@gmail.com',
+ url='http://github.com/chmeliuk/cmsplugin-simple-youtube/',
+ packages=find_packages(),
+ classifiers=[
+ 'Development Status :: Beta',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Framework :: Django',
+ ],
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=['setuptools'],
+)

0 comments on commit 7b44988

Please sign in to comment.