serve: colorize sat+sun
This commit is contained in:
parent
b471b76bec
commit
72d4a34015
|
@ -1,3 +1,4 @@
|
||||||
|
use std::convert::TryInto;
|
||||||
use gotham::{
|
use gotham::{
|
||||||
helpers::http::response::create_response,
|
helpers::http::response::create_response,
|
||||||
hyper::{Body, Response},
|
hyper::{Body, Response},
|
||||||
|
@ -6,7 +7,7 @@ use gotham::{
|
||||||
use http::status::StatusCode;
|
use http::status::StatusCode;
|
||||||
use mime::TEXT_HTML;
|
use mime::TEXT_HTML;
|
||||||
|
|
||||||
use typed_html::{html, text, dom::DOMTree};
|
use typed_html::{html, text, dom::DOMTree, types::{Class, SpacedSet}};
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use chrono::{offset::Local, Datelike, NaiveDate};
|
use chrono::{offset::Local, Datelike, NaiveDate};
|
||||||
|
|
||||||
|
@ -73,47 +74,52 @@ fn render_index(app_state: &AppState) -> String {
|
||||||
<link rel="stylesheet" title="Style" type="text/css" href="static/style.css"/>
|
<link rel="stylesheet" title="Style" type="text/css" href="static/style.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{ days.iter().map(|day| html!(<div>
|
{ days.iter().map(|day| {
|
||||||
<h2>
|
let mut day_class: SpacedSet<Class> = ["date"].try_into().unwrap();
|
||||||
<span class="date">
|
day_class.add(&format!("wd{}", day.date.weekday().num_days_from_monday())[..]);
|
||||||
<span class="day">
|
html!(
|
||||||
{ text!("{}", day.date.day()) }
|
<div>
|
||||||
</span>
|
<h2>
|
||||||
<span class="month">
|
<span class={ day_class }>
|
||||||
{ text!("{}", &config.months[day.date.month0() as usize]) }
|
<span class="day">
|
||||||
</span>
|
{ text!("{}", day.date.day()) }
|
||||||
</span>
|
</span>
|
||||||
<span class="weekday">
|
<span class="month">
|
||||||
{ text!("{}", &config.weekdays[day.date.weekday().num_days_from_monday() as usize]) }
|
{ text!("{}", &config.months[day.date.month0() as usize]) }
|
||||||
</span>
|
</span>
|
||||||
</h2>
|
</span>
|
||||||
|
<span class="weekday">
|
||||||
|
{ text!("{}", &config.weekdays[day.date.weekday().num_days_from_monday() as usize]) }
|
||||||
|
</span>
|
||||||
|
</h2>
|
||||||
|
|
||||||
{ day.events.iter().map(|e| html!(
|
{ day.events.iter().map(|e| html!(
|
||||||
<article class="event" style={ format!("border-left: 1.5rem solid {}", &config.calendars.get(&e.calendar).map(|o| &o.color[..]).unwrap_or("white")) }>
|
<article class="event" style={ format!("border-left: 1.5rem solid {}", &config.calendars.get(&e.calendar).map(|o| &o.color[..]).unwrap_or("white")) }>
|
||||||
{ match &e.url {
|
{ match &e.url {
|
||||||
None => html!(
|
None => html!(
|
||||||
<h3>{ text!("{}", &e.summary) }</h3>
|
<h3>{ text!("{}", &e.summary) }</h3>
|
||||||
),
|
),
|
||||||
Some(url) => html!(
|
Some(url) => html!(
|
||||||
<h3>
|
<h3>
|
||||||
<a href={ fix_url(url) }>
|
<a href={ fix_url(url) }>
|
||||||
{ text!("{}", &e.summary) }
|
{ text!("{}", &e.summary) }
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
),
|
),
|
||||||
} }
|
} }
|
||||||
|
|
||||||
<p class="dtstart" title={ format!("{}", e.dtstart.format("%c")) }>
|
<p class="dtstart" title={ format!("{}", e.dtstart.format("%c")) }>
|
||||||
{ text!("{}", &e.dtstart.format("%H:%S")) }
|
{ text!("{}", &e.dtstart.format("%H:%S")) }
|
||||||
</p>
|
</p>
|
||||||
{ e.location.as_ref().map(|location| html!(
|
{ e.location.as_ref().map(|location| html!(
|
||||||
<p class="location">
|
<p class="location">
|
||||||
{ text!("{}", location) }
|
{ text!("{}", location) }
|
||||||
</p>
|
</p>
|
||||||
)) }
|
)) }
|
||||||
</article>
|
</article>
|
||||||
)) }
|
)) }
|
||||||
</div>)) }
|
</div>)
|
||||||
|
}) }
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,6 +23,14 @@ h2 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 4rem;
|
width: 4rem;
|
||||||
}
|
}
|
||||||
|
/* saturday */
|
||||||
|
.date.wd5 {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
/* sunday */
|
||||||
|
.date.wd6 {
|
||||||
|
color: #d33;
|
||||||
|
}
|
||||||
.date .day {
|
.date .day {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
font-size: 140%;
|
font-size: 140%;
|
||||||
|
@ -40,7 +48,7 @@ article {
|
||||||
background-color: #f7f7f7;
|
background-color: #f7f7f7;
|
||||||
color: #222;
|
color: #222;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.5rem 0 0.5rem 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;*/
|
/*box-shadow: 0 -0.3rem 0.5rem 0.5rem #373737;*/
|
||||||
|
|
Loading…
Reference in New Issue