moving the lisp presentation parsing to service_items

Since we need the nav_bar to have the ServiceItemModel, the
presentation needs to be a list of service items, not slides, each
service item will have a list of slides attached though.
This commit is contained in:
Chris Cochrun 2024-12-10 09:27:50 -06:00
parent 9eb5bec320
commit cb7fa372a9
9 changed files with 493 additions and 79 deletions

View file

@ -10,10 +10,11 @@ use sqlx::{
};
use tracing::{debug, error};
use crate::core::slide;
use crate::{core::slide, Slide, SlideBuilder};
use super::{
model::Model,
service_items::ServiceTrait,
slide::{Background, TextAlignment},
};
@ -34,6 +35,47 @@ pub struct Song {
pub font_size: Option<i32>,
}
impl ServiceTrait for Song {
fn title(&self) -> String {
self.title.clone()
}
fn id(&self) -> i32 {
self.id
}
fn to_slides(&self) -> Result<Vec<Slide>> {
let lyrics = self.get_lyrics()?;
let slides: Vec<Slide> = lyrics
.iter()
.map(|l| {
SlideBuilder::new()
.background(
self.background.clone().unwrap_or_default(),
)
.font(self.font.clone().unwrap_or_default())
.font_size(self.font_size.unwrap_or_default())
.text_alignment(
self.text_alignment.unwrap_or_default(),
)
.audio(self.audio.clone().unwrap_or_default())
.video_loop(true)
.video_start_time(0.0)
.video_end_time(0.0)
.text(l)
.build()
.unwrap_or_default()
})
.collect();
Ok(slides)
}
fn box_clone(&self) -> Box<dyn ServiceTrait> {
Box::new((*self).clone())
}
}
const VERSE_KEYWORDS: [&str; 24] = [
"Verse 1", "Verse 2", "Verse 3", "Verse 4", "Verse 5", "Verse 6",
"Verse 7", "Verse 8", "Chorus 1", "Chorus 2", "Chorus 3",