Will try to repro this.
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:
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.
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ā¦
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!
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.
I can confirm that it is currently not possible to rebuild the latest stable version of Discourse with the current events plugin.
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?
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.
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.
There was an issue with webcal api keys which has been resolved.
Thanks for the report @md-misko
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.
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.
Hey there,
As mentioned in the OP
Please take a moment to consider whether the new Event features in the Discourse Calendar plugin made by the Discourse team are right for you. If they meet your needs, we recommend using that plugin. You should only use this plugin if youāve already first considered Discourse Calendar.
We recommend you use the Discourse Calendar Plugin if you can. We only support this plugin for specific use cases that are not fulfiled by that plugin. Happily, the Calendar Plugin has both features you mentioned.
Yup, thatās this plugin. But, as mentioned, it sounds like youāve got a good use case for Discourse Calendar, so I suggest you use that.
Internally, we actually use the Discourse Calendar Plugin to organise events for our members, rather than this plugin. We support specific use cases for a few clients, and weāre open to specific use cases if anyone has any, but thatās it.
Thanks Angus. I read all that advice and I was asking you specifically because it looked like you were involved with setting up the Legal Empowerment Network community in question, and I liked how it was working. But glad to hear you recommend the official Calendar plugin; Iāll explore that.
Am I correct in saying that the official Discourse Calendar plugin doesnāt have anything like the āAgendaā filter in the topic list? Sorting the topic list by the event dates in a topic is one of the main use cases Iām interested in. Itās more so for project management (treating topics as tasks and scheduling them accordingly) than events.
Iām thinking of adding something like this also. Have you come up with any solutions?
This is my thought: Each event should be considered a reply like pinning a topic. The add event button becomes a drop-down menu that lists all events in the topic.
Iāll check and get back.
We arenāt developing new features for this plugin. Weāve depricated this in favour of the Official Events feature in the discourse-calendar plugin.
I donāt think thereās an agenda style topic list in the official plugin yet.
Does anyone know if thereās a new link that formerly contained the content at Pavilion has gone?
When this plugin is running in a restricted category, we see:
ā¦ but the documentation link is broken and generates a 404. I looked around the site in question and here too, but didnāt know if there was some other home for this user instruction.
We moved that topic to a closed category somehow. Need to bring it back to public. Weāll discuss and get back soon.
p.s.
The page should be back now.