ticker-serve: fix ics linebreaks, PRODID, DTSTAMP
This commit is contained in:
parent
262f3961cd
commit
4ff09652ab
|
@ -47,13 +47,15 @@ where
|
||||||
// .into_iter().collect::<Vec<Event>>();
|
// .into_iter().collect::<Vec<Event>>();
|
||||||
let (template, content_type) = f(es);
|
let (template, content_type) = f(es);
|
||||||
match template.render() {
|
match template.render() {
|
||||||
Ok(rendered) =>
|
Ok(rendered) => {
|
||||||
|
let ics = rendered.replace('\n', "\r\n");
|
||||||
(
|
(
|
||||||
[(HeaderName::from_static("content-type"), HeaderValue::from_static(content_type))]
|
[(HeaderName::from_static("content-type"), HeaderValue::from_static(content_type))]
|
||||||
.iter().cloned()
|
.iter().cloned()
|
||||||
.collect::<HeaderMap>(),
|
.collect::<HeaderMap>(),
|
||||||
rendered
|
ics
|
||||||
).into_response(),
|
).into_response()
|
||||||
|
}
|
||||||
Err(e) => (
|
Err(e) => (
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
format!("Failed to render template. Error: {}", e),
|
format!("Failed to render template. Error: {}", e),
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
|
PRODID:-//astro/ticker//NONSGML v1.0//DE
|
||||||
METHOD:PUBLISH
|
METHOD:PUBLISH
|
||||||
X-WR-TIMEZONE;VALUE=TEXT:Europe/Berlin
|
X-WR-TIMEZONE;VALUE=TEXT:Europe/Berlin
|
||||||
|
|
||||||
{% for e in events -%}
|
{% for e in events -%}
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
SUMMARY:{{ e.summary }}
|
SUMMARY:{{ e.summary }}
|
||||||
|
DTSTAMP:{{ e.dtstart.format("%Y%m%dT%H%M%S").to_string() }}
|
||||||
DTSTART:{{ e.dtstart.format("%Y%m%dT%H%M%S").to_string() }}
|
DTSTART:{{ e.dtstart.format("%Y%m%dT%H%M%S").to_string() }}
|
||||||
{% if let Some(dtend) = e.dtend -%}
|
{% if let Some(dtend) = e.dtend -%}
|
||||||
DTEND:{{ dtend.format("%Y%m%dT%H%M%S") }}
|
DTEND:{{ dtend.format("%Y%m%dT%H%M%S") }}
|
||||||
|
|
Loading…
Reference in New Issue