From 95955abaa339098755a214cfcadf87c90211fe64 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 1 Jul 2026 00:24:10 +0200 Subject: Add RRULE humanizer and wire events into nodes#show - 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 --- config/locales/en.yml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config/locales/en.yml') diff --git a/config/locales/en.yml b/config/locales/en.yml index 2458d4d0..93a0d55c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -8,6 +8,9 @@ en: hello: "Hello world" show_tag_headline: "Pages tagged with:" old_ccc_de: the old ccc.de + event_schedule_time: "at %{time}" + event_schedule_unrecognized: "Schedule not automatically readable" + event_schedule_none: "No schedule" time: formats: -- cgit v1.3 From 5adbf85ab6de777869b0d47d626212caaec9f34e Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 2 Jul 2026 00:12:15 +0200 Subject: Add tagging support to Event model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Event: acts_as_taggable_on :tags — uses existing polymorphic taggings table, no migration needed - events/edit and events/new: tag_list field added, tag_list permitted in events_controller strong params - locales: add open_days (Offene Tage / Open days), upcoming_events (Weitere Termine / Upcoming events), event_schedule_time, event_schedule_unrecognized, event_schedule_none keys --- app/models/event.rb | 4 +--- config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'config/locales/en.yml') diff --git a/app/models/event.rb b/app/models/event.rb index de826748..e2e71c97 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -3,11 +3,9 @@ class Event < ApplicationRecord belongs_to :node, optional: true has_many :occurrences + acts_as_taggable_on :tags validates :title, presence: true, unless: -> { node_id.present? } - validates :is_primary, uniqueness: { scope: :node_id, - message: "only one primary event per node allowed" }, - if: -> { is_primary? && node_id.present? } after_save :generate_occurences diff --git a/config/locales/de.yml b/config/locales/de.yml index 0b42dd37..9719a1cb 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -10,6 +10,8 @@ de: event_schedule_time: "um %{time} Uhr" event_schedule_unrecognized: "Termin-Regel nicht automatisch lesbar" event_schedule_none: "Kein Termin" + open_days: "Offene Tage" + upcoming_events: "Weitere Termine" date: formats: default: "%d.%m.%Y" diff --git a/config/locales/en.yml b/config/locales/en.yml index 93a0d55c..aa477f08 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -11,6 +11,8 @@ en: event_schedule_time: "at %{time}" event_schedule_unrecognized: "Schedule not automatically readable" event_schedule_none: "No schedule" + open_days: "Open days" + upcoming_events: "Upcoming events" time: formats: -- cgit v1.3 From 175b408948e601d3db568768a309eed8f2edb307 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 2 Jul 2026 15:13:52 +0200 Subject: Add 'open today' sidebar widget and open days in chapter lists - open_erfas_today helper: samples 3 random open-day-tagged occurrences of the current day; widget hidden entirely on days without open chapters; heading shows current weekday - content/_open_erfas_today partial rendered in right column above tags and featured articles - _chapter partial: open-day schedules (event_schedule_text) shown inline in aggregated chapter lists with 'Offene Tage' label - ccc.css: open_erfas_today added to existing right-column widget selector groups (headings, lists, links) --- app/helpers/content_helper.rb | 16 ++++++++++++++++ app/views/content/_open_erfas_today.html.erb | 11 +++++++++++ app/views/custom/partials/_chapter.html.erb | 9 +++++++++ app/views/layouts/application.html.erb | 1 + config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ public/stylesheets/ccc.css | 10 +++++----- 7 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 app/views/content/_open_erfas_today.html.erb (limited to 'config/locales/en.yml') diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 53bf5b22..bf7287fb 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -23,6 +23,22 @@ module ContentHelper ) end + def open_erfas_today + occurrences = Occurrence + .find_in_range(Time.now.beginning_of_day, Time.now.end_of_day) + .joins(event: :tags) + .where(tags: { name: 'open-day' }) + .reject { |o| o.node.nil? || o.node.head.nil? } + .sample(3) + + return if occurrences.empty? + + render( + :partial => 'content/open_erfas_today', + :locals => { :occurrences => occurrences } + ) + end + def tags render :partial => 'content/tags' end diff --git a/app/views/content/_open_erfas_today.html.erb b/app/views/content/_open_erfas_today.html.erb new file mode 100644 index 00000000..3448af32 --- /dev/null +++ b/app/views/content/_open_erfas_today.html.erb @@ -0,0 +1,11 @@ +
+

