mirror of
https://github.com/netz39/www.netz39.de.git
synced 2025-05-04 04:21:57 +02:00
feat(events): support every 2nd friday of the month
This commit is contained in:
parent
bc693fb37a
commit
db630b6afd
6 changed files with 93 additions and 20 deletions
|
@ -52,6 +52,7 @@ Unsere Webseite setzt aus folgenden Gründen auf Jekyll, einen statischen Websit
|
|||
location: "Netz39 e.V." # optional, Ort des Events
|
||||
frequency: "WEEKLY" # https://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html
|
||||
interval: 2 # optional, ergibt zusammen mit frequency am Beispiel "alle zwei wochen"
|
||||
rrule: "FREQ=MONTHLY;INTERVAL=1;BYDAY=1FR,1TH" # follows https://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html
|
||||
---
|
||||
```
|
||||
- Unterhalb des Front Matters die Beschreibung des Events in Markdown aufschreiben
|
||||
|
|
11
_events/2025/recurring_event.md
Normal file
11
_events/2025/recurring_event.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
layout: event
|
||||
title: "recurringEvent"
|
||||
author: MaxMustermann # optional, soll angegeben werden, wenn du der Ansprechpartner des Events bist
|
||||
event:
|
||||
start: 2025-04-16 19:00:00 # Datum, an dem das Event stattfindet. Die Zeit ist optional
|
||||
end: 2025-04-16 21:00:00 # optional, Zeitpunkt, an dem das Event endet
|
||||
organizer: "Netz39 Team <kontakt@netz39.de>" # optional, Kontaktdaten im ical Event
|
||||
location: "Netz39 e.V." # optional, Ort des Events
|
||||
rrule: "DTSTART=20250416T190000Z;FREQ=MONTHLY;INTERVAL=1;BYDAY=2FR" # follows https://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html
|
||||
---
|
|
@ -1,7 +1,6 @@
|
|||
{% assign author = site.data.authors[include.author] %}
|
||||
{% assign date = include.date | default: "today" | date: "%-d. %B %Y" %}
|
||||
{% assign frequency = include.frequency %}
|
||||
{% assign interval = include.interval %}
|
||||
{% assign rrule = include.rrule %}
|
||||
|
||||
<div class="post-info">
|
||||
{%- if author.url -%}<a href="{{ author.url | relative_url }}" target="_blank" rel="noopener">{%- endif -%}
|
||||
|
@ -11,13 +10,80 @@
|
|||
<p class="meta">
|
||||
{% if author.name %}{{ author.name }} - {% endif %}
|
||||
{% assign x = date | date: "%m" | minus: 1 %}
|
||||
{% if frequency %}
|
||||
{% if interval == 1 %}
|
||||
Every {{ frequency }} starting {{ date | date: "%-d. " }}{{ site.data.language.str_months[x]}} {{ date | date: "%Y" }}
|
||||
{% else %}
|
||||
{% assign freql = frequency | size | minus: 2 %}
|
||||
Every {{ interval }} {{ frequency | slice: 0, freql }}s starting {{ date | date: "%-d. " }}{{ site.data.language.str_months[x]}} {{ date | date: "%Y" }}
|
||||
{% endif %}
|
||||
{% if rrule %}
|
||||
|
||||
{% assign freq = rrule | split: ";" %}
|
||||
{% assign frequency = freq[0] | split: "=" | last %}
|
||||
{% assign interval = freq[1] | split: "=" | last %}
|
||||
{% assign byday = freq[2] | split: "=" | last %}
|
||||
{% capture transformed_text %}
|
||||
{% if frequency == "MONTHLY" %}
|
||||
{% assign days = byday | split: "," %}
|
||||
{% capture days_text %}
|
||||
{% for day in days %}
|
||||
{% assign day_of_week = day | slice: 1, 2 %}
|
||||
{% assign week = day | slice: 0, 1 %}
|
||||
|
||||
{% case day_of_week %}
|
||||
{% when "MO" %}
|
||||
{% assign day_name = "Monday" %}
|
||||
{% when "TU" %}
|
||||
{% assign day_name = "Tuesday" %}
|
||||
{% when "WE" %}
|
||||
{% assign day_name = "Wednesday" %}
|
||||
{% when "TH" %}
|
||||
{% assign day_name = "Thursday" %}
|
||||
{% when "FR" %}
|
||||
{% assign day_name = "Friday" %}
|
||||
{% when "SA" %}
|
||||
{% assign day_name = "Saturday" %}
|
||||
{% when "SU" %}
|
||||
{% assign day_name = "Sunday" %}
|
||||
{% endcase %}
|
||||
|
||||
{% assign week_suffix = week | append: "th" %}
|
||||
{% if week == "1" %}
|
||||
{% assign week_suffix = week | append: "st" %}
|
||||
{% elsif week == "2" %}
|
||||
{% assign week_suffix = week | append: "nd" %}
|
||||
{% elsif week == "3" %}
|
||||
{% assign week_suffix = week | append: "rd" %}
|
||||
{% endif %}
|
||||
|
||||
{% if forloop.first %}
|
||||
{{ week_suffix }} {{ day_name }}
|
||||
{% else %}
|
||||
and {{ week_suffix }} {{ day_name }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endcapture %}
|
||||
{% capture month_text %}
|
||||
{% if interval == "1" %}
|
||||
Every month
|
||||
{% elsif interval == "2" %}
|
||||
Every other month
|
||||
{% else %}
|
||||
Every {{interval}} months
|
||||
{% endif %}
|
||||
{% endcapture %}
|
||||
{{ month_text }} on the {{days_text}}
|
||||
{% elsif frequency == "WEEKLY" %}
|
||||
{% capture week_text %}
|
||||
{% if interval == "1" %}
|
||||
Every week
|
||||
{% elsif interval == "2" %}
|
||||
Every other week
|
||||
{% else %}
|
||||
Every {{interval}} weeks
|
||||
{% endif %}
|
||||
{% endcapture %}
|
||||
{% capture day %}
|
||||
{{ date | date: "%A" }}
|
||||
{% endcapture %}
|
||||
{{ week_text }} on {{ day }}
|
||||
{% endif %}
|
||||
{% endcapture %}
|
||||
{{transformed_text}}
|
||||
{% else %}
|
||||
{{ date | date: "%-d. " }}{{ site.data.language.str_months[x]}} {{ date | date: "%Y" }}
|
||||
{% endif %}
|
||||
|
|
|
@ -9,7 +9,7 @@ layout: default
|
|||
{% else %}
|
||||
<h1 id="{{ page.title | cgi_escape }}" class="title">{{ page.title }}</h1>
|
||||
{% assign start_date = page.event.start | default: page.event_date %}
|
||||
{% include blog/post_info.liquid author=page.author date=start_date frequency=page.event.frequency interval=page.event.interval %}
|
||||
{% include blog/post_info.liquid author=page.author date=start_date rrule=page.event.rrule %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
|
|
|
@ -39,8 +39,7 @@ module Jekyll
|
|||
end_date = event.data.dig('event', 'end') || event.data['event_date'] || start_date + default_duration
|
||||
organizer = event.data.dig('event', 'organizer') || default_organizer
|
||||
location = event.data.dig('event', 'location') || default_location
|
||||
frequency = event.data.dig('event', 'frequency')
|
||||
interval = event.data.dig('event', 'interval')
|
||||
rrule = event.data.dig('event', 'rrule')
|
||||
|
||||
# Skip events older than 365 days
|
||||
next if start_date.to_date < (Date.today - 365)
|
||||
|
@ -65,8 +64,8 @@ module Jekyll
|
|||
ical_event.dtstart = Icalendar::Values::Date.new(start_date)
|
||||
ical_event.dtend = Icalendar::Values::Date.new(end_date)
|
||||
end
|
||||
if frequency && interval
|
||||
ical_event.rrule = "FREQ=#{frequency};INTERVAL=#{interval.to_i};"
|
||||
if rrule
|
||||
ical_event.rrule = rrule
|
||||
end
|
||||
ical_event.summary = title
|
||||
ical_event.description = description
|
||||
|
|
|
@ -8,18 +8,14 @@ permalink: /calendar-data/
|
|||
{% for event in site.events %}
|
||||
{% assign start = event.event.start | default: event.event_date %}
|
||||
{% assign end = event.event.end | default: start %}
|
||||
{% if event.event.frequency %}
|
||||
{% if event.event.rrule %}
|
||||
{
|
||||
"title": "{{event.title}}",
|
||||
"start": "{{start | date: "%Y-%m-%dT%H:%M:%S"}}",
|
||||
"end": "{{end | date: "%Y-%m-%dT%H:%M:%S"}}",
|
||||
"allDay": {% if start == end %}true{% else %}false{% endif %},
|
||||
"url": "{{event.url}}",
|
||||
"rrule": {% if event.event.frequency %}{
|
||||
"freq": "{{event.event.frequency}}",
|
||||
"interval": {{event.event.interval}},
|
||||
"dtstart": "{{start | date: "%Y-%m-%dT%H:%M:%S"}}"
|
||||
}{% else %}null{% endif %}
|
||||
"rrule": {% if event.event.rrule %}"{{event.event.rrule}}"{% else %}null{% endif %}
|
||||
}
|
||||
{% else %}
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue