From 354d74d4d9d5f370f50f69a119ea96fc7f4c6da5 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 26 May 2021 20:46:26 +0200 Subject: [PATCH] add recurrence flag --- libticker/src/model.rs | 2 ++ libticker/src/schema.rs | 2 ++ ticker-serve/src/index.rs | 16 ++++++++++++---- ticker-serve/src/main.rs | 2 +- ticker-serve/static/style.css | 13 ++++++++++--- ticker-update/src/main.rs | 7 ++++--- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/libticker/src/model.rs b/libticker/src/model.rs index 556fddd..f408c37 100644 --- a/libticker/src/model.rs +++ b/libticker/src/model.rs @@ -33,4 +33,6 @@ pub struct Event { pub summary: String, pub location: Option, pub url: Option, + + pub recurrence: bool, } diff --git a/libticker/src/schema.rs b/libticker/src/schema.rs index 3048735..8b0a426 100644 --- a/libticker/src/schema.rs +++ b/libticker/src/schema.rs @@ -22,5 +22,7 @@ table! { summary -> VarChar, location -> Nullable, url -> Nullable, + + recurrence -> Bool, } } diff --git a/ticker-serve/src/index.rs b/ticker-serve/src/index.rs index 1a67aae..b36821f 100644 --- a/ticker-serve/src/index.rs +++ b/ticker-serve/src/index.rs @@ -103,10 +103,18 @@ fn render_index(app_state: &AppState) -> String {
-

- { text!("{}", &e.dtstart.format("%H:%M")) } +

+ { if e.recurrence { + html!("â­¯") + } else { + html!(" ") + } } + + { text!("{}", &e.dtstart.format("%H:%M")) } +

{ match &e.url { None => html!( diff --git a/ticker-serve/src/main.rs b/ticker-serve/src/main.rs index c75596c..f7fea23 100644 --- a/ticker-serve/src/main.rs +++ b/ticker-serve/src/main.rs @@ -1,4 +1,4 @@ -#![recursion_limit="1024"] +#![recursion_limit="2048"] #[macro_use] extern crate gotham_derive; diff --git a/ticker-serve/static/style.css b/ticker-serve/static/style.css index 9913836..47c8926 100644 --- a/ticker-serve/static/style.css +++ b/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; diff --git a/ticker-update/src/main.rs b/ticker-update/src/main.rs index 26e6e09..cd24d53 100644 --- a/ticker-update/src/main.rs +++ b/ticker-update/src/main.rs @@ -49,7 +49,7 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec { 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 { summary: summary.to_owned(), location: location.clone(), url: url.clone(), + recurrence, } }; @@ -78,11 +79,11 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec { .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)], } }