diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-01 00:24:10 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-01 00:24:10 +0200 |
| commit | 95955abaa339098755a214cfcadf87c90211fe64 (patch) | |
| tree | a3ad7a789e71b20c7c760dc1b09f3efcea3f0331 /app/helpers | |
| parent | 51629c5c42270a346885057a441095c964101cc1 (diff) | |
Add RRULE humanizer and wire events into nodes#showerdgeist-revive-events
- app/models/concerns/rrule_humanizer.rb: new concern included into
Event, renders recurring schedule as natural-language German or
English from RRULE string; handles WEEKLY/MONTHLY, biweekly
(INTERVAL=2), ordinal weekday positions (1TU, -1TH, -2WE),
BYMONTH single-month exclusions (December pause convention);
gracefully returns nil for COUNT/UNTIL/unrecognized shapes
- test/models/concerns/rrule_humanizer_test.rb: 15 tests covering
all distinct RRULE shapes found in production data
- app/helpers/nodes_helper.rb: add event_schedule_text helper
combining humanize_rrule with start_time formatting
- app/views/nodes/show.html.erb: add events row, conditionally
rendered when node has associated events
- config/locales/de.yml, en.yml: add event_schedule_time,
event_schedule_unrecognized, event_schedule_none keys
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/nodes_helper.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index 4293628..329bcc5 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb | |||
| @@ -43,4 +43,20 @@ module NodesHelper | |||
| 43 | link_to('add event', new_event_path(:node_id => @node.id)) | 43 | link_to('add event', new_event_path(:node_id => @node.id)) |
| 44 | ]) | 44 | ]) |
| 45 | end | 45 | end |
| 46 | |||
| 47 | def event_schedule_text(event) | ||
| 48 | if event.rrule.present? | ||
| 49 | recurrence = event.humanize_rrule(I18n.locale) | ||
| 50 | if recurrence | ||
| 51 | time = event.start_time&.strftime("%H:%M") | ||
| 52 | time ? "#{recurrence} #{t(:event_schedule_time, time: time)}" : recurrence | ||
| 53 | else | ||
| 54 | "#{event.rrule} (#{t(:event_schedule_unrecognized)})" | ||
| 55 | end | ||
| 56 | elsif event.start_time | ||
| 57 | I18n.l(event.start_time, format: :long) | ||
| 58 | else | ||
| 59 | t(:event_schedule_none) | ||
| 60 | end | ||
| 61 | end | ||
| 46 | end | 62 | end |
