You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/11/06 15:39:12 UTC
[airavata-django-portal] 02/02: Wagtail: add bootstrap video embed
block
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 27e115cd661c852622b8df44911ebc4df00934f0
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Nov 6 10:38:51 2019 -0500
Wagtail: add bootstrap video embed block
---
.../templates/blocks/bootstrap/embed-video.html | 3 +++
django_airavata/wagtailapps/base/blocks.py | 24 ++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/django_airavata/templates/blocks/bootstrap/embed-video.html b/django_airavata/templates/blocks/bootstrap/embed-video.html
new file mode 100644
index 0000000..874980a
--- /dev/null
+++ b/django_airavata/templates/blocks/bootstrap/embed-video.html
@@ -0,0 +1,3 @@
+<div class="embed-responsive embed-responsive-{{ self.aspect_ratio }} {{self.custom_class}}">
+ <video controls src="{{ self.video.file.url }}" />
+</div>
diff --git a/django_airavata/wagtailapps/base/blocks.py b/django_airavata/wagtailapps/base/blocks.py
index ce05072..56cd97d 100644
--- a/django_airavata/wagtailapps/base/blocks.py
+++ b/django_airavata/wagtailapps/base/blocks.py
@@ -10,6 +10,7 @@ from wagtail.core.blocks import (
StructBlock,
TextBlock
)
+from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.embeds.blocks import EmbedBlock
from wagtail.images.blocks import ImageChooserBlock
@@ -432,6 +433,28 @@ class BootstrapMediaObject(StructBlock):
template = "blocks/bootstrap/media.html"
+class BootstrapEmbedVideo(StructBlock):
+ """
+ Use Bootstrap's Embed component with video tag.
+ """
+ video = DocumentChooserBlock(required=True)
+ aspect_ratio = ChoiceBlock(choices=[
+ ('21by9', '21 x 9'),
+ ('16by9', '16 x 9'),
+ ('4by3', '4 x 3'),
+ ('1by1', '1 x 1'),
+ ], default='4by3', help_text="Aspect ratio")
+ custom_class = TextBlock(
+ required=False,
+ blank=True,
+ help_text="control this element by giving unique class names "
+ "separated by space and styling the class in css")
+
+ class Meta:
+ icon = "media"
+ template = "blocks/bootstrap/embed-video.html"
+
+
# StreamBlocks
class BaseStreamBlock(StreamBlock):
"""
@@ -452,6 +475,7 @@ class BaseStreamBlock(StreamBlock):
placeholder_block = PlaceholderBlock()
font_awesome_icon_block = FontAwesomeIcon()
iu_footer_block = IuFooter()
+ bootstrap_embed_video = BootstrapEmbedVideo()
class CssStreamBlock(StreamBlock):