use details tag to hide details

This commit is contained in:
_ 2025-08-13 05:42:01 +00:00
parent 1717b3ab70
commit bf6e6fab0b

View file

@ -34,6 +34,9 @@ struct ConfigOutput {
/// Used as the OpenGraph description in meta tags /// Used as the OpenGraph description in meta tags
description: String, description: String,
/// Hide all these UIDs from the final output
hide_uids: BTreeSet<String>,
/// Timezone to use for output (e.g. "Antarctica/South_Pole") /// Timezone to use for output (e.g. "Antarctica/South_Pole")
/// ///
/// <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> /// <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
@ -401,12 +404,21 @@ fn read_data_from_disk(config: &Config) -> Result<Data> {
Ok(data) Ok(data)
} }
fn process_data(data: &Data, now: DateTime<chrono_tz::Tz>) -> Result<Vec<EventWithUrl<'_>>> { fn process_data<'a>(
data: &'a Data,
hide_uids: &'a BTreeSet<String>,
now: DateTime<chrono_tz::Tz>,
) -> Result<Vec<EventWithUrl<'a>>> {
let params = Parameters::new(now)?; let params = Parameters::new(now)?;
let mut instances = vec![]; let mut instances = vec![];
for (ical, config) in &data.icals { for (ical, config) in &data.icals {
for ei in ical.event_instances(&params)? { for ei in ical.event_instances(&params)? {
if let Some(uid) = ei.ev.get_uid()
&& hide_uids.contains(uid)
{
continue;
}
let ei = EventWithUrl::from_ei(config, ei)?; let ei = EventWithUrl::from_ei(config, ei)?;
instances.push(ei); instances.push(ei);
} }
@ -505,8 +517,12 @@ fn output_html(
maud::html! { (ei.calendar.short_name)} maud::html! { (ei.calendar.short_name)}
}; };
// This is where the main stuff happens
tracing::debug!(uid = ei.ev.get_uid(), summary = ei.ev.get_summary());
day_list.push(maud::html! { day_list.push(maud::html! {
li { p { (time) " - " (summary) } li { details {
summary { (time) " - " (summary) }
ul { ul {
li { (calendar_link) " calendar" } li { (calendar_link) " calendar" }
@if let Some(location) = location { @if let Some(location) = location {
@ -514,7 +530,7 @@ fn output_html(
} }
} }
} }
}); } });
} }
} }
// FIXME: De-dupe // FIXME: De-dupe
@ -623,7 +639,7 @@ async fn do_everything(cli: &CliAuto) -> Result<()> {
let tz = &config.output.timezone; let tz = &config.output.timezone;
let now = Utc::now().with_timezone(tz); let now = Utc::now().with_timezone(tz);
let instances = process_data(&data, now)?; let instances = process_data(&data, &config.output.hide_uids, now)?;
output_html(&config.output, &instances, now)?; output_html(&config.output, &instances, now)?;
Ok(()) Ok(())
} }
@ -655,7 +671,7 @@ fn main_ics_debug(cli: CliIcsDebug) -> Result<()> {
let tz = &config.output.timezone; let tz = &config.output.timezone;
let now = Utc::now().with_timezone(tz); let now = Utc::now().with_timezone(tz);
let instances = process_data(&data, now)?; let instances = process_data(&data, &config.output.hide_uids, now)?;
output_html(&config.output, &instances, now)?; output_html(&config.output, &instances, now)?;
Ok(()) Ok(())