add video templating

This commit is contained in:
Iris Lightshard 2022-08-21 14:18:03 -06:00
parent 8cdc1fc878
commit 77b6102e84
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

45
main.c
View file

@ -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 '`':