Browse Source

Add video-bg + video and soundtrack shortcodes

master
The Dod 1 year ago
parent
commit
a45ec5bfda

+ 18
- 7
app.py View File

7
 import sys
7
 import sys
8
 import time
8
 import time
9
 import shutil
9
 import shutil
10
+import re
11
+
12
+RE_VID = re.compile("""\[video ["']([^['"]*?)["']\]""")
13
+TEMPLATE_VID = """<video controls><source src="{}" type="video/{}"></video>"""
14
+
15
+RE_SOUNDTRACK = re.compile("""\[soundtrack ["']([^['"]*?)["']\]""")
16
+TEMPLATE_SOUNDTRACK = """<audio data-autoplay><source src="{}" type="audio/{}"></audio>"""
17
+
18
+def preprocess_markdown(md):
19
+    if md:
20
+        content = markdown(md)
21
+        content = RE_VID.sub(lambda m: TEMPLATE_VID.format(m.group(1), m.group(1).split('.')[-1]), content)
22
+        content = RE_SOUNDTRACK.sub(lambda m: TEMPLATE_SOUNDTRACK.format(m.group(1), m.group(1).split('.')[-1]), content)
23
+        return content
24
+    return ""
10
 
25
 
11
 def preprocess_payload(payload):
26
 def preprocess_payload(payload):
12
     for column in payload.get("columns", []):
27
     for column in payload.get("columns", []):
13
-        md = column.get("markdown")
14
-        if md:
15
-            column["content"] = markdown(md)
28
+        column["content"] = preprocess_markdown(column.get("markdown"))
16
         for slide in column.get("slides", []):
29
         for slide in column.get("slides", []):
17
-            md = slide.get("markdown")
18
-            if md:
19
-                slide["content"] = markdown(md)
30
+            slide["content"] = preprocess_markdown(slide.get("markdown"))
20
 
31
 
21
 load_dotenv()
32
 load_dotenv()
22
 
33
 
43
 
54
 
44
 @application.get("/enum/<topic>")
55
 @application.get("/enum/<topic>")
45
 def choices(topic):
56
 def choices(topic):
46
-    if topic in ["img", "bg"]:
57
+    if topic in ["img", "bg", "bg-video"]:
47
         return {"type": "string", "enum": glob("static/{}/*.*".format(topic))}
58
         return {"type": "string", "enum": glob("static/{}/*.*".format(topic))}
48
     abort(404)
59
     abort(404)
49
 
60
 

+ 2
- 0
debug-server.sh View File

1
+source venv/bin/activate
2
+flask --debug run

BIN
static/audio/VJ_Memes_-_funkyGarden.mp3 View File


BIN
static/bg-video/beach-sunset1.mp4 View File


BIN
static/bg-video/clouds1.mp4 View File


BIN
static/bg-video/underwater.mp4 View File


+ 1813
- 0
static/bg/twilight-2.svg
File diff suppressed because it is too large
View File


+ 19
- 11
static/slides.json View File

5
             "id": "welcome",
5
             "id": "welcome",
6
             "title": "Goodbye, mates",
6
             "title": "Goodbye, mates",
7
             "params": {
7
             "params": {
8
-                "theme": "simple",
9
-                "background-image": "static/bg/valley-1.svg",
10
-                "background-opacity": "0.25"
8
+                "theme": "sky",
9
+                "background-video": "static/bg-video/clouds1.mp4",
10
+                "background-video-loop": true,
11
+                "background-video-mute": true,
12
+                "background-opacity": "0.5",
13
+                "background-size": "cover",
14
+                "background-video-autoplay": true
11
             },
15
             },
12
-            "markdown": "Welcome, friends.\n\nWe're about to begin."
16
+            "markdown": "First, let us meditate: [video \"static/video/bell.mp4\"]\nClose your eyes and concentrate on the sound of the bell.\n"
13
         },
17
         },
