Skip to content

Commit 9af223a

Browse files
Gnukblackheaven
authored andcommitted
Use new calendar for upcoming events
1 parent 9fed523 commit 9af223a

21 files changed

+103
-63
lines changed

data/AFPy.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"Web"
99
],
1010
"patternsGoogleCalendar": [
11-
"Python"
11+
"Python",
12+
"AFPY"
1213
],
1314
"socialLinks": [
1415
{

data/AFSYSfPots.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"shortDescription": "L'AFSY organise les SfPots, des apéros décontractés autour du framework PHP Symfony",
44
"tags": [
55
"PHP",
6-
"Symfony"
6+
"Symfony",
7+
"AFSY-SfPots"
78
],
89
"socialLinks": [
910
{

data/CafeDevOpsLyon.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"Resilience"
1010
],
1111
"patternsGoogleCalendar": [
12-
"Café DevOps Lyon"
12+
"Café DevOps Lyon",
13+
"CafeDevOpsLyon"
1314
],
1415
"socialLinks": [
1516
{

data/DockerLyon.json

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"tags": [
55
"Docker"
66
],
7+
"patternsGoogleCalendar": [
8+
"DockerLyon"
9+
],
710
"socialLinks": [
811
{
912
"icon": "link",

data/GolangLyon.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"Golang"
77
],
88
"patternsGoogleCalendar": [
9-
"Golang Lyon"
9+
"Golang Lyon",
10+
"GolangLyon"
1011
],
1112
"socialLinks": [
1213
{

data/HumanTalks.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"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 !",
44
"tags": [],
55
"patternsGoogleCalendar": [
6-
"Human Talks"
6+
"Human Talks",
7+
"HumanTalks"
78
],
89
"socialLinks": [
910
{

data/LAWS.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "LAWS - Lyon Amazon Web Services UG",
33
"shortDescription": "Groupe officiel Amazon Web Services de la région Lyonnaise. Organisation de Meetup autour des services AWS, retours d'expériences, live coding, ...",
4+
"patternsGoogleCalendar": [
5+
"LAWS"
6+
],
47
"tags": [
58
"AWS",
69
"EC2",

data/LYAUG.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"Google"
77
],
88
"patternsGoogleCalendar": [
9-
"Lyaug"
9+
"Lyaug",
10+
"GDG"
1011
],
1112
"socialLinks": [
1213
{

data/LyonDataScience.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"Elasticsearch"
66
],
77
"patternsGoogleCalendar": [
8-
"Lyon Data Science"
8+
"Lyon Data Science",
9+
"LyonDataScience"
910
],
1011
"socialLinks": [
1112
{

data/LyonDataViz.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"Design"
1111
],
1212
"patternsGoogleCalendar": [
13-
"Lyon DataViz"
13+
"Lyon DataViz",
14+
"LyonDataViz"
1415
],
1516
"socialLinks": [
1617
{

data/LyonRB.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Sinatra"
88
],
99
"patternsGoogleCalendar": [
10-
"Lyon.rb"
10+
"Lyon.rb",
11+
"LyonRB"
1112
],
1213
"socialLinks": [
1314
{

data/MUGLyon.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"JavaScript"
1111
],
1212
"patternsGoogleCalendar": [
13-
"MUG"
13+
"MUG",
14+
"MTGLyon"
1415
],
1516
"socialLinks": [
1617
{

data/MeetupIALyon.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"maker"
1616
],
1717
"patternsGoogleCalendar": [
18-
"Meetup Intelligence Artificielle Lyon"
18+
"Meetup Intelligence Artificielle Lyon",
19+
"IALyon"
1920
],
2021
"socialLinks": [
2122
{

data/SoftwareCraftsmanshipLyon.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Coding Dojo"
88
],
99
"patternsGoogleCalendar": [
10-
"Software Craftsmanship Lyon"
10+
"Software Craftsmanship Lyon",
11+
"SWCrafters"
1112
],
1213
"socialLinks": [
1314
{

data/TheNEO.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"Organisations liberées"
88
],
99
"patternsGoogleCalendar": [
10+
"TheNEO",
1011
"TheNEO"
1112
],
1213
"socialLinks": [

data/graphdb-lyon.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "Neo4j Graph Database Lyon",
33
"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 !",
4+
"patternsGoogleCalendar": [
5+
"GraphDBLyon"
6+
],
47
"tags": [
58
"Neo4j",
69
"NoSQL",

public/css/main.css

+5-3
Original file line numberDiff line numberDiff line change
@@ -5557,11 +5557,13 @@ footer a:hover {
55575557
font-size: 100%;
55585558
}
55595559
.events li > :first-child > :nth-child(2) :first-child {
5560-
font-size: 120%;
5560+
font-size: 1.4rem;
55615561
font-weight: bold;
55625562
}
5563-
.events li > :first-child > :nth-child(2) :first-child a {
5564-
font-size: 50%;
5563+
5564+
.events li > :first-child > :nth-child(2) .event-title .fa {
5565+
font-size: 80%;
5566+
padding: 0;
55655567
}
55665568
.events li > :nth-child(2) {
55675569
padding: 5px 10px 5px 10px;

public/js/communityEvents.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ <h2>{{ paneTitle }}</h2>
1212
<div>{{ startDateMonth }}</div>
1313
</div>
1414
<div>
15-
<div>{{ title }} <a href="{{ url }}" target="_blank" class="fa fa-external-link" title="Lien vers l'événement dans Google Calendar"></a></div>
15+
<div class="event-title">
16+
{{#if hasUrl}}
17+
<a href="{{url}}" target="_blank">{{ title }} <span class="fa fa-external-link" title="Lien vers l'événement dans Google Calendar"></span></a>
18+
{{else}}
19+
{{ title }}
20+
{{/if}}
21+
</div>
1622
<div>De {{ startDateHour }} à {{ endDateHour }} - {{ location }}</div>
1723
</div>
1824
</div>

public/js/ical.es5.min.cjs

+5
Large diffs are not rendered by default.

public/js/main.js

+51-47
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,61 @@ function dynamicFilter(inputId) {
1515
}
1616
}
1717

18-
function fetchEvents(patterns, minDate, maxDate) {
19-
return Promise.all(patterns.map((p) =>
20-
fetch("https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?key=AIzaSyAHKI9T7fhK68b2eggUCHlu9eOwsdFUrhg&singleEvents=true"
21-
+ "&q=" + p
22-
+ "&timeMin=" + minDate.toISOString()
23-
+ "&timeMax=" + maxDate.toISOString())
24-
.then((response) => response.json())))
25-
.then((results) => {
26-
var mapEvents = (googleEvent) => {
27-
var startDate = Date.parse(googleEvent.start.dateTime);
28-
var endDate = Date.parse(googleEvent.end.dateTime);
29-
var parsedStartDate = new Date(startDate);
30-
var parsedEndDate = new Date(endDate);
31-
var format = (d) => d.toString().padStart(2, '0');
32-
var formatHour = (d) => format(d.getHours()) + 'H' + format(d.getMinutes())
33-
var months = ['Jan', 'Fev', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Aout', 'Sept', 'Oct', 'Nov', 'Dec'];
34-
return {
35-
id: googleEvent.id,
36-
title: googleEvent.summary,
37-
description: googleEvent.description,
38-
hasDescription: googleEvent.description && googleEvent.description.length > 0,
39-
location: googleEvent.location,
40-
startDate: startDate,
41-
endDate: endDate,
42-
url: googleEvent.htmlLink,
43-
startDateMonth: months[parsedStartDate.getMonth()],
44-
startDateDay: format(parsedStartDate.getDay()),
45-
startDateHour: formatHour(parsedStartDate),
46-
endDateHour: formatHour(parsedEndDate)
47-
}
48-
};
18+
const toDescription = component => {
19+
const description = component.getFirstPropertyValue('description');
20+
if (description === null) {
21+
return '';
22+
}
23+
return description;
24+
};
4925

50-
var removeDuplicates = (events) => {
51-
var tmpEvents = {};
52-
for (var i = 0, n = events.length; i < n; i++) {
53-
tmpEvents[events[i].id] = events[i];
54-
}
55-
var i = 0;
56-
events = [];
57-
for (var id in tmpEvents) {
58-
events[i++] = tmpEvents[id];
59-
}
60-
return events;
61-
};
26+
const meetupUrlFor = description => {
27+
const matching = description.match(/(https:\/\/www.meetup.com\/[a-zA-Z0-9-]+\/events\/[0-9]+)/g);
28+
if (matching && matching.length > 0) {
29+
return matching[matching.length - 1];
30+
}
31+
return undefined;
32+
};
6233

63-
return Promise.resolve(removeDuplicates(results
64-
.reduce((events, result) => events.concat(result.items.map(mapEvents)), [])
65-
));
66-
});
34+
const toEvent = (component) => {
35+
const description = toDescription(component);
36+
const startDate = component.getFirstPropertyValue('dtstart').toJSDate();
37+
const endDate = component.getFirstPropertyValue('dtend').toJSDate();
38+
const format = (d) => d.toString().padStart(2, '0');
39+
const formatHour = (d) => format(d.getHours()) + 'H' + format(d.getMinutes());
40+
const months = ['Jan', 'Fev', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Aout', 'Sept', 'Oct', 'Nov', 'Dec'];
41+
const url = meetupUrlFor(description);
42+
return {
43+
id: component.getFirstPropertyValue('uid'),
44+
title: component.getFirstPropertyValue('summary'),
45+
description: description,
46+
hasDescription: description && description.length > 0,
47+
url,
48+
hasUrl: url !== undefined,
49+
startDate,
50+
endDate,
51+
location: component.getFirstPropertyValue('location'),
52+
startDateMonth: months[startDate.getMonth()],
53+
startDateDay: format(startDate.getDate()),
54+
startDateHour: formatHour(startDate),
55+
endDateHour: formatHour(endDate)
56+
}
6757
}
6858

59+
const matchPatternForEvent = event => pattern => event.title.toLowerCase().includes(`[${pattern.toLowerCase()}]`);
60+
61+
const matchForPatterns = patterns => event => patterns.some(matchPatternForEvent(event));
62+
63+
const filterForPeriod = (minDate, maxDate) => event => event.startDate >= minDate && event.endDate <= maxDate;
64+
65+
const listVEventComponents = raw => new ICAL.Component(ICAL.parse(raw)).getAllSubcomponents('vevent');
66+
67+
const fetchEvents = (patterns, minDate, maxDate) => fetch('https://www.lyontechhub.org/Lyon-Tech-Hub-Calendar/calendar.ics').then((response) => response.text()).then((raw) =>
68+
listVEventComponents(raw)
69+
.map(toEvent)
70+
.filter(filterForPeriod(minDate, maxDate))
71+
.filter(matchForPatterns(patterns)));
72+
6973
function displayEvents(template, element, events) {
7074
if (element) {
7175
element.innerHTML = template({

src/layouts/Layout.astro

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface Props {
1818
<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>
1919
<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>
2020
<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>
21+
<script src="/js/ical.es5.min.cjs" is:inline></script>
2122
<script src="/js/main.js" is:inline></script>
2223
</head>
2324
<body>

0 commit comments

Comments
 (0)