finally trying to start bringing in crisp properly

This commit is contained in:
Chris Cochrun 2024-11-19 17:45:04 -06:00
parent d6536f8a88
commit 6f33930cc9
4 changed files with 105 additions and 109 deletions

1
Cargo.lock generated
View file

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

View file

@ -23,4 +23,4 @@ ron = "0.8.1"
sqlx = { version = "0.8.2", features = ["sqlite"] } sqlx = { version = "0.8.2", features = ["sqlite"] }
dirs = "5.0.1" dirs = "5.0.1"
tokio = "1.41.1" tokio = "1.41.1"
crisp = { git = "https://git.tfcconnection.org/chris/crisp" } crisp = { path = "../crisp" }

View file

@ -222,8 +222,7 @@ fn lisp_to_background(lisp: &Value) -> Background {
v == Value::Keyword(Keyword::from("source")) v == Value::Keyword(Keyword::from("source"))
}) { }) {
let path = list[source + 1]; let path = list[source + 1];
let path = String::from(path); Background::try_from(&path)
Background::from(path)
} else { } else {
Background::default() Background::default()
} }
@ -365,46 +364,46 @@ impl Image {
} }
} }
fn build_image_bg( // fn build_image_bg(
atom: &Value, // atom: &Value,
image_map: &mut HashMap<String, String>, // image_map: &mut HashMap<String, String>,
map_index: usize, // map_index: usize,
) { // ) {
// This needs to be the cons that contains (image . ...) // // This needs to be the cons that contains (image . ...)
// the image is a symbol and the rest are keywords and other maps // // the image is a symbol and the rest are keywords and other maps
if atom.is_symbol() { // if atom.is_symbol() {
// We shouldn't get a symbol // // We shouldn't get a symbol
return; // return;
} // }
for atom in // for atom in
atom.list_iter().unwrap().map(|a| a.as_cons().unwrap()) // atom.list_iter().unwrap().map(|a| a.as_cons().unwrap())
{ // {
if atom.car() == &Value::Symbol("image".into()) { // if atom.car() == &Value::Symbol("image".into()) {
build_image_bg(atom.cdr(), image_map, map_index); // build_image_bg(atom.cdr(), image_map, map_index);
} else { // } else {
let atom = atom.car(); // let atom = atom.car();
match atom { // match atom {
Value::Keyword(keyword) => { // Value::Keyword(keyword) => {
image_map.insert(keyword.to_string(), "".into()); // image_map.insert(keyword.to_string(), "".into());
build_image_bg(atom, image_map, map_index); // build_image_bg(atom, image_map, map_index);
} // }
Value::Symbol(symbol) => { // Value::Symbol(symbol) => {
// let mut key; // // let mut key;
// let image_map = image_map // // let image_map = image_map
// .iter_mut() // // .iter_mut()
// .enumerate() // // .enumerate()
// .filter(|(i, e)| i == &map_index) // // .filter(|(i, e)| i == &map_index)
// .map(|(i, (k, v))| v.push_str(symbol)) // // .map(|(i, (k, v))| v.push_str(symbol))
// .collect(); // // .collect();
build_image_bg(atom, image_map, map_index); // build_image_bg(atom, image_map, map_index);
} // }
Value::String(string) => {} // Value::String(string) => {}
_ => {} // _ => {}
} // }
} // }
} // }
} // }
// fn build_slide(exp: Value) -> Result<Slide> { // fn build_slide(exp: Value) -> Result<Slide> {
// let mut slide_builder = SlideBuilder::new(); // let mut slide_builder = SlideBuilder::new();
@ -426,57 +425,57 @@ fn build_image_bg(
// todo!() // todo!()
// } // }
fn build_slides( // fn build_slides(
cons: &lexpr::Cons, // cons: &lexpr::Cons,
mut current_symbol: Symbol, // mut current_symbol: Symbol,
mut slide_builder: SlideBuilder, // mut slide_builder: SlideBuilder,
) -> SlideBuilder { // ) -> SlideBuilder {
for value in cons.list_iter() { // for value in cons.list_iter() {
dbg!(&current_symbol); // dbg!(&current_symbol);
match value { // match value {
Value::Cons(v) => { // Value::Cons(v) => {
slide_builder = build_slides( // slide_builder = build_slides(
&v, // &v,
current_symbol.clone(), // current_symbol.clone(),
slide_builder, // slide_builder,
); // );
} // }
Value::Nil => { // Value::Nil => {
dbg!(Value::Nil); // dbg!(Value::Nil);
} // }
Value::Bool(boolean) => { // Value::Bool(boolean) => {
dbg!(boolean); // dbg!(boolean);
} // }
Value::Number(number) => { // Value::Number(number) => {
dbg!(number); // dbg!(number);
} // }
Value::String(string) => { // Value::String(string) => {
dbg!(string); // dbg!(string);
} // }
Value::Symbol(symbol) => { // Value::Symbol(symbol) => {
dbg!(symbol); // dbg!(symbol);
current_symbol = // current_symbol =
Symbol::from_str(symbol).unwrap_or_default(); // Symbol::from_str(symbol).unwrap_or_default();
} // }
Value::Keyword(keyword) => { // Value::Keyword(keyword) => {
dbg!(keyword); // dbg!(keyword);
} // }
Value::Null => { // Value::Null => {
dbg!("null"); // dbg!("null");
} // }
Value::Char(c) => { // Value::Char(c) => {
dbg!(c); // dbg!(c);
} // }
Value::Bytes(b) => { // Value::Bytes(b) => {
dbg!(b); // dbg!(b);
} // }
Value::Vector(v) => { // Value::Vector(v) => {
dbg!(v); // dbg!(v);
} // }
} // }
} // }
slide_builder // slide_builder
} // }
#[cfg(test)] #[cfg(test)]
mod test { mod test {

View file

@ -84,10 +84,12 @@ struct App {
impl Default for App { impl Default for App {
fn default() -> Self { fn default() -> Self {
let initial_slide = SlideBuilder::new() let initial_slide = SlideBuilder::new()
.background(PathBuf::from( .background(
"/home/chris/vids/test/chosensmol.mp4", Background::try_from(
)) "/home/chris/vids/test/chosensmol.mp4",
.expect("oops video") )
.unwrap(),
)
.text("Hello") .text("Hello")
.build() .build()
.expect("oops slide"); .expect("oops slide");
@ -144,13 +146,11 @@ impl cosmic::Application for App {
let initial_slide = SlideBuilder::new() let initial_slide = SlideBuilder::new()
.background( .background(
PathBuf::from( Background::try_from(
"/home/chris/vids/test/camprules2024.mp4", "/home/chris/vids/test/camprules2024.mp4",
) )
.canonicalize()
.unwrap(), .unwrap(),
) )
.expect("oops video")
.text("") .text("")
.font("Quicksand") .font("Quicksand")
.font_size(50) .font_size(50)
@ -163,11 +163,9 @@ impl cosmic::Application for App {
let second_slide = SlideBuilder::new() let second_slide = SlideBuilder::new()
.background( .background(
PathBuf::from("/home/chris/pics/frodo.jpg") Background::try_from("/home/chris/pics/frodo.jpg")
.canonicalize()
.unwrap(), .unwrap(),
) )
.expect("oops video")
.text("Hello") .text("Hello")
.font("Quicksand") .font("Quicksand")
.font_size(50) .font_size(50)
@ -180,11 +178,9 @@ impl cosmic::Application for App {
let tetrary_slide = SlideBuilder::new() let tetrary_slide = SlideBuilder::new()
.background( .background(
PathBuf::from("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad_x16_drawing.png") Background::try_from("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad_x16_drawing.png")
.canonicalize()
.unwrap(), .unwrap(),
) )
.expect("oops video")
.text("Hello") .text("Hello")
.font("Quicksand") .font("Quicksand")
.font_size(50) .font_size(50)
@ -583,8 +579,10 @@ where
fn test_slide<'a>() -> Element<'a, Message> { fn test_slide<'a>() -> Element<'a, Message> {
if let Ok(slide) = SlideBuilder::new() if let Ok(slide) = SlideBuilder::new()
.background(PathBuf::from("/home/chris/pics/frodo.jpg")) .background(
.unwrap() Background::try_from("/home/chris/pics/frodo.jpg")
.unwrap(),
)
.text("This is a frodo") .text("This is a frodo")
.text_alignment(TextAlignment::TopCenter) .text_alignment(TextAlignment::TopCenter)
.font_size(50) .font_size(50)