Events Plugin 📆


(Angus McLeod) #205

@steve_pd @tobiaseigen Thank you both. Current agenda:

1 Release email support for events. My work on this was disrupted by travel. I’m putting the finishing touches on this now.

2 - Add a setting to add a hamburger menu item for events (the top menu item can currently be toggled in the top menu setting).

3 - Add site level equivalents for the category-specific settings.

4 - Fix the preview display issue.

5 - Review calendar mobile performance.

6 - Address long title display

7 - RSVP feature (this is lower on the list as it’s a bigger feature)

8 - Add event details to onebox previews

? - Event calendar for groups


(Angus McLeod) #206

I’ve added links for the site-level calendar and agenda to the hamburger menu. The can be enabled (and disabled) using the events_hamburger_menu_calendar_link and events_hamburger_menu_agenda_link site settings.

Live on my sandbox.

cc @tobiaseigen


(Angus McLeod) #207

I’ve added site-level settings for:

There is already a site-level setting for “No text on add event buttons”.

For each site level setting mentioned above the category level setting will override the site level setting. For boolean settings, a false category-level setting will also override the site-level setting. This means that if you have already set a category-level setting for a category, the site level setting will not apply to the category.

Live on my sandbox.

cc @tobiaseigen


(Angus McLeod) #208

This one’s not the events plugin, it’s the alt text for the image in that post.

Nevertheless, it would be nice to have some event details in oneboxes. As it’s feature task though, I’ll add it to the end of the list.


Current list

1 Release email support for events. My work on this was disrupted by travel. I’m putting the finishing touches on this now.

2 - Add a setting to add a hamburger menu item for events (the top menu item can currently be toggled in the top menu setting).

3 - Add site level equivalents for the category-specific settings.

4 - Fix the preview display issue.

5 - Review calendar mobile performance.

6 - Address long title display

7 - RSVP feature (this is lower on the list as it’s a bigger feature)

8 - Add event details to onebox previews

? - Event calendar for groups


(Angus McLeod) #209

This is fixed :sunny:

Live on the sandbox.


#210

Hi @Angus. Great to see events appearing in email notifications :+1:

Would be good if the time zone and time zone offset could be omitted.


(Angus McLeod) #211

My general thinking is that the timezone should be included in emails as there is no way to detect a user’s timezone in the email client.

Even for communities that are specific to an area like yours there still may be circumstances in which a timezone becomes useful, like when you went to Paris :fr:.

But perhaps I should still add a setting to not include timezones in emails. I can see the argument in your case. I’ll add that this weekend.

Also, you should use the new default timezone site setting (i.e. set it to London rather than UTC).


#212

Hi Angus, I noticed that setting and set the default timezone to London (although it kept flipping to Edinburgh? No biggie).

Would definitely like to be able to disable the timezone display on emails. Thanks for looking into this.


(Angus McLeod) #213

hm right, yeah, it’s because I’m now using “Friendlier” labels generated by Rails in the UI and the official zones underneath the hood. Sometimes two labels refer to the same zone.

The select-kit gets confused when two labels refer to the same value. I’ll figure out some fix to that at some point, but as you say it’s not a big issue.

I’ll add the setting soon.


#214

Thanks. Also, somewhat concerning, the time shown in a recent email was 1 hour out:

This is the same event on the forum:

Probably a daylight saving time issue. I could have sworn I set the timezone to London. Should this be sufficient for the plugin to account for daylight saving time adjustment?

Also the date appears to show as a range although only a single date was entered.


#215

@angus kindly helped me test the issue with dates in emails being one hour out. It looks like the timezone setting on my forum must have been UTC at the time of the issue (rather than London) which meant that this was a daylight savings time issue.

I could have sworn I set the timezone correctly when I first installed the plugin but in any case, I don’t think there is any issue with the plugin itself here.

Thanks, Angus, for your help diagnosing this.


(Anton) #216

Please consider adding language files to Transifex. I’d like to translate to Russian.


(Angus McLeod) #217

They’re actually there already :slight_smile:

This plugin’s Travis CI runs:

  • All the core rspec tests (partly to ensure emails work properly)

  • It’s own tests.

  • Syncs the repo with Transifex.


#218

Hi @Angus, me again I’m afraid!

I had a report from a user whose topic date/time was showing an hour out in the topic list today. Mine was correct.

