Events Plugin 📆

Yes. I’ll add a fix in a bit, but requesting you to go over this one. Events Plugin 📆

@rmccown

Just fixed the issue. Please upgrade the plugin to latest.

1 Like

Yes, it should be possible by tweaking the css. Although, our plugin’s logic needs the event start date to be there.

1 Like

Beforehand, thank you for the awesome plugin!

FWIW, we would use this feature quite a bit. Perhaps others would have interest in it too?

Sorry, me again! This time, I think our people caught a few things that seem to be all bugs related with the RSVP. Maybe someone can help confirm these?

Issue 1

If an event has a limit of participants and it is “Booked out”, it seems the already “going” users can’t remove themselves from the list. This is what a “goer” sees:

Issue 2

When editing the event, it’s possible to explicitly set a negative number of guests:

Screenshot 2020-09-16 at 10.17.43

An attribute of min="1" on that input will help, but mind that currently the form can still be saved with a negative limit of guests.

Issue 3

Lastly, if setting a maximum number of guests but manually adding an higher number of guests will render negative number of available slots:

This is an event with a limit of 1 guest, 2 going. Perhaps it’s best to say “Booked out”? On this special case (negative available spots), I’m able to remove myself from the list (see Issue 1).

Sorry for the avalanche of things — unfortunately my tech chops aren’t enough to submit a PR, but I can submit a github issue if it is of any help.

2 Likes

Thanks for reporting those issues. If you can report them here, it would be very easy for us to track it.
https://thepavilion.io/w/bug-report/

Secondly, the discourse team also has an implementation of the events use case. Worth having a look

2 Likes

I tried logging with my Github account and it doesn’t seem work — I keep getting back to the login screen. No need to fix it for me, just letting you know something seems amiss with the Github authentication bit over there.

I appreciate the heads up about this. I had missed that news and it’s very relevant as we are still evaluating how to proceed regarding events on our community.

1 Like

We have got this complain earlier too. cc @angus

1 Like

Not sure where to report this, but this seemed to be the most appropriate place for this.

I noticed an odd bug that affects the Discourse polls and, from my tests, only occurs when the Events plugin is also installed.

When creating a poll and selecting to “Automatically close poll”, regardless of the date picked, the date on the bbcode added to the post is always 24h from then (even if selecting, say, 7 days from now).

Disabling the Events plugin makes the automatic poll close date selection to work as expected.

2 Likes

Will try to repro this.

2 Likes

How can I execute javascript after the calendar page has loaded?


edit: I explain my case.
I was asked to have multi-colored events, like:

I don’t want to create a fork of the plugin, so I achieved something with the following code.
The colors are related to event tags and replace the default category color.

I added the tag list in the event HTML this way: data-tags="{{event.topic.tags}}"

