Browse Source

add recurrence flag

master
Astro 5 months ago
parent
commit
354d74d4d9
  1. 2
      libticker/src/model.rs
  2. 2
      libticker/src/schema.rs
  3. 16
      ticker-serve/src/index.rs
  4. 2
      ticker-serve/src/main.rs
  5. 13
      ticker-serve/static/style.css
  6. 7
      ticker-update/src/main.rs

2
libticker/src/model.rs

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

2
libticker/src/schema.rs

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

16
ticker-serve/src/index.rs

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

2
ticker-serve/src/main.rs

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

13
ticker-serve/static/style.css

@ -51,7 +51,7 @@ article {
padding: 0.8rem 0 0.8rem 1rem;
clear: both;
line-height: 1.3rem;
/*box-shadow: 0 -0.3rem 0.5rem 0.5rem #373737;*/
min-height: 3.5rem;
}
article p {
@ -71,15 +71,22 @@ h3 a {
color: #222;
}
.dtstart {
.time {
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;
color: #F7F7F7;
font-weight: 500;
font-size: 85%;
line-height: 1.5rem;
}
.recurrence {
color: #D7D7D7;
font-weight: bold;
padding-right: 0.8em;
}
.location {
line-height: 1.1em;
min-height: 1.1em;

7
ticker-update/src/main.rs

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

Loading…
Cancel
Save