aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDerek Stevens <nilix@nilfm.cc>2022-08-21 14:18:03 -0600
committerDerek Stevens <nilix@nilfm.cc>2022-08-21 14:18:03 -0600
commit77b6102e84ecbf1bf06e6f04b784b9a9539dc4e7 (patch)
treedf1d2bea94debaa82eb13b486d0b152146188c61 /main.c
parent8cdc1fc8782150c892fed4111255ff52573d3858 (diff)
add video templatingHEADmain
Diffstat (limited to 'main.c')
-rw-r--r--main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/main.c b/main.c
index 591b822..c24ef42 100644
--- a/main.c
+++ b/main.c
@@ -255,6 +255,49 @@ int fphimg(FILE* f, char* s) {
return 1;
}
+int fpvideo(FILE* f, char* s) {
+ char id[1024] = {0};
+ char href[1024] = {0};
+ char src[1024] = {0};
+ char alt[1024] = {0};
+ char thumb[1024] = {0};
+
+ char* c = s;
+ int i = 0;
+ while (i < 4) {
+ if (*c == '|' || !(*c)) {
+ i++;
+ c++;
+ continue;
+ }
+ switch (i) {
+ case 0:
+ ccat(id, *c++);
+ break;
+ case 1:
+ ccat(href, *c++);
+ break;
+ case 2:
+ ccat(src, *c++);
+ break;
+ case 3:
+ ccat(alt, *c++);
+ break;
+ }
+ }
+ thumbtrans(src, thumb);
+
+ fprintf(
+ f,
+ "<video id='%s' src='%s' controls preload='metadata' poster='%s'>\n",
+ id,
+ href,
+ thumb);
+ fprintf(f, "<a href='%s'>%s</a>\n", href, alt);
+ fprintf(f, "</video>\n");
+ return 1;
+}
+
int fpaudio(FILE* f, char* s) {
fputs("<audio class='player' preload='metadata' controls>\n", f);
fprintf(
@@ -378,6 +421,8 @@ int fptemplate(FILE* f, Lexicon* l, char* s) {
return fpimg(f, s + 1);
case '?':
return fphimg(f, s + 1);
+ case ']':
+ return fpvideo(f, s + 1);
case '_':
return fpaudio(f, s + 1);
case '`':