diff options
| author | Xe Iaso <me@christine.website> | 2022-12-28 11:35:45 -0500 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2022-12-28 11:35:45 -0500 |
| commit | f6a10af0a81a1b3a83bdce660ed5ee88abcc063a (patch) | |
| tree | 64430939d9d96419b0b230b4944e29d464e1b0cd /lib | |
| parent | 793e1c79bfaecbc14e868fdf91d802a88be39384 (diff) | |
| download | xesite-unwrapped-2022.tar.xz xesite-unwrapped-2022.zip | |
first attemptunwrapped-2022
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/xesite_markdown/src/lib.rs | 8 | ||||
| -rw-r--r-- | lib/xesite_templates/src/lib.rs | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/xesite_markdown/src/lib.rs b/lib/xesite_markdown/src/lib.rs index 941761d..0c6900a 100644 --- a/lib/xesite_markdown/src/lib.rs +++ b/lib/xesite_markdown/src/lib.rs @@ -175,6 +175,14 @@ pub fn render(inp: &str) -> Result<String> { el.replace(&xesite_templates::talk_warning().0, ContentType::Html); Ok(()) }), + element!("xeblog-story", |el| { + let name = el + .get_attribute("name") + .ok_or(Error::MissingElementAttribute("name".to_string()))?; + + el.replace(&xesite_templates::story(name).0, ContentType::Html); + Ok(()) + }), element!("xeblog-video", |el| { let path = el .get_attribute("path") diff --git a/lib/xesite_templates/src/lib.rs b/lib/xesite_templates/src/lib.rs index 1149aaa..2f830f8 100644 --- a/lib/xesite_templates/src/lib.rs +++ b/lib/xesite_templates/src/lib.rs @@ -96,6 +96,26 @@ pub fn sticker(name: String, mood: String) -> Markup { } } +pub fn story(name: String) -> Markup { + let uuid = uuid::Uuid::new_v4(); + let uuid = format!("{uuid}").replace("-", ""); + let story_script = PreEscaped(format!( + r#" +<script type="module"> +import {{ init }} from "/static/js/stories.js?cachebust={uuid}"; + +init("{uuid}", "{name}"); +</script> +"# + )); + + html! { + div id=(uuid) { + (story_script) + } + } +} + pub fn video(path: String) -> Markup { let stream_url = format!( "https://cdn.xeiaso.net/file/christine-static/{}/index.m3u8", |
