Skip to content
Browse files

extensible embedded video plugin

  • Loading branch information...
1 parent e5a7fcc commit 70ce3fd583023c29e2a23b6f5e88226eb90ffe16 @evildmp committed Mar 13, 2013
View
20 arkestra_image_plugin/cms_plugins.py
@@ -15,7 +15,8 @@
from widgetry.tabs.admin import ModelAdminWithTabs
from widgetry import fk_lookup
-from arkestra_utilities.settings import IMAGESET_ITEM_PADDING
+from arkestra_utilities.settings import IMAGESET_ITEM_PADDING, VIDEO_HOSTING_SERVICES
+
from arkestra_utilities.output_libraries.plugin_widths import get_placeholder_width, calculate_container_width
from arkestra_utilities.admin_mixins import AutocompleteMixin, SupplyRequestMixin
@@ -531,32 +532,23 @@ def icon_src(self, instance):
plugin_pool.register_plugin(FilerImagePlugin)
+
class EmbeddedVideoSetItemEditor(SupplyRequestMixin, admin.StackedInline, AutocompleteMixin):
- # form = ImageSetItemPluginForm
- # formset = ImageSetItemFormFormSet
- # related_search_fields = ['destination_content_type']
model=EmbeddedVideoSetItem
extra=1
fieldsets = (
(None, {
'fields': (
('service', 'video_code', 'aspect_ratio'),
('video_title', 'video_autoplay'),
- ('active', ),
+ ('active', 'inline_item_ordering'),
),
}),
- # ('Other options', {
- # 'fields': (
- # 'video_caption',
- # ),
- # 'classes': ('collapse',),
- # })
)
class EmbeddedVideoPlugin(CMSPluginBase):
model = EmbeddedVideoSetPlugin
- render_template = "arkestra_image_plugin/embedded_video_plugin.html"
admin_preview = False
name = "Embedded video set"
@@ -583,6 +575,7 @@ def render(self, context, embeddedvideoset, placeholder):
width = int(width_of_image_container(context, embeddedvideoset))
height = int(width/video.aspect_ratio)
+ self.render_template = VIDEO_HOSTING_SERVICES[video.service]["template"]
context.update({
'embeddedvideoset': embeddedvideoset,
'video': video,
@@ -593,9 +586,6 @@ def render(self, context, embeddedvideoset, placeholder):
# no items, use a null template
else:
self.render_template = "null.html"
- # context.update({
- # 'placeholder':placeholder,
- # })
return context
View
7 arkestra_image_plugin/models.py
@@ -12,6 +12,8 @@
from filer.fields.file import FilerFileField
from arkestra_utilities.import_free_model_mixins import ArkestraGenericPluginItemOrdering
+from arkestra_utilities.settings import VIDEO_HOSTING_SERVICES
+
from links.models import LinkMethodsMixin
class FilerImage(CMSPlugin):
@@ -281,10 +283,7 @@ class Meta:
EmbeddedVideoSetPlugin,
related_name="embeddedvideoset_item"
)
- SERVICES = (
- ("vimeo", "Vimeo"),
- ("youtube", "YouTube"),
- )
+ SERVICES = [(service, values["name"]) for service,values in VIDEO_HOSTING_SERVICES.items()]
service = models.CharField(choices = SERVICES, max_length = 50)
video_code = models.CharField(max_length=255,
help_text = "Not the full URL."
View
22 arkestra_image_plugin/templates/arkestra_image_plugin/embedded_video_plugin.html
@@ -1,22 +0,0 @@
-{% if video.service == "youtube" %}
- <iframe id="youtubeplayer-{{ embeddedvideoset.id }}"
- type="text/html"
- width="{{ width }}"
- height="{{ height }}"
- frameborder="0"
- src="http://www.youtube.com/embed/{{ video.video_code }}?autoplay={{ video.video_autoplay|yesno:"1,0,0" }}&modestbranding=0&theme=light"
- />
- </iframe>
-
-{% elif video.service == "vimeo" %}
- <iframe
- id="vimeoplayer-{{ embeddedvideoset.id }}"
- width="{{ width }}"
- height="{{ height }}"
- frameborder="0"
- webkitAllowFullScreen mozallowfullscreen allowFullScreen
- src="http://player.vimeo.com/video/{{ video.video_code }}?autoplay={{ video.video_autoplay|yesno:"1,0,0" }}"
- />
- </iframe>
-
-{% endif %}
View
9 arkestra_image_plugin/templates/embedded_video/vimeo.html
@@ -0,0 +1,9 @@
+<iframe
+ id="vimeoplayer-{{ embeddedvideoset.id }}"
+ width="{{ width }}"
+ height="{{ height }}"
+ frameborder="0"
+ webkitAllowFullScreen mozallowfullscreen allowFullScreen
+ src="http://player.vimeo.com/video/{{ video.video_code }}?autoplay={{ video.video_autoplay|yesno:"1,0,0" }}"
+ />
+</iframe>
View
8 arkestra_image_plugin/templates/embedded_video/youtube.html
@@ -0,0 +1,8 @@
+<iframe id="youtubeplayer-{{ embeddedvideoset.id }}"
+ type="text/html"
+ width="{{ width }}"
+ height="{{ height }}"
+ frameborder="0"
+ src="http://www.youtube.com/embed/{{ video.video_code }}?autoplay={{ video.video_autoplay|yesno:"1,0,0" }}&modestbranding=0&theme=light"
+ />
+</iframe>
View
6 arkestra_utilities/settings.py
@@ -99,6 +99,12 @@
USE_CELERY_FOR_VIDEO_ENCODING = getattr(settings, "USE_CELERY_FOR_VIDEO_ENCODING", False)
+VIDEO_HOSTING_SERVICES = getattr(settings, "VIDEO_HOSTING_SERVICES", {
+ "vimeo": {"name": "Vimeo", "template": "embedded_video/vimeo.html"},
+ "youtube": {"name": "YouTube", "template": "embedded_video/youtube.html"},
+ }
+ )
+
# -------- Django CMS ----------------------
CMS_SEO_FIELDS = getattr(settings, "CMS_SEO_FIELDS", True)

0 comments on commit 70ce3fd

Please sign in to comment.
Something went wrong with that request. Please try again.