Both the “allow user locale” and " set locale from accept language header" site settings are false, and I’m baffled by this issue.

Any help would be much appreciated


(Angus McLeod) #219

Ok, I’ll take a look tomorrow.


#220

Is it possible that the user‘s computer/phone has a wrong timezone? The locale is only used for date/time formatting using moment.js afaik. The time for your event shown to me is also 20:30. My timezone is Berlin.


#221

That is entirely possible as the user is from Germany I think!

I’d still want the events to be shown in London time for all users though, due to the nature of my forum


(Angus McLeod) #222

As @craisp suggested, the way it’s meant to work is that it shows the user the event time in their own timezone. If the user is in Germany the time will be different.

I added the setting Include timezone in event label. to handle the case of users in multiple timezones, i.e. so there would be no confusion about what time was being displayed.

However I guess you’re after a setting that will always show the event in a certain timezone.

Well now that we have a default timezone, this is possible without also requiring the timezone to be entered each time an event is added. So I’ll add it.

Updated tasklist (for my reference);

1 - Address long title display.

2 - Add setting to always display time in default timezone, unless timezone is explicitly set.

3 - RSVP feature(@steve_pd I haven’t forgotten about this, sorry it’s taking so long).

4 - Add event details to onebox previews.

? - Event calendar for groups


(Angus McLeod) #223

New feature: Event cards.

Screenshot%20at%20Apr%2013%2016-46-58

Now when you click on an event in the calendar in desktop, you will see an event card, with the topic title, metadata (including event label) and a topic excerpt. Clicking the title, the event label or the excerpt takes you to the topic itself. Event cards do not display on mobile. They are somewhat similar to the event details display in Google Calendar.

@tobiaseigen This addresses the title display issue.


(Angus McLeod) #224

Timezones update

I’ve simplified the way timezones are handled.

Event creation, editing and display

For creating, editing and displaying an event, the timezone is set according to this hierarchy:

// Start with the user's timezone, guessed by momentjs.
let timezone = moment.tz.guess();

// If a default timezone is set in the site setting use that instead.
const defaultTimezone = Discourse.SiteSettings.events_default_timezone;
if (defaultTimezone) {
  timezone = defaultTimezone;
}

// If the event has a custom timezone use that instead.
if (event['timezone']) {
  timezone = event['timezone'];
}

return timezone;

The decision on whether or not to display a timezone label next to a datetime is determined according to this logic:

const defaultTimezone = Discourse.SiteSettings.events_default_timezone;
const standardTimezone = defaultTimezone || moment.tz.guess();

if (!allDay && event['timezone'] && event['timezone'] !== standardTimezone) {
  dateString += `, ${timezoneLabel(event['timezone'])}`;
}

Basically, if the event is not an all day event and has a custom timezone that is different from the standard timezone (either the site setting or the user’s own timezone), then the timezone is displayed.

Zone list

I’ve also updated the timezone list (used for both the default timezone setting and the custom timezone input in event creation / editing modal) to filter duplicate values in the ActiveSupport::TimeZone::MAPPING. This simplifies the selection of zones (e.g. prevents issues with having objects with duplicate keys in a combo-box)

timezones = ActiveSupport::TimeZone::MAPPING
zone_map = []
remove_zones = []

# Remove the duplicate zones where the label doesn't include the city in the zone.
timezones.each do |k, v|
  if zone_map.include?(v)
    duplicates = timezones.select { |key, val| val === v }
    remove = duplicates.select{ |key, val| !val.include?(key) }
    remove_zones.push(*remove.keys)
  end

  zone_map.push(v)
end

timezones.except!(*remove_zones)

Basically, this means that when you have two or more “Readable” labels referring to the same IANA zone such as

"Edinburgh" => "Europe/London",
"London" => "Europe/London"

The zone with a label that does not match in the city in the IANA zone is removed. In this case Edinburgh would be removed.

Emails

The timezone of event times in emails is set according to this logic:

event_timezone = SiteSetting.events_default_timezone
event_timezone = event[:timezone] if event[:timezone].present?

i.e. Start with the default timezone, then use the custom event timezone if one is used.

I’ve also added a setting that toggles the display of timezones in event emails: events_emails_include_timezones. Default is true. The event time in the email is still going to be localised according to the logic above regardless of this setting.

@anon2041049 Amongst other things, I hope this addresses your various timezone issues.