Explorar el Código

Add video-bg + video and soundtrack shortcodes

master
The Dod hace 1 año
padre
commit
a45ec5bfda

+ 18
- 7
app.py Ver fichero

@@ -7,16 +7,27 @@ import os
7 7
 import sys
8 8
 import time
9 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 26
 def preprocess_payload(payload):
12 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 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 32
 load_dotenv()
22 33
 
@@ -43,7 +54,7 @@ def update():
43 54
 
44 55
 @application.get("/enum/<topic>")
45 56
 def choices(topic):
46
-    if topic in ["img", "bg"]:
57
+    if topic in ["img", "bg", "bg-video"]:
47 58
         return {"type": "string", "enum": glob("static/{}/*.*".format(topic))}
48 59
     abort(404)
49 60
 

+ 2
- 0
debug-server.sh Ver fichero

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

BIN
static/audio/VJ_Memes_-_funkyGarden.mp3 Ver fichero


BIN
static/bg-video/beach-sunset1.mp4 Ver fichero


BIN
static/bg-video/clouds1.mp4 Ver fichero


BIN
static/bg-video/underwater.mp4 Ver fichero


+ 1813
- 0
static/bg/twilight-2.svg
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 19
- 11
static/slides.json Ver fichero

@@ -5,21 +5,27 @@
5 5
             "id": "welcome",
6 6
             "title": "Goodbye, mates",
7 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 19
             "id": "memory",
16 20
             "title": "How I'd like to be remembered",
17 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 29
             "slides": [
24 30
                 {
25 31
                     "id": "work",
@@ -34,8 +40,8 @@
34 40
                     "id": "rest",
35 41
                     "title": "The rest",
36 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 45
                         "background-size": "contain"
40 46
                     },
41 47
                     "markdown": "#### I've rested like a cat.\n\n![A cat resting|w-66 centered](static/img/cat-resting.png)"
@@ -47,7 +53,9 @@
47 53
             "title": "Who I seek forgiveness from",
48 54
             "params": {
49 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 59
                 "background-opacity": "0.25"
52 60
             },
53 61
             "markdown": "I've made many mistakes.\n\nI hope you can forgive me:",

+ 20
- 0
static/slides.schema.json Ver fichero

@@ -103,6 +103,26 @@
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 126
         "background-opacity": {
107 127
           "type": "string",
108 128
           "title": "Background opacity",

BIN
static/video/bell.mp4 Ver fichero


+ 2
- 0
templates/slides.html Ver fichero

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

Loading…
Cancelar
Guardar