some updates

This commit is contained in:
Chris Cochrun 2024-11-19 15:25:35 -06:00
parent c60353f8c8
commit d6536f8a88
2 changed files with 32 additions and 6 deletions

2
Cargo.lock generated
View file

@ -1257,7 +1257,7 @@ dependencies = [
[[package]] [[package]]
name = "crisp" name = "crisp"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.tfcconnection.org/chris/crisp#04a470d771bd86646d27ef35811fc7d6a3c7bafb" source = "git+https://git.tfcconnection.org/chris/crisp#b01eda5e0e3df469b45ff91424f7ad6f806cbca3"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"miette", "miette",

View file

@ -10,8 +10,6 @@ use std::{
use crate::core::lisp::Symbol; use crate::core::lisp::Symbol;
use super::lisp::get_lists;
#[derive( #[derive(
Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize,
)] )]
@ -207,11 +205,31 @@ fn lisp_to_slide(lisp: Vec<Value>) -> Slide {
slide.background(lisp_to_background(background)); slide.background(lisp_to_background(background));
} else { } else {
slide.background(Background::default()); slide.background(Background::default());
};
match slide.build() {
Ok(slide) => slide,
Err(e) => {
miette!("Shoot! Slide didn't build: {e}");
Slide::default()
}
} }
} }
fn lisp_to_background(lisp: &Value) { fn lisp_to_background(lisp: &Value) -> Background {
todo!() match lisp {
Value::List(list) => {
if let Some(source) = list.iter().position(|v| {
v == Value::Keyword(Keyword::from("source"))
}) {
let path = list[source + 1];
let path = String::from(path);
Background::from(path)
} else {
Background::default()
}
}
_ => Background::default(),
}
} }
#[derive( #[derive(
@ -233,7 +251,7 @@ impl SlideBuilder {
Self::default() Self::default()
} }
pub(crate) fn background( pub(crate) fn background_path(
mut self, mut self,
background: PathBuf, background: PathBuf,
) -> Result<Self, ParseError> { ) -> Result<Self, ParseError> {
@ -242,6 +260,14 @@ impl SlideBuilder {
Ok(self) Ok(self)
} }
pub(crate) fn background(
mut self,
background: Background,
) -> Self {
self.background.insert(background);
self
}
pub(crate) fn text(mut self, text: impl Into<String>) -> Self { pub(crate) fn text(mut self, text: impl Into<String>) -> Self {
let _ = self.text.insert(text.into()); let _ = self.text.insert(text.into());
self self