From 2695d1b70f5f1f4a91fdde86029e12e55dfad13d Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 15 Jan 2025 10:59:18 -0600 Subject: [PATCH] adding text items to slides --- src/core/service_items.rs | 102 ++++++++++++++++++++++++-------------- src/core/slide.rs | 2 +- 2 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/core/service_items.rs b/src/core/service_items.rs index 1183a92..7e8d9dc 100644 --- a/src/core/service_items.rs +++ b/src/core/service_items.rs @@ -76,47 +76,73 @@ impl From<&Value> for ServiceItem { _ => false, }) .map_or_else(|| 1, |pos| pos + 1); - if let Some(background) = list.get(background_pos) - { - match background { - Value::List(item) => match &item[0] { - Value::Symbol(Symbol(s)) - if s == "image" => - { - Self::from(&Image::from( - background, - )) - } - Value::Symbol(Symbol(s)) - if s == "video" => - { - Self::from(&Video::from( - background, - )) - } - Value::Symbol(Symbol(s)) - if s == "presentation" => - { - Self::from(&Presentation::from( - background, - )) - } - _ => todo!(), - }, - _ => { - error!( - "There is no background here: {:?}", - background - ); - ServiceItem::default() + if let Some(content) = + list.iter().position(|v| match v { + Value::List(list) + if list.iter().next() + == Some(&Value::Symbol( + Symbol("text".into()), + )) => + { + list.iter().next().is_some() } + _ => false, + }) + { + let slide = Slide::from(value); + let title = slide.text(); + Self { + id: 0, + title, + database_id: 0, + kind: ServiceItemKind::Content(slide), } } else { - error!( - "There is no background here: {:?}", - background_pos - ); - ServiceItem::default() + if let Some(background) = + list.get(background_pos) + { + match background { + Value::List(item) => match &item[0] { + Value::Symbol(Symbol(s)) + if s == "image" => + { + Self::from(&Image::from( + background, + )) + } + Value::Symbol(Symbol(s)) + if s == "video" => + { + Self::from(&Video::from( + background, + )) + } + Value::Symbol(Symbol(s)) + if s == "presentation" => + { + Self::from( + &Presentation::from( + background, + ), + ) + } + _ => todo!(), + }, + _ => { + error!( + "There is no background here: {:?}", + background + ); + ServiceItem::default() + } + } + } else { + error!( + "There is no background here: {:?}", + background_pos + ); + ServiceItem::default() + } } } Value::Symbol(Symbol(s)) if s == "song" => { diff --git a/src/core/slide.rs b/src/core/slide.rs index 5511105..b3810b7 100644 --- a/src/core/slide.rs +++ b/src/core/slide.rs @@ -5,7 +5,7 @@ use std::{ fmt::Display, path::{Path, PathBuf}, }; -use tracing::error; +use tracing::{debug, error}; use super::songs::Song;