Skip to content

Commit

Permalink
Use new calendar for upcoming events
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnuk committed Dec 14, 2024
1 parent 9fed523 commit ce05cdf
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 63 deletions.
3 changes: 2 additions & 1 deletion data/AFPy.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"Web"
],
"patternsGoogleCalendar": [
"Python"
"Python",
"AFPY"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/AFSYSfPots.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"shortDescription": "L'AFSY organise les SfPots, des apéros décontractés autour du framework PHP Symfony",
"tags": [
"PHP",
"Symfony"
"Symfony",
"AFSY-SfPots"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/CafeDevOpsLyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"Resilience"
],
"patternsGoogleCalendar": [
"Café DevOps Lyon"
"Café DevOps Lyon",
"CafeDevOpsLyon"
],
"socialLinks": [
{
Expand Down
3 changes: 3 additions & 0 deletions data/DockerLyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"tags": [
"Docker"
],
"patternsGoogleCalendar": [
"DockerLyon"
],
"socialLinks": [
{
"icon": "link",
Expand Down
3 changes: 2 additions & 1 deletion data/GolangLyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"Golang"
],
"patternsGoogleCalendar": [
"Golang Lyon"
"Golang Lyon",
"GolangLyon"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/HumanTalks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"shortDescription": "Des talks de 10 minutes accessibles à tous, pour découvrir des sujets techs variés et partager ses passions. Tous les 2nds mardi du mois partout en France et à Lyon en particulier !",
"tags": [],
"patternsGoogleCalendar": [
"Human Talks"
"Human Talks",
"HumanTalks"
],
"socialLinks": [
{
Expand Down
3 changes: 3 additions & 0 deletions data/LAWS.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "LAWS - Lyon Amazon Web Services UG",
"shortDescription": "Groupe officiel Amazon Web Services de la région Lyonnaise. Organisation de Meetup autour des services AWS, retours d'expériences, live coding, ...",
"patternsGoogleCalendar": [
"LAWS"
],
"tags": [
"AWS",
"EC2",
Expand Down
3 changes: 2 additions & 1 deletion data/LYAUG.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"Google"
],
"patternsGoogleCalendar": [
"Lyaug"
"Lyaug",
"GDG"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/LyonDataScience.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"Elasticsearch"
],
"patternsGoogleCalendar": [
"Lyon Data Science"
"Lyon Data Science",
"LyonDataScience"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/LyonDataViz.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"Design"
],
"patternsGoogleCalendar": [
"Lyon DataViz"
"Lyon DataViz",
"LyonDataViz"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/LyonRB.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"Sinatra"
],
"patternsGoogleCalendar": [
"Lyon.rb"
"Lyon.rb",
"LyonRB"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/MUGLyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"JavaScript"
],
"patternsGoogleCalendar": [
"MUG"
"MUG",
"MTGLyon"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/MeetupIALyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"maker"
],
"patternsGoogleCalendar": [
"Meetup Intelligence Artificielle Lyon"
"Meetup Intelligence Artificielle Lyon",
"IALyon"
],
"socialLinks": [
{
Expand Down
3 changes: 2 additions & 1 deletion data/SoftwareCraftsmanshipLyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"Coding Dojo"
],
"patternsGoogleCalendar": [
"Software Craftsmanship Lyon"
"Software Craftsmanship Lyon",
"SWCrafters"
],
"socialLinks": [
{
Expand Down
1 change: 1 addition & 0 deletions data/TheNEO.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Organisations liberées"
],
"patternsGoogleCalendar": [
"TheNEO",
"TheNEO"
],
"socialLinks": [
Expand Down
3 changes: 3 additions & 0 deletions data/graphdb-lyon.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "Neo4j Graph Database Lyon",
"shortDescription": "Cher Graphista, ce groupe a pour objectif de réunir les personnes intéressées par les bases de données NoSql de graphe. Tous les utilisateurs sont les bienvenus, depuis le développeur jusqu'à l'utilisateur final en passant par le simple curieux. A bientôt dans le graphe !",
"patternsGoogleCalendar": [
"GraphDBLyon"
],
"tags": [
"Neo4j",
"NoSQL",
Expand Down
8 changes: 5 additions & 3 deletions public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5557,11 +5557,13 @@ footer a:hover {
font-size: 100%;
}
.events li > :first-child > :nth-child(2) :first-child {
font-size: 120%;
font-size: 1.4rem;
font-weight: bold;
}
.events li > :first-child > :nth-child(2) :first-child a {
font-size: 50%;

.events li > :first-child > :nth-child(2) .event-title .fa {
font-size: 80%;
padding: 0;
}
.events li > :nth-child(2) {
padding: 5px 10px 5px 10px;
Expand Down
8 changes: 7 additions & 1 deletion public/js/communityEvents.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ <h2>{{ paneTitle }}</h2>
<div>{{ startDateMonth }}</div>
</div>
<div>
<div>{{ title }} <a href="{{ url }}" target="_blank" class="fa fa-external-link" title="Lien vers l'événement dans Google Calendar"></a></div>
<div class="event-title">
{{#if hasUrl}}
<a href="{{url}}" target="_blank">{{ title }} <span class="fa fa-external-link" title="Lien vers l'événement dans Google Calendar"></span></a>
{{else}}
{{ title }}
{{/if}}
</div>
<div>De {{ startDateHour }} à {{ endDateHour }} - {{ location }}</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions public/js/ical.es5.min.cjs

Large diffs are not rendered by default.

98 changes: 51 additions & 47 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,61 @@ function dynamicFilter(inputId) {
}
}

function fetchEvents(patterns, minDate, maxDate) {
return Promise.all(patterns.map((p) =>
fetch("https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?key=AIzaSyAHKI9T7fhK68b2eggUCHlu9eOwsdFUrhg&singleEvents=true"
+ "&q=" + p
+ "&timeMin=" + minDate.toISOString()
+ "&timeMax=" + maxDate.toISOString())
.then((response) => response.json())))
.then((results) => {
var mapEvents = (googleEvent) => {
var startDate = Date.parse(googleEvent.start.dateTime);
var endDate = Date.parse(googleEvent.end.dateTime);
var parsedStartDate = new Date(startDate);
var parsedEndDate = new Date(endDate);
var format = (d) => d.toString().padStart(2, '0');
var formatHour = (d) => format(d.getHours()) + 'H' + format(d.getMinutes())
var months = ['Jan', 'Fev', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Aout', 'Sept', 'Oct', 'Nov', 'Dec'];
return {
id: googleEvent.id,
title: googleEvent.summary,
description: googleEvent.description,
hasDescription: googleEvent.description && googleEvent.description.length > 0,
location: googleEvent.location,
startDate: startDate,
endDate: endDate,
url: googleEvent.htmlLink,
startDateMonth: months[parsedStartDate.getMonth()],
startDateDay: format(parsedStartDate.getDay()),
startDateHour: formatHour(parsedStartDate),
endDateHour: formatHour(parsedEndDate)
}
};
const toDescription = component => {
const description = component.getFirstPropertyValue('description');
if (description === null) {
return '';
}
return description;
};

var removeDuplicates = (events) => {
var tmpEvents = {};
for (var i = 0, n = events.length; i < n; i++) {
tmpEvents[events[i].id] = events[i];
}
var i = 0;
events = [];
for (var id in tmpEvents) {
events[i++] = tmpEvents[id];
}
return events;
};
const meetupUrlFor = description => {
const matching = description.match(/(https:\/\/www.meetup.com\/[a-zA-Z0-9-]+\/events\/[0-9]+)/g);
if (matching && matching.length > 0) {
return matching[matching.length - 1];
}
return undefined;
};

return Promise.resolve(removeDuplicates(results
.reduce((events, result) => events.concat(result.items.map(mapEvents)), [])
));
});
const toEvent = (component) => {
const description = toDescription(component);
const startDate = component.getFirstPropertyValue('dtstart').toJSDate();
const endDate = component.getFirstPropertyValue('dtend').toJSDate();
const format = (d) => d.toString().padStart(2, '0');
const formatHour = (d) => format(d.getHours()) + 'H' + format(d.getMinutes());
const months = ['Jan', 'Fev', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Aout', 'Sept', 'Oct', 'Nov', 'Dec'];
const url = meetupUrlFor(description);
return {
id: component.getFirstPropertyValue('uid'),
title: component.getFirstPropertyValue('summary'),
description: description,
hasDescription: description && description.length > 0,
url,
hasUrl: url !== undefined,
startDate,
endDate,
location: component.getFirstPropertyValue('location'),
startDateMonth: months[startDate.getMonth()],
startDateDay: format(startDate.getDate()),
startDateHour: formatHour(startDate),
endDateHour: formatHour(endDate)
}
}

const matchPatternForEvent = event => pattern => event.title.toLowerCase().includes(`[${pattern.toLowerCase()}]`);

const matchForPatterns = patterns => event => patterns.some(matchPatternForEvent(event));

const filterForPeriod = (minDate, maxDate) => event => event.startDate >= minDate && event.endDate <= maxDate;

const listVEventComponents = raw => new ICAL.Component(ICAL.parse(raw)).getAllSubcomponents('vevent');

const fetchEvents = (patterns, minDate, maxDate) => fetch('https://www.lyontechhub.org/Lyon-Tech-Hub-Calendar/calendar.ics').then((response) => response.text()).then((raw) =>
listVEventComponents(raw)
.map(toEvent)
.filter(filterForPeriod(minDate, maxDate))
.filter(matchForPatterns(patterns)));

function displayEvents(template, element, events) {
if (element) {
element.innerHTML = template({
Expand Down
1 change: 1 addition & 0 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Props {
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.8/handlebars.min.js" integrity="sha512-E1dSFxg+wsfJ4HKjutk/WaCzK7S2wv1POn1RRPGh8ZK+ag9l244Vqxji3r6wgz9YBf6+vhQEYJZpSjqWFPg9gg==" crossorigin="anonymous" referrerpolicy="no-referrer" is:inline></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer" is:inline></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha512-oBTprMeNEKCnqfuqKd6sbvFzmFQtlXS3e0C/RGFV0hD6QzhHV+ODfaQbAlmY6/q0ubbwlAM/nCJjkrgA3waLzg==" crossorigin="anonymous" referrerpolicy="no-referrer" is:inline></script>
<script src="/js/ical.es5.min.cjs" is:inline></script>
<script src="/js/main.js" is:inline></script>
</head>
<body>
Expand Down

0 comments on commit ce05cdf

Please sign in to comment.