Compare commits

...

2 commits

Author SHA1 Message Date
_
b320605f26 patch Campfire events with no location 2025-09-11 03:35:59 +00:00
_
9dba0779eb wip: struggling with the feed page a bit 2025-09-11 03:25:58 +00:00
5 changed files with 26 additions and 15 deletions

View file

@ -346,6 +346,7 @@ fn main_debug_rss(cli: CliDebugRss) -> Result<()> {
println!("{}", item.channel_title); println!("{}", item.channel_title);
println!("{}", item.inner.title.as_ref().unwrap()); println!("{}", item.inner.title.as_ref().unwrap());
println!("{}", item.date.to_rfc3339()); println!("{}", item.date.to_rfc3339());
println!("{}", item.inner.link.as_ref().unwrap());
println!(); println!();
} }

View file

@ -58,6 +58,14 @@ impl Config {
} }
} }
fn day_link(date: chrono::NaiveDate) -> maud::PreEscaped<String> {
let date_s = date.format("%-d %A");
let id = date.format("%F");
maud::html! {
h3 id=(id) { (date_s) " " a href=(format!("#{id}")) title=(format!("Permalink to {date_s}")) {"🔗"} }
}
}
fn calendar_link(calendar_ui: &crate::CalendarUi) -> maud::PreEscaped<String> { fn calendar_link(calendar_ui: &crate::CalendarUi) -> maud::PreEscaped<String> {
if let Some(html_url) = &calendar_ui.html_url { if let Some(html_url) = &calendar_ui.html_url {
maud::html! { a href=(html_url) { (calendar_ui.short_name) } } maud::html! { a href=(html_url) { (calendar_ui.short_name) } }
@ -110,7 +118,7 @@ fn calendars_page(upstreams: &[crate::CalendarUi], now: DateTime<chrono_tz::Tz>)
.into_string() .into_string()
} }
pub(crate) fn feed_page(feed_items: &[crate::FeedItem], now: DateTime<chrono_tz::Tz>) -> String { pub(crate) fn feed_page(_feed_items: &[crate::FeedItem], _now: DateTime<chrono_tz::Tz>) -> String {
todo!() todo!()
} }
@ -162,10 +170,8 @@ fn index_page(
p class="past"{ s { (date.format("%-d %A")) } } p class="past"{ s { (date.format("%-d %A")) } }
}); });
} else { } else {
let date_s = date.format("%-d %A");
let id = date.format("%F");
html_list.push(maud::html! { html_list.push(maud::html! {
h3 id=(id) { (date_s) " " a href=(format!("#{id}")) title=(format!("Permalink to {date_s}")) {"🔗"} } (day_link(date))
hr{} hr{}
}); });
} }

View file

@ -27,7 +27,8 @@ struct Event {
_end_time: Option<String>, _end_time: Option<String>,
#[serde(alias = "eventName")] #[serde(alias = "eventName")]
event_name: String, event_name: String,
location: String, // Seen in test data where this can be missing
location: Option<String>,
#[serde(alias = "Id")] #[serde(alias = "Id")]
id: String, id: String,
#[serde(alias = "startDate")] #[serde(alias = "startDate")]
@ -95,7 +96,7 @@ impl Calendar {
Some(Ok(EventInstance { Some(Ok(EventInstance {
calendar_ui: self.config.ui.clone(), calendar_ui: self.config.ui.clone(),
dtstart, dtstart,
location: Some(ev.location.clone()), location: ev.location.clone(),
recurrence_id: None, recurrence_id: None,
summary: Some(ev.event_name.clone()), summary: Some(ev.event_name.clone()),
uid: Some(ev.id.clone()), uid: Some(ev.id.clone()),
@ -111,9 +112,10 @@ impl Calendar {
} }
pub(crate) fn read_from_config(config: Config) -> Result<Self> { pub(crate) fn read_from_config(config: Config) -> Result<Self> {
let path = &config.dl.file_path; let path = config.dl.file_path.clone();
let s = std::fs::read_to_string(path).with_context(|| format!("Couldn't read {path:?}"))?; let s =
Self::read_from_str(config, &s) std::fs::read_to_string(&path).with_context(|| format!("Couldn't read {path:?}"))?;
Self::read_from_str(config, &s).with_context(|| format!("Couldn't parse {path:?}"))
} }
} }

View file

@ -95,9 +95,10 @@ impl Calendar {
} }
pub(crate) fn read_from_config(config: Config) -> Result<Self> { pub(crate) fn read_from_config(config: Config) -> Result<Self> {
let path = &config.dl.file_path; let path = config.dl.file_path.clone();
let s = std::fs::read_to_string(path).with_context(|| format!("Couldn't read {path:?}"))?; let s =
Self::read_from_str(config, &s) std::fs::read_to_string(&path).with_context(|| format!("Couldn't read {path:?}"))?;
Self::read_from_str(config, &s).with_context(|| format!("Couldn't parse {path:?}"))
} }
} }

View file

@ -267,8 +267,9 @@ impl Calendar {
} }
pub(crate) fn read_from_config(config: Config) -> Result<Self> { pub(crate) fn read_from_config(config: Config) -> Result<Self> {
let path = &config.dl.file_path; let path = config.dl.file_path.clone();
let s = std::fs::read_to_string(path).with_context(|| format!("Couldn't read {path:?}"))?; let s =
Self::read_from_str(config, &s) std::fs::read_to_string(&path).with_context(|| format!("Couldn't read {path:?}"))?;
Self::read_from_str(config, &s).with_context(|| format!("Couldn't parse {path:?}"))
} }
} }