diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue
index e87321b8..18e995e1 100644
--- a/client/src/components/ContentBlock.vue
+++ b/client/src/components/ContentBlock.vue
@@ -23,11 +23,12 @@
+
+
diff --git a/client/src/components/ContentBlockChooserWidget.vue b/client/src/components/content-forms/ContentBlockChooserWidget.vue
similarity index 98%
rename from client/src/components/ContentBlockChooserWidget.vue
rename to client/src/components/content-forms/ContentBlockChooserWidget.vue
index 809085cb..3262c65e 100644
--- a/client/src/components/ContentBlockChooserWidget.vue
+++ b/client/src/components/content-forms/ContentBlockChooserWidget.vue
@@ -4,7 +4,7 @@
Link
-
+
diff --git a/client/src/components/content-forms/VideoForm.vue b/client/src/components/content-forms/VideoForm.vue
index 56e44e5f..f0aba251 100644
--- a/client/src/components/content-forms/VideoForm.vue
+++ b/client/src/components/content-forms/VideoForm.vue
@@ -15,14 +15,10 @@
-
+
-
+
@@ -30,32 +26,25 @@
+
+
diff --git a/client/src/components/videos/YoutubeEmbed.vue b/client/src/components/videos/YoutubeEmbed.vue
new file mode 100644
index 00000000..4a24d1c1
--- /dev/null
+++ b/client/src/components/videos/YoutubeEmbed.vue
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
diff --git a/client/src/helpers/video.js b/client/src/helpers/video.js
new file mode 100644
index 00000000..2e4b4e87
--- /dev/null
+++ b/client/src/helpers/video.js
@@ -0,0 +1,20 @@
+const YOUTUBE = /^(?:https:\/\/)?(?:www.)?youtube.com\/watch\?v=([a-zA-Z0-9_-]{11})$/;
+const VIMEO = /^(?:https:\/\/)?(?:www.)?vimeo.com\/([a-zA-Z0-9]*)$/;
+
+export function isYoutubeUrl(url) {
+ return YOUTUBE.test(url);
+}
+
+export function isVimeoUrl(url) {
+ return VIMEO.test(url);
+}
+
+export function getVideoId(url) {
+ if (isYoutubeUrl(url)) {
+ return YOUTUBE.exec(url)[1];
+ } else if (isVimeoUrl(url)) {
+ return VIMEO.exec(url)[1];
+ } else {
+ return '';
+ }
+}
diff --git a/server/book/blocks.py b/server/book/blocks.py
index c96802f5..99c515f5 100644
--- a/server/book/blocks.py
+++ b/server/book/blocks.py
@@ -31,6 +31,11 @@ class StudentEntryBlock(blocks.StructBlock):
task_text = blocks.RichTextBlock()
+# 'video_block'
+class VideoBlock(blocks.StructBlock):
+ url = blocks.URLBlock()
+
+
# 'text_block' 'task' 'basic_knowledge' 'student_entry' 'image_block'
#
# url = blocks.URLBlock()
diff --git a/server/book/models/contentblock.py b/server/book/models/contentblock.py
index 4625b2e6..0ef9da15 100644
--- a/server/book/models/contentblock.py
+++ b/server/book/models/contentblock.py
@@ -5,7 +5,7 @@ from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList,
from wagtail.core.fields import StreamField
from wagtail.images.blocks import ImageChooserBlock
-from book.blocks import TextBlock, BasicKnowledgeBlock, StudentEntryBlock, LinkBlock
+from book.blocks import TextBlock, BasicKnowledgeBlock, StudentEntryBlock, LinkBlock, VideoBlock
from core.wagtail_utils import StrictHierarchyPage
from user.models import UserGroup
@@ -35,7 +35,8 @@ class ContentBlock(StrictHierarchyPage):
('student_entry', StudentEntryBlock(icon='download')),
('image_block', ImageChooserBlock(icon='image')),
('link_block', LinkBlock(icon='link')),
- ('task', TextBlock(icon='tick'))
+ ('task', TextBlock(icon='tick')),
+ ('video_block', VideoBlock(icon='media')),
], null=True, blank=True)
type = models.CharField(
diff --git a/server/book/schema/mutations.py b/server/book/schema/mutations.py
index 8aa8052e..e2abbe22 100644
--- a/server/book/schema/mutations.py
+++ b/server/book/schema/mutations.py
@@ -31,7 +31,11 @@ def handle_content_blocks(content_data):
elif content['type'] == 'task':
pass
elif content['type'] == 'video_block':
- pass
+ new_contents.append({
+ 'type': 'video_block',
+ 'value': {
+ 'url': bleach.clean(content['url'])
+ }})
elif content['type'] == 'document_block':
pass
return new_contents