aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2023-02-02 08:05:34 -0500
committerXe Iaso <me@christine.website>2023-02-02 08:05:34 -0500
commitc117eae7c5af977d0299d34169e4a403f77e2afa (patch)
tree83438cf5abc605e0ec174aa4a3f0e4b91b640008 /src/app
parent757cee6fdd13502eb62305f77e73698878b01aa2 (diff)
downloadxesite-c117eae7c5af977d0299d34169e4a403f77e2afa.tar.xz
xesite-c117eae7c5af977d0299d34169e4a403f77e2afa.zip
add stream VOD page
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config.rs60
-rw-r--r--src/app/config/markdown_string.rs64
2 files changed, 123 insertions, 1 deletions
diff --git a/src/app/config.rs b/src/app/config.rs
index 7ea46fd..8c7d64d 100644
--- a/src/app/config.rs
+++ b/src/app/config.rs
@@ -1,11 +1,15 @@
use crate::signalboost::Person;
-use maud::{html, Markup, Render};
+use chrono::prelude::*;
+use maud::{html, Markup, PreEscaped, Render};
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
fmt::{self, Display},
};
+mod markdown_string;
+use markdown_string::MarkdownString;
+
#[derive(Clone, Deserialize, Default)]
pub struct Config {
pub signalboost: Vec<Person>,
@@ -29,6 +33,7 @@ pub struct Config {
pub contact_links: Vec<Link>,
pub pronouns: Vec<PronounSet>,
pub characters: Vec<Character>,
+ pub vods: Vec<VOD>,
}
#[derive(Clone, Deserialize, Serialize, Default)]
@@ -336,3 +341,56 @@ impl Render for Job {
}
}
}
+
+#[derive(Clone, Deserialize, Serialize, Default)]
+pub struct VOD {
+ pub title: String,
+ pub slug: String,
+ pub date: NaiveDate,
+ pub description: MarkdownString,
+ #[serde(rename = "cdnPath")]
+ pub cdn_path: String,
+ pub tags: Vec<String>,
+}
+
+impl VOD {
+ pub fn detri(&self) -> String {
+ self.date.format("M%m %d %Y").to_string()
+ }
+}
+
+impl Render for VOD {
+ fn render(&self) -> Markup {
+ html! {
+ meta name="twitter:card" content="summary";
+ meta name="twitter:site" content="@theprincessxena";
+ meta name="twitter:title" content={(self.title)};
+ meta property="og:type" content="website";
+ meta property="og:title" content={(self.title)};
+ meta property="og:site_name" content="Xe's Blog";
+ meta name="description" content={(self.title) " - Xe's Blog"};
+ meta name="author" content="Xe Iaso";
+
+ h1 {(self.title)}
+ small {"Streamed on " (self.detri())}
+
+ (xesite_templates::advertiser_nag(Some(html!{
+ (xesite_templates::conv("Cadey".into(), "coffee".into(), html!{
+ "Hi. This page embeds a video file that is potentially multiple hours long. Hosting this stuff is not free. Bandwidth in particular is expensive. If you really want to continue to block ads, please consider donating via "
+ a href="https://patreon.com/cadey" {"Patreon"}
+ " because servers and bandwidth do not grow on trees."
+ }))
+ })))
+
+ (xesite_templates::video(self.cdn_path.clone()))
+ (self.description)
+ p {
+ "Tags: "
+ @for tag in &self.tags {
+ code{(tag)}
+ " "
+ }
+ }
+ }
+ }
+}
diff --git a/src/app/config/markdown_string.rs b/src/app/config/markdown_string.rs
new file mode 100644
index 0000000..aad803b
--- /dev/null
+++ b/src/app/config/markdown_string.rs
@@ -0,0 +1,64 @@
+use std::fmt;
+
+use maud::{html, Markup, PreEscaped, Render};
+use serde::{
+ de::{self, Visitor},
+ Deserialize, Deserializer, Serialize,
+};
+
+struct StringVisitor;
+
+impl<'de> Visitor<'de> for StringVisitor {
+ type Value = MarkdownString;
+
+ fn visit_borrowed_str<E>(self, value: &'de str) -> Result<Self::Value, E>
+ where
+ E: de::Error,
+ {
+ Ok(MarkdownString(xesite_markdown::render(value).map_err(
+ |why| de::Error::invalid_value(de::Unexpected::Other(&format!("{why}")), &self),
+ )?))
+ }
+
+ fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
+ where
+ E: de::Error,
+ {
+ Ok(MarkdownString(xesite_markdown::render(value).map_err(
+ |why| de::Error::invalid_value(de::Unexpected::Other(&format!("{why}")), &self),
+ )?))
+ }
+
+ fn visit_string<E>(self, value: String) -> Result<Self::Value, E>
+ where
+ E: de::Error,
+ {
+ Ok(MarkdownString(xesite_markdown::render(&value).map_err(
+ |why| de::Error::invalid_value(de::Unexpected::Other(&format!("{why}")), &self),
+ )?))
+ }
+
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ formatter.write_str("a string with xesite-flavored markdown")
+ }
+}
+
+#[derive(Serialize, Clone, Default)]
+pub struct MarkdownString(String);
+
+impl<'de> Deserialize<'de> for MarkdownString {
+ fn deserialize<D>(deserializer: D) -> Result<MarkdownString, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ deserializer.deserialize_string(StringVisitor)
+ }
+}
+
+impl Render for MarkdownString {
+ fn render(&self) -> Markup {
+ html! {
+ (PreEscaped(&self.0))
+ }
+ }
+}