<script type="text/x-handlebars" data-template-name="javascripts/components/events-calendar-event">
<div class="{{event.classes}}" data-tags="{{event.topic.tags}}" {{action 'selectEvent' event.topic.url}} style="{{event.listStyle}}">
  {{#unless event.allDay}}
    <span style='{{event.dotStyle}}'>{{d-icon 'circle'}}</span>
  {{/unless}}
  {{#if event.time}}
    <span class="time">{{event.time}}</span>
  {{/if}}
  {{#if event.title}}
    <span class="title" style="{{event.titleStyle}}">{{replace-emoji event.title}}</span>
  {{/if}}
</div>

{{#if showEventCard}}
  {{events-calendar-card topic=event.topic selectEvent="selectEvent"}}
{{/if}}
</script>

I generate stripped patterns:

<script type="text/discourse-plugin" version="0.8.23">
api.onPageChange((url, title) => {
    // tags colors
    let colors = {muni: "#91D0B5", road: "#8ABBE2", freestyle: "#CFB3D3"};

    let events = document.getElementsByClassName("event");
    for (var i = 0; i < events.length; i++) {
        let event = events[i];
        let gradient = "";
        let tags = event.getAttribute("data-tags").split(",");
        for (j = 1; j <= tags.length; j++) {
            gradient +=
                ", " +
                colors[tags[j - 1]] +
                " " +
                j * 8 +
                "px, " +
                colors[tags[j - 1]] +
                " " +
                (j * 8 + 8) +
                "px";
        }
        event.style.background = "repeating-linear-gradient(-45deg" + gradient + ")";
    }
});
</script>

And I added a bit of CSS.

The result:
2 tags event:

3 tags event:
image

The issue I encounter is that my javascript is executed at the page change and won’t apply stripped colors on previous/next months’ events since the calendar dynamically loads its content.

If I’m in October and and I click “next” twice, going for December, this is how it appears:

This is why I’d like my js to be executed when the calendar content has loaded.

1 Like

I tried another method and achieved the striped effect by editing the function eventsForDay in /assets/javascripts/discourse/lib/date-utilities.js.es6:

I replaced this line:

let tStyle = `width:calc((100%*${daysInRow}) - ${buffer}px);background-color:#${topic.category.color};`;

By:

let tStyle = `width:calc((100%*${daysInRow}) - ${buffer}px);`;

And I added this:

if (topic.tags.length > 0) {
  let colors = {muni: "#91D0B5", road: "#8ABBE2", freestyle: "#CFB3D3"};
  let gradient = "";
  for (let i = 1; i <= topic.tags.length; i++) {
    gradient +=
      ", " +
      colors[topic.tags[i - 1]] +
      " " +
      i * 8 +
      "px, " +
      colors[topic.tags[i - 1]] +
      " " +
      (i * 8 + 8) +
      "px";
  }
   attrs['listStyle'] += `background:repeating-linear-gradient(-45deg ${gradient});`;
}

It works very well and it’s a cleaner way to do what I want to achieve. However, I don’t know how to override this function or file without having to create a fork of the plugin…

1 Like

plugin seems to be incompatible with the latest Discourse version.
from the rebuild log file:

1: from /var/www/discourse/lib/plugin/instance.rb:417:in block in notify_after_initialize' /var/www/discourse/plugins/discourse-events/plugin.rb:190:in block in activate!’: uninitialized constant #Class:0x0000562a2a10fa90::SCOPES
Did you mean? Sprockets (NameError)

** INCOMPATIBLE PLUGIN **

You are unable to build Discourse due to errors in the plugin at
/var/www/discourse/plugins/discourse-events

Please try removing this plugin and rebuilding again!

3 Likes

seems that it had been a problem in Discourse and not in the plugin.
In the latest beta version of Discourse at least the plugins is working again.

1 Like

I can confirm that it is currently not possible to rebuild the latest stable version of Discourse with the current events plugin. :worried:

Unfortunately we can’t switch to tests-passed — we choose the stable branch precisely to avoid this sort of issues. Is anyone looking into this?

I have tried rebuilding with v2.5.2 (which used to work) and that fails with the same error, so I’m not sure where the issue is. Is there a particular commit (of the plugin or of stable Discourse) that I can point the container to?

1 Like

Our support policy is to ensure compatibility with the latest tests-passed version of discourse(due to the fact that its the default setting in discourse_docker). Although, we would like to understand how many of the users of Pavilion family Plugins are on stable branch of discourse.

Also, we’re planning to depricate the events plugin in favour of the discourse team’s events plugin in the near future.

2 Likes

I understand that developers have to look forward to keep compatibility with the future of Discourse — that makes sense. But if there’s no stable branch of sorts for the plugin, then it leaves people looking for a stable setup on a scenario where their setup breaks because due to a beta version they are not using.

Any tips on what commit broke the compatibility? I could try to work with that, but I’m lost on what change made this.

Edit to add: for anyone who has trouble with this and needs a temporary workaround, this commit seems to be the culprit.

2 Likes

There was an issue with webcal api keys which has been resolved.

Thanks for the report @md-misko

3 Likes

again the plugin seems to be incompatible with the latest discourse release 2.6.0.beta5 ( 2bb7676ba4 ).
This time it creates just a blank page when accessing the site. But other than last time there had not been an error when using admin/upgrade.
After disabling the plugin and rebuilding the container Discourse is working fine again.

3 Likes

Hi, does this Events plugin produce the “Add To Calendar” links at the top of posts, like on this page:

Also, here in 2021 what are people’s opinions on using this Pavilion Events plugin vs the official Calendar plugin?

I’m mainly interested in finding ways to make it easy to aggregate views of topics on a calendar, and would also love the ability for our users to be able to add individual events onto their own Google / .ics calendars.

Cheers.