Skip to content

Commit

Permalink
Add DTSTAMP to events to help updates flow through to clients
Browse files Browse the repository at this point in the history
DTSTAMP is supposed to be in UTC, so I needed to add a .rb plugin. I
hope it works on GH Pages.
  • Loading branch information
BudgieInWA committed Nov 18, 2023
1 parent 23ed7cd commit 94ccbd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions _layouts/ical.ics
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ VERSION:2.0
PRODID:-//{{ site.domain }}//{{ site.title }}//EN
CALSCALE:GREGORIAN{% assign events_data = site.pages | where: "layout", "event" | sort: "path" | reverse %}{% for event in events_data %}
BEGIN:VEVENT
SUMMARY:{{ event.title }}
URL:{{ event.url | prepend: site.url }}
UID:{{ event.url | prepend: site.domain }}
{%- comment -%}
DTSTAMP is when this file was generated, LAST-MOD is when the content of this event changed and SEQUENCE is an int that increments when the event changes substantially (such that RSVPs should be reconsidered).
{% endcomment %}
DTSTAMP: {{ site.time | to_utc | date: "%Y%m%dT%H%M%SZ" }}
CLASS: PUBLIC
SUMMARY:{{ event.title }} and dey say
ORGANIZER;CN="{{ site.title }}":MAILTO:{{ site.email }}
DTSTART;TZID=/{{ site.timezone }}:{{ event.start_time | date: "%Y%m%dT%H%M00" }}{% if event.end_time %}
DTEND;TZID=/{{ site.timezone }}:{{ event.end_time | date: "%Y%m%dT%H%M00" }}{% else %}
DTSTART;TZID=/{{ site.timezone }}:{{ event.start_time | date: "%Y%m%dT%H%M%S" }}{% if event.end_time %}
DTEND;TZID=/{{ site.timezone }}:{{ event.end_time | date: "%Y%m%dT%H%M%S" }}{% else %}
DURATION:PT2H{% endif %}
LOCATION:{{ event.location.name }}{% if event.location.address %}, {{ event.location.address }}{% endif %}{% if event.location.latitude and event.location.longitude %}
GEO:{{ event.location.latitude }};{{ event.location.longitude }}{% endif %}
Expand Down
9 changes: 9 additions & 0 deletions _plugins/utc_filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Jekyll
module UTCFilter
def to_utc(date)
time(date).utc
end
end
end

Liquid::Template.register_filter(Jekyll::UTCFilter)

0 comments on commit 94ccbd0

Please sign in to comment.