add recurrence flag

This commit is contained in:
Astro 2021-05-26 20:46:26 +02:00
parent 351f0e057b
commit 354d74d4d9
6 changed files with 31 additions and 11 deletions

View File

@ -33,4 +33,6 @@ pub struct Event {
pub summary: String, pub summary: String,
pub location: Option<String>, pub location: Option<String>,
pub url: Option<String>, pub url: Option<String>,
pub recurrence: bool,
} }

View File

@ -22,5 +22,7 @@ table! {
summary -> VarChar, summary -> VarChar,
location -> Nullable<VarChar>, location -> Nullable<VarChar>,
url -> Nullable<VarChar>, url -> Nullable<VarChar>,
recurrence -> Bool,
} }
} }

View File

@ -103,10 +103,18 @@ fn render_index(app_state: &AppState) -> String {
<article class="event" <article class="event"
style={ format!("border-left: 1.5rem solid {}", &config.calendars.get(&e.calendar).map(|o| &o.color[..]).unwrap_or("white")) } style={ format!("border-left: 1.5rem solid {}", &config.calendars.get(&e.calendar).map(|o| &o.color[..]).unwrap_or("white")) }
> >
<p class="dtstart" <p class="time"
title={ format!("{}", e.dtstart.format("%c")) } >
> { if e.recurrence {
{ text!("{}", &e.dtstart.format("%H:%M")) } html!(<span class="recurrence" title="Regelmässige Veranstaltung">""</span>)
} else {
html!(<span class="recurrence">" "</span>)
} }
<span class="dtstart"
title={ format!("{}", e.dtstart.format("%c")) }
>
{ text!("{}", &e.dtstart.format("%H:%M")) }
</span>
</p> </p>
{ match &e.url { { match &e.url {
None => html!( None => html!(

View File

@ -1,4 +1,4 @@
#![recursion_limit="1024"] #![recursion_limit="2048"]
#[macro_use] #[macro_use]
extern crate gotham_derive; extern crate gotham_derive;

View File

@ -51,7 +51,7 @@ article {
padding: 0.8rem 0 0.8rem 1rem; padding: 0.8rem 0 0.8rem 1rem;
clear: both; clear: both;
line-height: 1.3rem; line-height: 1.3rem;
/*box-shadow: 0 -0.3rem 0.5rem 0.5rem #373737;*/ min-height: 3.5rem;
} }
article p { article p {
@ -71,15 +71,22 @@ h3 a {
color: #222; color: #222;
} }
.dtstart { .time {
position: absolute; position: absolute;
transform: translate(-2.5rem, 2.5rem) rotate(270deg); transform: translate(-2.5rem, 3.8rem) rotate(270deg);
width: 3.5rem;
text-align: right;
transform-origin: top left; transform-origin: top left;
color: #F7F7F7; color: #F7F7F7;
font-weight: 500; font-weight: 500;
font-size: 85%; font-size: 85%;
line-height: 1.5rem; line-height: 1.5rem;
} }
.recurrence {
color: #D7D7D7;
font-weight: bold;
padding-right: 0.8em;
}
.location { .location {
line-height: 1.1em; line-height: 1.1em;
min-height: 1.1em; min-height: 1.1em;

View File

@ -49,7 +49,7 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec<Event> {
let location = obj.get("LOCATION"); let location = obj.get("LOCATION");
let url = obj.get("URL"); let url = obj.get("URL");
let generate_event = |dtstart| { let generate_event = |dtstart, recurrence| {
let id = format!("{}{}{}", uid, dtstart, dtstamp); let id = format!("{}{}{}", uid, dtstart, dtstamp);
Event { Event {
calendar: calendar.clone(), calendar: calendar.clone(),
@ -59,6 +59,7 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec<Event> {
summary: summary.to_owned(), summary: summary.to_owned(),
location: location.clone(), location: location.clone(),
url: url.clone(), url: url.clone(),
recurrence,
} }
}; };
@ -78,11 +79,11 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec<Event> {
.skip_while(|d| *d < start) .skip_while(|d| *d < start)
.take_while(|d| *d <= end) .take_while(|d| *d <= end)
.map(|dtstart| dtstart.naive_utc()) .map(|dtstart| dtstart.naive_utc())
.map(generate_event) .map(|dtstart| generate_event(dtstart, true))
.collect() .collect()
} }
None => None =>
vec![generate_event(dtstart)], vec![generate_event(dtstart, false)],
} }
} }