diff --git a/.github/workflows/jekyll-build.yml b/.github/workflows/jekyll-build.yml index c79f55b937..5e170bd301 100644 --- a/.github/workflows/jekyll-build.yml +++ b/.github/workflows/jekyll-build.yml @@ -13,10 +13,5 @@ jobs: ruby-version: '3.0' bundler-cache: true - run: | - malformed_event_dates=$(grep -Er --files-without-match '^eventdate: [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [-+][0-9]{4}$' _events) - if [ -n "${malformed_event_dates}" ]; then - echo "Malformed event date in:" >&2 - echo "${malformed_event_dates}" >&2 - exit 1 - fi + bundle exec _scripts/_malformedevents.rb bundle exec jekyll build --future diff --git a/Gemfile b/Gemfile index 489b65fed6..ae42b12ef6 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,10 @@ group :jekyll_plugins do gem "jekyll-sitemap" end +group :test do + gem "activesupport" +end + # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem # and associated library. platforms :mingw, :x64_mingw, :mswin, :jruby do diff --git a/_events/_0000-0000-communitymeeting-template.markdown b/_events/_0000-0000-communitymeeting-template.markdown index 1ff6243aac..2110834778 100644 --- a/_events/_0000-0000-communitymeeting-template.markdown +++ b/_events/_0000-0000-communitymeeting-template.markdown @@ -4,8 +4,7 @@ eventdate: 2023-02-28 15:00:00 -0800 title: OpenSearch Community Meeting - 2023-02-28 online: true -# If the event is online, remove the next line, otherwise uncomment and adjust it: -# tz: Pacific/Tahiti +tz: America/Los_Angeles signup: url: https://www.meetup.com/opensearch/events/290444926/ title: Join on Meetup diff --git a/_events/_0000-0000-dev-officehours-dashboards.markdown b/_events/_0000-0000-dev-officehours-dashboards.markdown index 11959cfb08..17cb9cb6af 100644 --- a/_events/_0000-0000-dev-officehours-dashboards.markdown +++ b/_events/_0000-0000-dev-officehours-dashboards.markdown @@ -5,8 +5,7 @@ eventdate: 2023-05-05 10:00:00 -0700 title: OpenSearch Dashboards Developer Office Hours - YYYY-MM-DD # if your event has an online component, put it here (mind the time-zone and daylight saving time!): online: true -# If the event is online, remove the next line, otherwise uncomment and adjust it: -# tz: Pacific/Tahiti +tz: America/Los_Angeles # This is for the sign up button signup: # the link URL diff --git a/_events/_sample.markdown b/_events/_sample.markdown index 8fbc8907b4..0f980858c0 100644 --- a/_events/_sample.markdown +++ b/_events/_sample.markdown @@ -1,14 +1,14 @@ --- # put your event date and time (24 hr) here (mind the time-zone and daylight saving time!): -eventdate: 2021-01-01 12:34:00 -0700 +eventdate: 2021-01-01 12:34:00 -0800 # If the event last multiple day, also add the end date: -# enddate: 2021-01-03 20:00:00 -0700 +# enddate: 2021-01-03 20:00:00 -0800 # the title - this is how it will show up in listing and headings on the site: title: Your Event Title online: true +tz: America/Los_Angeles # If the event is online, remove the next lines, otherwise uncomment and adjust: -# tz: Pacific/Tahiti # location: # city: Papeete # country: French Polynesia diff --git a/_scripts/_malformeddates.sh b/_scripts/_malformeddates.sh index 14da02e1b6..9b6f0020ae 100755 --- a/_scripts/_malformeddates.sh +++ b/_scripts/_malformeddates.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh malformed_event_dates=$(grep -Er --files-without-match '^eventdate: [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [-+][0-9]{4}$' _events) if [ -n "${malformed_event_dates}" ]; then -echo "Malformed event date in:" >&2 -echo "${malformed_event_dates}" >&2 -exit 1 + echo "Malformed event date in:" >&2 + echo "${malformed_event_dates}" >&2 + exit 1 fi diff --git a/_scripts/_malformedevents.rb b/_scripts/_malformedevents.rb new file mode 100755 index 0000000000..5004a9bc58 --- /dev/null +++ b/_scripts/_malformedevents.rb @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby + +require 'active_support' +require 'active_support/time' + +require 'yaml' + +issues = 0 + +Dir['_events/*'].each do |filename| + data = YAML.safe_load_file(filename, permitted_classes: [Time]) + start_date = data['eventdate'] + end_date = data['enddate'] + tz = data['tz'] + + if tz.nil? + message = "#{filename}: All events must have a 'tz' key" + if start_date + message += %{ (based on the time-zone offset of 'eventdate' (#{start_date}), it may be "#{ActiveSupport::TimeZone[start_date.utc_offset].tzinfo.identifier}")} + end + + warn message + issues += 1 + end + + if data['online'] == false + if data.dig('location', 'city').nil? + warn "#{filename}: non-online events must have a 'location.city' key" + issues += 1 + end + + if data.dig('location', 'country').nil? + warn "#{filename}: non-online events must have a 'location.country' key" + issues += 1 + end + end + + if start_date.nil? + warn "#{filename}: All events must have an 'eventdate' key" + issues += 1 + elsif start_date.is_a?(Time) + x = start_date.in_time_zone(tz) + if x.utc_offset != start_date.utc_offset + warn %{#{filename}: event 'eventdate' (#{start_date}) in not in 'tz' (#{tz}) (did you mean "#{x}"?)} + issues += 1 + end + else + warn "#{filename}: event 'eventdate' (#{start_date}) is not a valid RFC822 date" + issues += 1 + end + + if end_date.is_a?(Time) + x = end_date.in_time_zone(tz) + if x.utc_offset != start_date.utc_offset + warn %{#{filename}: event 'enddate' (#{end_date}) in not in 'tz' (#{tz}) (did you mean "#{x}"?)} + issues += 1 + end + elsif end_date + warn "#{filename}: event 'enddate' (#{end_date}) is not a valid RFC822 date" + issues += 1 + end +end + +if issues > 0 + warn "#{issues} problems found in events." + exit 1 +end