diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 8ce01a4..602d3c8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -21,5 +21,6 @@ fn main() { #[tauri::command] fn test(message: metadata::Metadata) -> String { + message.save_to_xml("/home/neshura/Repositories/comicinfo-editor-v2/ComicInfo.xml"); format!("Series: '{}' | Title: '{}'", message.series_title, message.title) } diff --git a/src-tauri/src/metadata/mod.rs b/src-tauri/src/metadata/mod.rs index 094cd04..b3d87e0 100644 --- a/src-tauri/src/metadata/mod.rs +++ b/src-tauri/src/metadata/mod.rs @@ -16,18 +16,16 @@ pub(crate) struct Metadata { pub(crate) volume_number: i16, - pub(crate) summary: Option, + pub(crate) summary: String, - pub(crate) year: i16, - pub(crate) month: i8, - pub(crate) day: i8, + pub(crate) release_date: ReleaseDate, - pub(crate) writer: Option, - pub(crate) translator: Option, - pub(crate) letterer: Option, - pub(crate) editor: Option, + pub(crate) writer: String, + pub(crate) translator: String, + pub(crate) letterer: String, + pub(crate) editor: String, - pub(crate) publisher: Option, + pub(crate) publisher: String, pub(crate) genre: String, @@ -50,15 +48,17 @@ impl Default for Metadata { chapter_number: 0, total_chapter_count: -1, volume_number: 1, - summary: None, - year: -1, - month: -1, - day: -1, - writer: None, - letterer: None, - editor: None, - translator: None, - publisher: None, + summary: "".into(), + release_date: ReleaseDate { + year: -1, + month: -1, + day: -1, + }, + writer: "".into(), + letterer: "".into(), + editor: "".into(), + translator: "".into(), + publisher: "".into(), genre: "".into(), tags: vec![], page_count: 0, @@ -74,37 +74,38 @@ impl Serialize for Metadata { let mut out_state = serializer.serialize_struct("Metadata", 22)?; out_state.serialize_field("@xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")?; out_state.serialize_field("@xsi:noNamespaceSchemaLocation", "ComicInfo.xsd")?; - out_state.serialize_field("Title", &self.title)?; out_state.serialize_field("Series", &self.series_title)?; + out_state.serialize_field("Title", &self.title)?; + out_state.serialize_field("Number", &self.chapter_number)?; out_state.serialize_field("Count", &self.total_chapter_count)?; out_state.serialize_field("Volume", &self.volume_number)?; - if self.summary.is_some() { + if self.summary != "" { out_state.serialize_field("Summary", &self.summary)?; } - out_state.serialize_field("Year", &self.year)?; - out_state.serialize_field("Month", &self.month)?; - out_state.serialize_field("Day", &self.day)?; + out_state.serialize_field("Year", &self.release_date.year)?; + out_state.serialize_field("Month", &self.release_date.month)?; + out_state.serialize_field("Day", &self.release_date.day)?; - if self.writer.is_some() { + if self.writer != "" { out_state.serialize_field("Writer", &self.writer)?; } - if self.letterer.is_some() { + if self.letterer != "" { out_state.serialize_field("Letterer", &self.letterer)?; } - if self.editor.is_some() { + if self.editor != "" { out_state.serialize_field("Editor", &self.editor)?; } - if self.translator.is_some() { + if self.translator != "" { out_state.serialize_field("Translator", &self.translator)?; } - if self.publisher.is_some() { + if self.publisher != "" { out_state.serialize_field("Publisher", &self.publisher)?; } @@ -142,6 +143,13 @@ impl Metadata { } } +#[derive(Debug, Deserialize, PartialEq, Clone)] +pub(crate) struct ReleaseDate { + year: i16, + month: i8, + day: i8 +} + /*#[derive(strum_macros::Display, Debug, PartialEq, strum_macros::EnumIter, Serialize, Deserialize, Clone)] #[serde(tag = "AgeRating")] pub(crate) enum AgeRating { diff --git a/src/lib/Dropdown/Dropdown.svelte b/src/lib/Dropdown/Dropdown.svelte new file mode 100644 index 0000000..e69de29