<%= t(:open_today) %>

+
    + <% occurrences.each do |occurrence| %> +
  • + <%= link_to_path occurrence.node.head.title, occurrence.node.unique_name %> + <%= occurrence.start_time.strftime("%H:%M") %> +
  • + <% end %> +
+
diff --git a/app/views/custom/partials/_chapter.html.erb b/app/views/custom/partials/_chapter.html.erb index a5b8662b..805559b2 100644 --- a/app/views/custom/partials/_chapter.html.erb +++ b/app/views/custom/partials/_chapter.html.erb @@ -6,5 +6,14 @@ <% if page.node.external_url.present? %>
<%= link_to page.node.external_url, page.node.external_url, target: '_blank', rel: 'noopener' %>
<% end %> + <% open_days = page.node.events.tagged_with('open-day').order(:start_time) %> + <% if open_days.any? %> +
+ <%= t(:open_days_label) %>: + <% open_days.each do |event| %> + <%= event_schedule_text(event) %> + <% end %> +
+ <% end %>

<%= sanitize page.body %>

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index edab5fc6..57d12e62 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -72,6 +72,7 @@
+ <%= open_erfas_today %> <%= tags %> <%= featured_articles %>
diff --git a/config/locales/de.yml b/config/locales/de.yml index 9719a1cb..e8ae4e19 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -11,7 +11,9 @@ de: event_schedule_unrecognized: "Termin-Regel nicht automatisch lesbar" event_schedule_none: "Kein Termin" open_days: "Offene Tage" + open_days_label: "Offene Tage" upcoming_events: "Weitere Termine" + open_today: "Heute dabei" date: formats: default: "%d.%m.%Y" diff --git a/config/locales/en.yml b/config/locales/en.yml index aa477f08..980a6b85 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -12,7 +12,9 @@ en: event_schedule_unrecognized: "Schedule not automatically readable" event_schedule_none: "No schedule" open_days: "Open days" + open_days_label: "Open days" upcoming_events: "Upcoming events" + open_today: "Open today" time: formats: diff --git a/public/stylesheets/ccc.css b/public/stylesheets/ccc.css index 30eb8dd3..422b7c06 100644 --- a/public/stylesheets/ccc.css +++ b/public/stylesheets/ccc.css @@ -216,7 +216,7 @@ div#frontpage_calendar { } } -div#frontpage_calendar h2, div#tags h2, div#featured_articles h2, div.main_navigation h2 { +div#frontpage_calendar h2, div#tags h2, div#featured_articles h2, div#open_erfas_today h2, div.main_navigation h2 { border-top: 2px solid; border-bottom: 2px solid; font-size: 1.1em; @@ -248,7 +248,7 @@ div#frontpage_calendar h2 { } @media(min-width:1016px) { - div#frontpage_calendar h2, div#tags h2, div#featured_articles h2 { + div#frontpage_calendar h2, div#tags h2, div#featured_articles h2, div#open_erfas_today h2 { font-size: 1rem; } @@ -260,7 +260,7 @@ div#frontpage_calendar h2 { } -div#frontpage_calendar ul, div#tags ul, div#featured_articles ul { +div#frontpage_calendar ul, div#tags ul, div#featured_articles ul, div#open_erfas_today ul { padding: 0px; font-size: 1rem; line-height: 1.5em; @@ -278,11 +278,11 @@ div#frontpage_calendar li { margin-bottom: 20px; } -div#frontpage_calendar li, div#tags li, div#featured_articles li { +div#frontpage_calendar li, div#tags li, div#featured_articles li, div#open_erfas_today li { list-style-type: none; } -div#frontpage_calendar li a, div#tags li a, div#featured_articles li a { +div#frontpage_calendar li a, div#tags li a, div#featured_articles li a, div#open_erfas_today li a { text-decoration: none; color: color-mix(in srgb, CanvasText, #808080 25%); } -- cgit v1.3 From 876697bdff7e03d98a7a426895b4e5dcc07c5a88 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 11 Jul 2026 00:53:53 +0200 Subject: Style admin pagination widget, add missing locale keys Pagination had almost no styling, and its current-page selector never matched will_paginate's actual markup. Added chip-style page links, a solid current-page indicator, and distinct disabled states for Previous/Next. Previous/Next/gap rendered as empty, unlabeled elements -- will_paginate only ships English translations and this app defaults to German. Added previous_label/next_label/page_gap to en.yml and de.yml. --- config/locales/de.yml | 9 +++++++++ config/locales/en.yml | 9 +++++++++ public/stylesheets/admin.css | 42 +++++++++++++++++++++++++++++++++++++++++- script12.rb | 23 +++++++++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 script12.rb (limited to 'config/locales/en.yml') diff --git a/config/locales/de.yml b/config/locales/de.yml index 2f089849..1f2222c3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -133,3 +133,12 @@ de: less_than_or_equal_to: "must be less than or equal to {{count}}" odd: "must be odd" even: "must be even" + + will_paginate: + previous_label: "← Zurück" + previous_aria_label: "Vorherige Seite" + next_label: "Weiter →" + next_aria_label: "Nächste Seite" + page_gap: "…" + container_aria_label: "Seitennavigation" + page_aria_label: "Seite %{page}" diff --git a/config/locales/en.yml b/config/locales/en.yml index 980a6b85..59c73043 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -19,3 +19,12 @@ en: time: formats: ccc: "%d %B, %Y %H:%M" + + will_paginate: + previous_label: "← Previous" + previous_aria_label: "Previous page" + next_label: "Next →" + next_aria_label: "Next page" + page_gap: "…" + container_aria_label: "Pagination" + page_aria_label: "Page %{page}" diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 4723f507..28b8494c 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -240,12 +240,52 @@ span.warning a { div.pagination { padding-top: 5px; padding-bottom: 15px; + display: flex; + align-items: center; + gap: 0.35rem; +} + +div.pagination a, +div.pagination em.current, +div.pagination span.gap { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 1.75rem; + height: 1.75rem; + padding: 0 0.4rem; + border-radius: 4px; + font-style: normal; +} + +div.pagination a { + text-decoration: underline; + text-decoration-style: wavy; + text-decoration-color: #b0b0b0; + text-decoration-thickness: 1px; + text-underline-offset: 2px; } -div.pagination span.current, div.pagination a:hover { +div.pagination a:hover { color: #ff9600; } +div.pagination em.current { + background-color: #ff9600; + color: #ffffff; + font-weight: bold; +} + +div.pagination span.gap { + color: #969696; +} + +div.pagination .previous_page.disabled, +div.pagination .next_page.disabled { + color: #969696; + cursor: not-allowed; +} + /* ============================================================ Buttons ============================================================ */ diff --git a/script12.rb b/script12.rb new file mode 100644 index 00000000..659557c6 --- /dev/null +++ b/script12.rb @@ -0,0 +1,23 @@ +require 'timeout' + +a = Node.root.children.create!(:slug => "cycle_test_a") +b = a.children.create!(:slug => "cycle_test_b") + +a.staged_parent_id = b.id +a.publish_draft! +a.reload + +puts "a.parent_id after staging a under its own child b: #{a.parent_id.inspect} (b.id = #{b.id})" +puts "Node.valid? => #{Node.valid?}" + +begin + Timeout.timeout(3) { puts "a.level => #{a.level}" } +rescue Timeout::Error + puts "TIMED OUT after 3s -- a real cycle and a real infinite loop, confirmed" +end + +# Break any cycle before cleanup -- delete_descendants does its own BFS +# the same way #level does, and would hang on a real cycle too. +Node.where(id: a.id).update_all(parent_id: nil) +b.destroy +a.destroy -- cgit v1.3 From cf93acb8ad44ba9cd486e8f6457d9fd9fbc041cc Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 12 Jul 2026 23:42:23 +0200 Subject: Add a locale-aware relative-time helper; drop stale locale overrides Node.recently_changed and the new dashboard need "X ago" rendered correctly in both locales. Rails' own distance_of_time_in_words/ time_ago_in_words can't do this on their own -- the scope option changes which translation key is looked up, not the underlying grammar, and German's "vor" requires dative case, which is a different word form than the nominative plural Rails computes by default. relative_time_phrase/relative_distance is a small, from- scratch bucketing helper instead, with an explicit, hand-checked translation table per unit per locale. Also removes de.yml's datetime.distance_in_words and activerecord. errors blocks. Both used the old {{count}}/{{model}} interpolation syntax the current i18n gem no longer recognizes -- it silently leaves the literal placeholder text in the rendered output rather than erroring, which is why this went unnoticed until now. Both were shadowing rails-i18n's own current, correct translations for exactly these keys; deleting the local override lets the gem's version take over instead of maintaining a second, broken copy. --- app/helpers/datetime_helper.rb | 53 ++++++++++++++++++++++ config/locales/de.yml | 70 ++--------------------------- config/locales/en.yml | 4 ++ test/models/helpers/datetime_helper_test.rb | 19 ++++++++ 4 files changed, 80 insertions(+), 66 deletions(-) create mode 100644 app/helpers/datetime_helper.rb create mode 100644 test/models/helpers/datetime_helper_test.rb (limited to 'config/locales/en.yml') diff --git a/app/helpers/datetime_helper.rb b/app/helpers/datetime_helper.rb new file mode 100644 index 00000000..8497b1c0 --- /dev/null +++ b/app/helpers/datetime_helper.rb @@ -0,0 +1,53 @@ +module DatetimeHelper + + def relative_distance(time, now = Time.current) + seconds = (now - time).abs + + case seconds + when 0...90 + [1, :minute] + when 90...45.minutes + [(seconds / 60).round, :minute] + when 45.minutes...24.hours + [(seconds / 1.hour).round, :hour] + when 24.hours...30.days + [(seconds / 1.day).round, :day] + when 30.days...365.days + [(seconds / 30.days).round, :month] + else + [(seconds / 365.days).round, :year] + end + end + + RELATIVE_TIME_UNIT_FORMS = { + en: { + minute: { one: "minute", other: "minutes" }, + hour: { one: "hour", other: "hours" }, + day: { one: "day", other: "days" }, + month: { one: "month", other: "months" }, + year: { one: "year", other: "years" }, + }, + de: { + # "other" here is the DATIVE plural needed after "vor" -- not the + # nominative plural you'd use standing alone ("3 Tage" vs "vor 3 + # Tagen"). All five happen to be the nominative plural + "n", since + # none of them already end in -n or -s -- a property of these five + # specific words, not a rule to extend to new units without checking. + minute: { one: "Minute", other: "Minuten" }, + hour: { one: "Stunde", other: "Stunden" }, + day: { one: "Tag", other: "Tagen" }, + month: { one: "Monat", other: "Monaten" }, + year: { one: "Jahr", other: "Jahren" }, + }, + }.freeze + + def relative_time_phrase(time, now = Time.current) + count, unit = relative_distance(time, now) + locale = I18n.locale.to_sym + forms = RELATIVE_TIME_UNIT_FORMS.fetch(locale, RELATIVE_TIME_UNIT_FORMS[:en]) + word = forms.fetch(unit).fetch(count == 1 ? :one : :other) + + locale == :de ? "vor #{count} #{word}" : "#{count} #{word} ago" + end + +end diff --git a/config/locales/de.yml b/config/locales/de.yml index 1f2222c3..550ccb34 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -14,6 +14,10 @@ de: open_days_label: "Offene Tage" upcoming_events: "Weitere Termine" open_today: "Das Chaos, lokal und heute offen" + published: "veröffentlicht" + published_by: "veröffentlicht durch %{editor}" + editor_self: "du" + publisher_self: "dich" date: formats: default: "%d.%m.%Y" @@ -29,7 +33,6 @@ de: - :day - :month - :year - time: formats: default: "%A, %e. %B %Y, %H:%M Uhr" @@ -41,42 +44,6 @@ de: am: "vormittags" pm: "nachmittags" - datetime: - distance_in_words: - half_a_minute: 'eine halbe Minute' - less_than_x_seconds: - zero: 'weniger als 1 Sekunde' - one: 'weniger als 1 Sekunde' - other: 'weniger als {{count}} Sekunden' - x_seconds: - one: '1 Sekunde' - other: '{{count}} Sekunden' - less_than_x_minutes: - zero: 'weniger als 1 Minute' - one: 'weniger als eine Minute' - other: 'weniger als {{count}} Minuten' - x_minutes: - one: '1 Minute' - other: '{{count}} Minuten' - about_x_hours: - one: 'etwa 1 Stunde' - other: 'etwa {{count}} Stunden' - x_days: - one: '1 Tag' - other: '{{count}} Tage' - about_x_months: - one: 'etwa 1 Monat' - other: 'etwa {{count}} Monate' - x_months: - one: '1 Monat' - other: '{{count}} Monate' - about_x_years: - one: 'etwa 1 Jahr' - other: 'etwa {{count}} Jahre' - over_x_years: - one: 'mehr als 1 Jahr' - other: 'mehr als {{count}} Jahre' - number: format: precision: 2 @@ -105,35 +72,6 @@ de: sentence_connector: "und" skip_last_comma: true - activerecord: - errors: - template: - header: - one: 1 error prohibited this {{model}} from being saved - other: "{{count}} errors prohibited this {{model}} from being saved" - body: "There were problems with the following fields:" - - messages: - inclusion: "is not included in the list" - exclusion: "is reserved" - invalid: "is invalid" - confirmation: "doesn't match confirmation" - accepted: "must be accepted" - empty: "can't be empty" - blank: "can't be blank" - too_long: "is too long (maximum is {{count}} characters)" - too_short: "is too short (minimum is {{count}} characters)" - wrong_length: "is the wrong length (should be {{count}} characters)" - taken: "has already been taken" - not_a_number: "is not a number" - greater_than: "must be greater than {{count}}" - greater_than_or_equal_to: "must be greater than or equal to {{count}}" - equal_to: "must be equal to {{count}}" - less_than: "must be less than {{count}}" - less_than_or_equal_to: "must be less than or equal to {{count}}" - odd: "must be odd" - even: "must be even" - will_paginate: previous_label: "← Zurück" previous_aria_label: "Vorherige Seite" diff --git a/config/locales/en.yml b/config/locales/en.yml index 59c73043..73271ed2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,6 +15,10 @@ en: open_days_label: "Open days" upcoming_events: "Upcoming events" open_today: "Open today" + published: "published" + published_by: "published by %{editor}" + publisher_self: "you" + editor_self: "you" time: formats: diff --git a/test/models/helpers/datetime_helper_test.rb b/test/models/helpers/datetime_helper_test.rb new file mode 100644 index 00000000..a24e5d3a --- /dev/null +++ b/test/models/helpers/datetime_helper_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class DatetimeHelperTest < ActionView::TestCase + test "relative_time_phrase pluralizes correctly in English and German" do + travel_to Time.zone.parse("2026-07-12 12:00:00") do + I18n.with_locale(:en) do + assert_equal "1 day ago", relative_time_phrase(1.day.ago) + assert_equal "3 days ago", relative_time_phrase(3.days.ago) + end + I18n.with_locale(:de) do + assert_equal "vor 1 Tag", relative_time_phrase(1.day.ago) + assert_equal "vor 3 Tagen", relative_time_phrase(3.days.ago) + assert_equal "vor 1 Monat", relative_time_phrase(30.days.ago) + assert_equal "vor 2 Monaten", relative_time_phrase(45.days.ago) + assert_equal "vor 2 Jahren", relative_time_phrase(2.years.ago) + end + end + end +end -- cgit v1.3