14
         {
18
         {
15
             "id": "memory",
19
             "id": "memory",
16
             "title": "How I'd like to be remembered",
20
             "title": "How I'd like to be remembered",
17
             "params": {
21
             "params": {
18
-                "theme": "solarized",
19
-                "background-image": "static/bg/valley-1.svg",
20
-                "background-opacity": "0.25"
22
+                "theme": "night",
23
+                "background-video": "static/bg-video/beach-sunset1.mp4",
24
+                "background-video-loop": true,
25
+                "background-video-mute": true,
26
+                "background-opacity": "0.75"
21
             },
27
             },
22
-            "markdown": "I've done many things.\n\nSome of them I'm proud of:",
28
+            "markdown": "I've done many things. Some of them I'm proud of: [soundtrack \"static/audio/VJ_Memes_-_funkyGarden.mp3\"]",
23
             "slides": [
29
             "slides": [
24
                 {
30
                 {
25
                     "id": "work",
31
                     "id": "work",
34
                     "id": "rest",
40
                     "id": "rest",
35
                     "title": "The rest",
41
                     "title": "The rest",
36
                     "params": {
42
                     "params": {
37
-                        "theme": "moon",
38
-                        "background-image": "static/bg/twilight-1.svg",
43
+                        "background-image": "static/bg/twilight-2.svg",
44
+                        "background-opacity": "0.5",
39
                         "background-size": "contain"
45
                         "background-size": "contain"
40
                     },
46
                     },
41
                     "markdown": "#### I've rested like a cat.\n\n![A cat resting|w-66 centered](static/img/cat-resting.png)"
47
                     "markdown": "#### I've rested like a cat.\n\n![A cat resting|w-66 centered](static/img/cat-resting.png)"
47
             "title": "Who I seek forgiveness from",
53
             "title": "Who I seek forgiveness from",
48
             "params": {
54
             "params": {
49
                 "theme": "league",
55
                 "theme": "league",
50
-                "background-image": "static/bg/particles-1.svg",
56
+                "background-video": "static/bg-video/underwater.mp4",
57
+                "background-video-loop": true,
58
+                "background-video-mute": true,
51
                 "background-opacity": "0.25"
59
                 "background-opacity": "0.25"
52
             },
60
             },
53
             "markdown": "I've made many mistakes.\n\nI hope you can forgive me:",
61
             "markdown": "I've made many mistakes.\n\nI hope you can forgive me:",

+ 20
- 0
static/slides.schema.json View File

103
             }
103
             }
104
           ]
104
           ]
105
         },
105
         },
106
+        "background-video": {
107
+          "$ref": "/enum/bg-video",
108
+          "title": "Background video",
109
+          "links": [
110
+            {
111
+              "rel": "Preview video",
112
+              "class": "link-info",
113
+              "href": "{{self}}",
114
+              "media-type": "video/mp4"
115
+            }
116
+          ]
117
+        },
118
+        "background-video-loop": {
119
+            "type": "boolean",
120
+            "default": true
121
+        },
122
+        "background-video-mute": {
123
+            "type": "boolean",
124
+            "default": true
125
+        },
106
         "background-opacity": {
126
         "background-opacity": {
107
           "type": "string",
127
           "type": "string",
108
           "title": "Background opacity",
128
           "title": "Background opacity",

BIN
static/video/bell.mp4 View File


+ 2
- 0
templates/slides.html View File

84
 				plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
84
 				plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
85
 			});
85
 			});
86
                         $(function() {
86
                         $(function() {
87
+                            // force autoplay for bg videos (but why?!?)
88
+                            $('.reveal .slide-background-content video').each((index, element) => element.play());
87
                             // open external links in new tab
89
                             // open external links in new tab
88
                             $('.reveal a:not([href^="#"])').attr('target','_blank');
90
                             $('.reveal a:not([href^="#"])').attr('target','_blank');
89
                             // extract css classes from img alt
91
                             // extract css classes from img alt

Loading…
Cancel
Save