server: move calendar rendering to askama template
This commit is contained in:
parent
d16c221995
commit
5b48c5dbc3
@ -1091,6 +1091,18 @@ pub struct TlsReportTemplate<'a> {
|
||||
pub report: &'a FormattedTlsRpt,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "ical_summary.html")]
|
||||
pub struct IcalSummaryTemplate<'a> {
|
||||
pub summary: &'a str,
|
||||
pub local_fmt_start: &'a str,
|
||||
pub local_fmt_end: &'a str,
|
||||
pub organizer: &'a str,
|
||||
pub organizer_cn: &'a str,
|
||||
pub calendar_html: &'a str,
|
||||
pub description_paragraphs: &'a [String],
|
||||
}
|
||||
|
||||
// Add this helper function to parse the DMARC XML and summarize it.
|
||||
pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> {
|
||||
let feedback: Feedback = xml_from_str(xml)
|
||||
@ -1298,7 +1310,6 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
let mut parser = IcalParser::new(ical_data.as_bytes());
|
||||
while let Some(Ok(calendar)) = parser.next() {
|
||||
for event in calendar.events {
|
||||
let mut event_summary = String::new();
|
||||
let mut summary = None;
|
||||
let mut description = None;
|
||||
let mut dtstart = None;
|
||||
@ -1336,16 +1347,14 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
}
|
||||
|
||||
// Parse start/end as chrono DateTime
|
||||
let (start_dt, end_dt, local_fmt_start, local_fmt_end, event_days) =
|
||||
if let Some(dtstart) = dtstart {
|
||||
let (local_fmt_start, local_fmt_end, event_days) = if let Some(dtstart) = dtstart {
|
||||
let tz: Tz = tzid
|
||||
.as_deref()
|
||||
.unwrap_or("UTC")
|
||||
.parse()
|
||||
.unwrap_or(chrono_tz::UTC);
|
||||
let fallback = tz.from_utc_datetime(
|
||||
&chrono::NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
|
||||
);
|
||||
let fallback =
|
||||
tz.from_utc_datetime(&chrono::NaiveDateTime::from_timestamp_opt(0, 0).unwrap());
|
||||
let start = parse_ical_datetime_tz(dtstart, tz).unwrap_or(fallback);
|
||||
let end = dtend
|
||||
.and_then(|d| parse_ical_datetime_tz(d, tz))
|
||||
@ -1358,8 +1367,7 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
let mut d = start.date_naive();
|
||||
let mut end_d = end.date_naive();
|
||||
// Check for all-day event (DATE, not DATE-TIME)
|
||||
let allday =
|
||||
dtstart.len() == 8 && (dtend.map(|s| s.len() == 8).unwrap_or(false));
|
||||
let allday = dtstart.len() == 8 && (dtend.map(|s| s.len() == 8).unwrap_or(false));
|
||||
if allday {
|
||||
// DTEND is exclusive for all-day events
|
||||
if end_d > d {
|
||||
@ -1372,54 +1380,79 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
days.push(day_iter);
|
||||
day_iter = day_iter.succ_opt().unwrap();
|
||||
}
|
||||
#[cfg(test)]
|
||||
println!("DEBUG event_days: {:?}", days);
|
||||
(start, end, fmt_start, fmt_end, days)
|
||||
(fmt_start, fmt_end, days)
|
||||
} else {
|
||||
let tz = chrono_tz::UTC;
|
||||
let fallback = tz.from_utc_datetime(
|
||||
&chrono::NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
|
||||
);
|
||||
(fallback, fallback, String::new(), String::new(), vec![])
|
||||
(String::new(), String::new(), vec![])
|
||||
};
|
||||
|
||||
// Render a single merged calendar table for all spanned months
|
||||
let mut calendar_html = String::new();
|
||||
if !event_days.is_empty() {
|
||||
// Render calendar table HTML
|
||||
let calendar_html = if !event_days.is_empty() {
|
||||
render_merged_calendar_table(&event_days)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
// Description paragraphs
|
||||
let description_paragraphs: Vec<String> = if let Some(desc) = description {
|
||||
let desc = desc.replace("\\n", "\n");
|
||||
desc.lines()
|
||||
.map(|line| line.trim().to_string())
|
||||
.filter(|line| !line.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let summary_val = summary.unwrap_or("");
|
||||
let organizer_val = organizer.unwrap_or("");
|
||||
let organizer_cn_val = organizer_cn.unwrap_or("");
|
||||
let local_fmt_start_val = &local_fmt_start;
|
||||
let local_fmt_end_val = &local_fmt_end;
|
||||
let calendar_html_val = &calendar_html;
|
||||
let description_paragraphs_val = &description_paragraphs;
|
||||
let template = IcalSummaryTemplate {
|
||||
summary: summary_val,
|
||||
local_fmt_start: local_fmt_start_val,
|
||||
local_fmt_end: local_fmt_end_val,
|
||||
organizer: organizer_val,
|
||||
organizer_cn: organizer_cn_val,
|
||||
calendar_html: calendar_html_val,
|
||||
description_paragraphs: description_paragraphs_val,
|
||||
};
|
||||
summary_parts.push(template.render()?);
|
||||
}
|
||||
}
|
||||
Ok(summary_parts.join("<hr>"))
|
||||
}
|
||||
|
||||
fn render_merged_calendar_table(event_days: &[NaiveDate]) -> String {
|
||||
use chrono::Datelike;
|
||||
let first_event = event_days.first().unwrap();
|
||||
let last_event = event_days.last().unwrap();
|
||||
// First day of the first event's month
|
||||
let first_of_month =
|
||||
NaiveDate::from_ymd_opt(first_event.year(), first_event.month(), 1).unwrap();
|
||||
// Last day of the last event's month
|
||||
let last_of_month = {
|
||||
let next_month = if last_event.month() == 12 {
|
||||
NaiveDate::from_ymd_opt(last_event.year() + 1, 1, 1).unwrap()
|
||||
} else {
|
||||
NaiveDate::from_ymd_opt(last_event.year(), last_event.month() + 1, 1)
|
||||
.unwrap()
|
||||
NaiveDate::from_ymd_opt(last_event.year(), last_event.month() + 1, 1).unwrap()
|
||||
};
|
||||
next_month.pred_opt().unwrap()
|
||||
};
|
||||
// Find the first Sunday before or on the first day of the first event month
|
||||
let mut cal_start = first_of_month;
|
||||
while cal_start.weekday() != chrono::Weekday::Sun {
|
||||
cal_start = cal_start.pred_opt().unwrap();
|
||||
}
|
||||
// Find the last Saturday after or on the last day of the last event month
|
||||
let mut cal_end = last_of_month;
|
||||
while cal_end.weekday() != chrono::Weekday::Sat {
|
||||
cal_end = cal_end.succ_opt().unwrap();
|
||||
}
|
||||
// Collect all days in the calendar range
|
||||
let mut all_days = vec![];
|
||||
let mut d = cal_start;
|
||||
while d <= cal_end {
|
||||
all_days.push(d);
|
||||
d = d.succ_opt().unwrap();
|
||||
}
|
||||
// Table header: show month/year range
|
||||
let start_month = first_event.format("%B %Y");
|
||||
let end_month = last_event.format("%B %Y");
|
||||
let caption = if start_month.to_string() == end_month.to_string() {
|
||||
@ -1427,8 +1460,9 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
} else {
|
||||
format!("{} – {}", start_month, end_month)
|
||||
};
|
||||
let mut calendar_html = String::new();
|
||||
calendar_html.push_str(&format!(
|
||||
"<table class='ical-month' style='border-collapse:collapse; min-width:220px; background:#fff; box-shadow:0 2px 8px #bbb; font-size:14px; margin:0; float:right;'>"
|
||||
"<table class='ical-month' style='border-collapse:collapse; min-width:220px; background:#fff; box-shadow:0 2px 8px #bbb; font-size:14px; margin:0;'>"
|
||||
));
|
||||
calendar_html.push_str(&format!("<caption style='caption-side:top; text-align:center; font-weight:bold; font-size:16px; padding:8px 0;'>{}</caption>", caption));
|
||||
calendar_html.push_str("<thead><tr>");
|
||||
@ -1439,147 +1473,21 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
for week in all_days.chunks(7) {
|
||||
calendar_html.push_str("<tr>");
|
||||
for day in week {
|
||||
#[cfg(test)]
|
||||
println!("CAL DAY: {} is_event: {}", day, event_days.contains(day));
|
||||
let is_event = event_days.contains(day);
|
||||
let style = if is_event {
|
||||
"background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;"
|
||||
} else {
|
||||
"border:1px solid #eee; text-align:center;background:#f7f7f7;color:#bbb;"
|
||||
};
|
||||
calendar_html.push_str(&format!(
|
||||
"<td style='{}'>{}</td>",
|
||||
style,
|
||||
day.day()
|
||||
));
|
||||
calendar_html.push_str(&format!("<td style='{}'>{}</td>", style, day.day()));
|
||||
}
|
||||
calendar_html.push_str("</tr>");
|
||||
}
|
||||
calendar_html.push_str("</tbody></table>");
|
||||
}
|
||||
// Remove block-level summary wrapper, move its styles to the flex child
|
||||
let summary_inner = {
|
||||
let mut s = String::new();
|
||||
s.push_str("<div style='font-size:17px; font-weight:bold; margin-bottom:8px; color:#333;'><b>Summary:</b> ");
|
||||
if let Some(summary) = summary {
|
||||
s.push_str(summary);
|
||||
}
|
||||
s.push_str("</div>");
|
||||
s.push_str(&format!(
|
||||
"<div style='margin-bottom:4px;'><b>Start:</b> {}</div>",
|
||||
local_fmt_start
|
||||
));
|
||||
s.push_str(&format!(
|
||||
"<div style='margin-bottom:4px;'><b>End:</b> {}</div>",
|
||||
local_fmt_end
|
||||
));
|
||||
if let Some(cn) = organizer_cn {
|
||||
s.push_str(&format!(
|
||||
"<div style='margin-bottom:4px;'><b>Organizer:</b> {}</div>",
|
||||
cn
|
||||
));
|
||||
} else if let Some(organizer) = organizer {
|
||||
s.push_str(&format!(
|
||||
"<div style='margin-bottom:4px;'><b>Organizer:</b> {}</div>",
|
||||
organizer
|
||||
));
|
||||
}
|
||||
s
|
||||
};
|
||||
calendar_html
|
||||
}
|
||||
|
||||
// Responsive layout: row with wrap by default, summary expands, calendar right-justified
|
||||
let event_block = format!(
|
||||
"<style>.ical-flex {{ display: flex; flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 0.5em; max-width: 700px; width: 100%; }}\n.ical-flex .summary-block {{ flex: 1 1 0%; }}\n.ical-flex .calendar-block {{ flex: none; margin-left: auto; }}\n@media (max-width: 599px) {{ .ical-flex {{ flex-direction: column; }} .ical-flex > div.summary-block {{ margin-bottom: 0.5em; margin-left: 0; }} .ical-flex > div.calendar-block {{ margin-left: 0; }} }}</style>\
|
||||
<div class='ical-flex'>\
|
||||
<div class='summary-block' style='background:#f7f7f7; border-radius:8px; box-shadow:0 2px 8px #bbb; padding:16px 18px; margin:0 0 8px 0; min-width:220px; max-width:400px; font-size:15px; color:#222;'>{}</div>\
|
||||
{}\
|
||||
</div>",
|
||||
summary_inner,
|
||||
if !calendar_html.is_empty() {
|
||||
format!("<div class=\"calendar-block\" style=\"margin-top: 8px;\">{}</div>", calendar_html)
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
);
|
||||
|
||||
// Description: only if present and non-whitespace, below summary+calendar
|
||||
let mut desc_block = String::new();
|
||||
if let Some(desc) = description {
|
||||
// Replace escaped newlines with real newlines, then split
|
||||
let desc = desc.replace("\\n", "\n");
|
||||
if desc.trim().len() > 0 {
|
||||
let paragraphs: Vec<String> = desc
|
||||
.lines()
|
||||
.map(|line| line.trim())
|
||||
.filter(|line| !line.is_empty())
|
||||
.map(|line| {
|
||||
format!("<p style='margin: 0 0 8px 0; color:#444;'>{}</p>", line)
|
||||
})
|
||||
.collect();
|
||||
if !paragraphs.is_empty() {
|
||||
desc_block = format!(
|
||||
"<div style='max-width:700px; width:100%;'>{}</div>",
|
||||
paragraphs.join("\n")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
summary_parts.push(format!("{}{}", event_block, desc_block));
|
||||
}
|
||||
}
|
||||
|
||||
fn render_month_calendar_widget(date: NaiveDate, event_days: &[NaiveDate]) -> String {
|
||||
let first = date.with_day(1).unwrap();
|
||||
let last = first
|
||||
.with_day(1)
|
||||
.unwrap()
|
||||
.succ_opt()
|
||||
.unwrap_or(first)
|
||||
.pred_opt()
|
||||
.unwrap_or(first);
|
||||
let month_name = first.format("%B").to_string();
|
||||
let year = first.year();
|
||||
let mut html = String::from(
|
||||
"<table class='ical-month' style='border-collapse:collapse; min-width:220px; background:#fff; box-shadow:0 2px 8px #bbb; font-size:14px; margin:0; float:right;'>"
|
||||
);
|
||||
html.push_str(&format!("<caption style='caption-side:top; text-align:center; font-weight:bold; font-size:16px; padding:8px 0;'>{} {}</caption>", month_name, year));
|
||||
html.push_str("<thead><tr>");
|
||||
for wd in ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] {
|
||||
html.push_str(&format!("<th style='padding:4px 6px; border-bottom:1px solid #ccc; color:#666; font-weight:600; background:#f7f7f7'>{}</th>", wd));
|
||||
}
|
||||
html.push_str("</tr></thead><tbody><tr>");
|
||||
let mut cur = first;
|
||||
let mut started = false;
|
||||
for _ in 0..first.weekday().num_days_from_sunday() {
|
||||
html.push_str("<td style='background:#f7f7f7'></td>");
|
||||
}
|
||||
while cur.month() == first.month() {
|
||||
if cur.weekday() == chrono::Weekday::Sun && started {
|
||||
html.push_str("</tr><tr>");
|
||||
}
|
||||
started = true;
|
||||
if event_days.contains(&cur) {
|
||||
html.push_str(&format!("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>{}</td>", cur.day()));
|
||||
} else {
|
||||
html.push_str(&format!(
|
||||
"<td style='border:1px solid #eee; text-align:center;'>{}</td>",
|
||||
cur.day()
|
||||
));
|
||||
}
|
||||
cur = match cur.succ_opt() {
|
||||
Some(d) => d,
|
||||
None => break,
|
||||
};
|
||||
}
|
||||
let last_wd = last.weekday().num_days_from_sunday();
|
||||
for _ in last_wd + 1..7 {
|
||||
html.push_str("<td style='background:#f7f7f7'></td>");
|
||||
}
|
||||
html.push_str("</tr></tbody></table>");
|
||||
html
|
||||
}
|
||||
|
||||
fn parse_ical_datetime_tz(dt: &str, tz: Tz) -> Option<chrono::DateTime<Tz>> {
|
||||
fn parse_ical_datetime_tz(dt: &str, tz: Tz) -> Option<chrono::DateTime<Tz>> {
|
||||
let dt = dt.split(':').last().unwrap_or(dt);
|
||||
if let Ok(ndt) = chrono::NaiveDateTime::parse_from_str(dt, "%Y%m%dT%H%M%SZ") {
|
||||
Some(tz.from_utc_datetime(&ndt))
|
||||
@ -1598,114 +1506,4 @@ pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_ical_datetime(dt: &str) -> Option<String> {
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
let dt = dt.split(':').last().unwrap_or(dt);
|
||||
if let Ok(ndt) = NaiveDateTime::parse_from_str(dt, "%Y%m%dT%H%M%SZ") {
|
||||
let dt_utc: DateTime<Utc> = TimeZone::from_utc_datetime(&Utc, &ndt);
|
||||
return Some(dt_utc.format("%Y-%m-%dT%H:%M:%SZ").to_string());
|
||||
}
|
||||
if let Ok(ndt) = NaiveDateTime::parse_from_str(dt, "%Y%m%dT%H%M%S") {
|
||||
return Some(ndt.format("%Y-%m-%dT%H:%M:%S").to_string());
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
Ok(summary_parts.join("<hr>"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_parse_dmarc_report() {
|
||||
let xml = fs::read_to_string("testdata/dmarc-example.xml").unwrap();
|
||||
let html = parse_dmarc_report(&xml).unwrap();
|
||||
assert!(html.contains("hotmail.com"));
|
||||
assert!(html.contains("msn.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_dmarc_report_no_envelope_to() {
|
||||
let xml = fs::read_to_string("testdata/dmarc-example-no-envelope-to.xml").unwrap();
|
||||
let html = parse_dmarc_report(&xml).unwrap();
|
||||
assert!(!html.contains("Envelope To"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ical_render() {
|
||||
let ical = fs::read_to_string("testdata/ical-example-1.ics").unwrap();
|
||||
let html = render_ical_summary(&ical).unwrap();
|
||||
assert!(html.contains("<b>Summary:</b> dentist night guard"));
|
||||
assert!(html.contains("<b>Start:</b> "));
|
||||
assert!(html.contains("<b>End:</b> "));
|
||||
assert!(html.contains("<b>Organizer:</b> Bill Thiede"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ical_render_2() {
|
||||
let ical = fs::read_to_string("testdata/ical-example-2.ics").unwrap();
|
||||
let html = render_ical_summary(&ical).unwrap();
|
||||
println!("HTML OUTPUT: {}", html);
|
||||
assert!(html.contains("<b>Summary:</b> [tenative] dinner w/ amatute"));
|
||||
assert!(html.contains("<b>Start:</b> "));
|
||||
assert!(html.contains("<b>End:</b> "));
|
||||
assert!(html.contains("<b>Organizer:</b> Family"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ical_multiday() {
|
||||
let ical = fs::read_to_string("testdata/ical-multiday.ics").unwrap();
|
||||
let html = render_ical_summary(&ical).unwrap();
|
||||
println!("HTML MULTIDAY: {}", html);
|
||||
// Print the calendar row containing 28, 29, 30 for debug
|
||||
if let Some(row_start) = html.find("<tr>") {
|
||||
if let Some(row_end) = html[row_start..].find("</tr>") {
|
||||
println!(
|
||||
"CALENDAR ROW: {}",
|
||||
&html[row_start..row_start + row_end + 5]
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(html.contains("<b>Summary:</b> Multi-day Event"));
|
||||
assert!(html.contains("This event spans multiple days"));
|
||||
// Should highlight 28, 29, 30 in the merged calendar table (event days), and dim 27, 31 (out-of-event)
|
||||
for day in [28, 29, 30] {
|
||||
assert!(html.contains(&format!("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>{}</td>", day)), "Missing highlighted day {}", day);
|
||||
}
|
||||
for day in [27, 31] {
|
||||
assert!(html.contains(&format!("<td style='border:1px solid #eee; text-align:center;background:#f7f7f7;color:#bbb;'>{}</td>", day)), "Missing dimmed day {}", day);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ical_straddle() {
|
||||
let ical = fs::read_to_string("testdata/ical-straddle.ics").unwrap();
|
||||
let html = render_ical_summary(&ical).unwrap();
|
||||
println!("HTML STRADDLE: {}", html);
|
||||
assert!(html.contains("<b>Summary:</b> Straddle Month Event"));
|
||||
assert!(html.contains("This event straddles two months"));
|
||||
// Should highlight 30, 31 in August and 1, 2 in September
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>30</td>"));
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>31</td>"));
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>1</td>"));
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>2</td>"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ical_straddle_real() {
|
||||
let ical = fs::read_to_string("testdata/ical-straddle-real.ics").unwrap();
|
||||
let html = render_ical_summary(&ical).unwrap();
|
||||
println!("HTML STRADDLE REAL: {}", html);
|
||||
// Should highlight 30, 31 in August and 1 in September (DTEND is exclusive)
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>30</td>"));
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>31</td>"));
|
||||
assert!(html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>1</td>"));
|
||||
assert!(!html.contains("<td style='background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;'>2</td>"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
use askama::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "dmarc_report.html")]
|
||||
pub struct DmarcReportTemplate<'a> {
|
||||
pub feedback: &'a crate::nm::Feedback,
|
||||
}
|
||||
55
server/templates/ical_summary.html
Normal file
55
server/templates/ical_summary.html
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
<style>
|
||||
.ical-flex {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
gap: 0.5em;
|
||||
max-width: 700px;
|
||||
width: 100%;
|
||||
}
|
||||
.ical-flex .summary-block {
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.ical-flex .calendar-block {
|
||||
flex: none;
|
||||
margin-left: auto;
|
||||
}
|
||||
@media (max-width: 599px) {
|
||||
.ical-flex {
|
||||
flex-direction: column;
|
||||
}
|
||||
.ical-flex > div.summary-block {
|
||||
margin-bottom: 0.5em;
|
||||
margin-left: 0;
|
||||
}
|
||||
.ical-flex > div.calendar-block {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="ical-flex">
|
||||
<div class="summary-block" style="background:#f7f7f7; border-radius:8px; box-shadow:0 2px 8px #bbb; padding:16px 18px; margin:0 0 8px 0; min-width:220px; max-width:400px; font-size:15px; color:#222;">
|
||||
<div style="font-size:17px; font-weight:bold; margin-bottom:8px; color:#333;"><b>Summary:</b> {{ summary }}</div>
|
||||
<div style="margin-bottom:4px;"><b>Start:</b> {{ local_fmt_start }}</div>
|
||||
<div style="margin-bottom:4px;"><b>End:</b> {{ local_fmt_end }}</div>
|
||||
{% if !organizer_cn.is_empty() %}
|
||||
<div style="margin-bottom:4px;"><b>Organizer:</b> {{ organizer_cn }}</div>
|
||||
{% elif !organizer.is_empty() %}
|
||||
<div style="margin-bottom:4px;"><b>Organizer:</b> {{ organizer }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if !calendar_html.is_empty() %}
|
||||
{% if !calendar_html.is_empty() %}
|
||||
<div class="calendar-block" style="margin-top: 8px;">{{ calendar_html | safe }}</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if !description_paragraphs.is_empty() %}
|
||||
<div style="max-width:700px; width:100%;">
|
||||
{% for p in description_paragraphs %}
|
||||
<p style="margin: 0 0 8px 0; color:#444;">{{ p }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
Loading…
x
Reference in New Issue
Block a user