diff --git a/Cargo.toml b/Cargo.toml index 09b6b0e..21ec1f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chrono = "0.4.39" +chrono = { version = "0.4.39", features = ["serde"] } clap = { version = "4.5.28", features = ["derive"] } -leptos = { version = "0.7.5", features = ["csr"] } +leptos = { version = "0.7.5", features = ["ssr"] } +leptos_axum = "0.7.5" console_error_panic_hook = "0.1.7" +serde = { version = "1.0", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 74dc6dd..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::session_date_calculator::{Day, NthWeekday}; -use chrono::Weekday; -use clap::Parser; - -pub mod session_date_calculator; - -#[derive(Debug, Parser)] -pub struct StartArgs { - /// on which days of the month there are sessions - #[arg(long = "sessions", num_args = 1..)] - pub session_days: Vec -} - -pub fn localize_day(day: &Day) -> String { - format!( - "{}, {}", - match day.weekday { - Weekday::Mon => "Montag", - Weekday::Tue => "Dienstag", - Weekday::Wed => "Mittwoch", - Weekday::Thu => "Donnerstag", - Weekday::Fri => "Freitag", - Weekday::Sat => "Samstag", - Weekday::Sun => "Sonntag", - }, - day.date.format("%d.%m.%Y") - ) -} diff --git a/src/main.rs b/src/main.rs index 58cb77a..2681563 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,40 @@ -mod webpage; +mod ui; +mod session_date_calculator; +use crate::session_date_calculator::{Day, NthWeekday}; +use chrono::Weekday; +use clap::Parser; use leptos::prelude::*; -fn main() { - console_error_panic_hook::set_once(); - - mount_to_body(webpage::App); +#[derive(Debug, Clone, Parser)] +struct AppArgs { + /// On which days of the month there are sessions + #[arg(long = "sessions", num_args = 1..)] + session_days: Vec, + /// The text to show next to upcoming band sessions + #[arg(long)] + motd: String, } + +fn main() { + let app_args = AppArgs::parse(); + + console_error_panic_hook::set_once(); + //TODO serving and shit +} + +pub fn localize_day(day: &Day) -> String { + format!( + "{}, {}", + match day.weekday { + Weekday::Mon => "Montag", + Weekday::Tue => "Dienstag", + Weekday::Wed => "Mittwoch", + Weekday::Thu => "Donnerstag", + Weekday::Fri => "Freitag", + Weekday::Sat => "Samstag", + Weekday::Sun => "Sonntag", + }, + day.date.format("%d.%m.%Y") + ) +} \ No newline at end of file diff --git a/src/session_date_calculator.rs b/src/session_date_calculator.rs index 68015a5..01f1b7f 100644 --- a/src/session_date_calculator.rs +++ b/src/session_date_calculator.rs @@ -1,10 +1,11 @@ use chrono::{Datelike, Days, Local, NaiveDate, ParseWeekdayError, Weekday}; +use serde::{Deserialize, Serialize}; use std::error::Error; use std::fmt::{Display, Formatter}; use std::num::ParseIntError; use std::str::FromStr; -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] pub struct NthWeekday { pub n: u8, pub weekday: Weekday, diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..4bba0f7 --- /dev/null +++ b/src/ui.rs @@ -0,0 +1,17 @@ +use crate::AppArgs; +use leptos::prelude::*; + +#[component] +pub fn App(app_args: AppArgs) -> impl IntoView { + let (count, set_count) = signal(0); + + view! { +
+
+

"Anstehende Proben Termine"

+

{app_args.motd}

+ +
+
+ } +} diff --git a/src/webpage.rs b/src/webpage.rs deleted file mode 100644 index b5ef2a8..0000000 --- a/src/webpage.rs +++ /dev/null @@ -1,11 +0,0 @@ -use leptos::prelude::*; - -#[component] -pub fn App() -> impl IntoView { - let (count, set_count) = signal(0); - - view! { - -

"Double count: " {move || count.get() * 2}

- } -}