From 96caa7cccd8bedd7ebfffc9095c4f8fe44c9aa9d Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Wed, 12 Oct 2022 02:39:57 +0000 Subject: HLS support Signed-off-by: Xe Iaso --- lib/xesite_markdown/src/lib.rs | 8 ++++++++ lib/xesite_templates/src/lib.rs | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/xesite_markdown/src/lib.rs b/lib/xesite_markdown/src/lib.rs index b225c4a..fad2b3a 100644 --- a/lib/xesite_markdown/src/lib.rs +++ b/lib/xesite_markdown/src/lib.rs @@ -167,6 +167,14 @@ pub fn render(inp: &str) -> Result { el.replace(&xesite_templates::talk_warning().0, ContentType::Html); Ok(()) }), + element!("xeblog-video", |el| { + let path = el + .get_attribute("path") + .ok_or(Error::MissingElementAttribute("path".to_string()))?; + + el.replace(&xesite_templates::video(path).0, ContentType::Html); + Ok(()) + }), ], ..RewriteStrSettings::default() }, diff --git a/lib/xesite_templates/src/lib.rs b/lib/xesite_templates/src/lib.rs index 32ec07f..2e095db 100644 --- a/lib/xesite_templates/src/lib.rs +++ b/lib/xesite_templates/src/lib.rs @@ -1,4 +1,4 @@ -use maud::{html, Markup}; +use maud::{html, Markup, PreEscaped}; pub fn talk_warning() -> Markup { html! { @@ -94,3 +94,34 @@ pub fn sticker(name: String, mood: String) -> Markup { } } } + +pub fn video(path: String) -> Markup { + let hls_script = PreEscaped(format!( + r#" + +"#, + path + )); + + html! { + script src="/static/js/hls.js" {} + video id="video" width="100%" controls {} + (hls_script) + } +} -- cgit v1.2.3