-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new calendar for upcoming events
- Loading branch information
Showing
21 changed files
with
103 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
"Web" | ||
], | ||
"patternsGoogleCalendar": [ | ||
"Python" | ||
"Python", | ||
"AFPY" | ||
], | ||
"socialLinks": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
"tags": [ | ||
"Docker" | ||
], | ||
"patternsGoogleCalendar": [ | ||
"DockerLyon" | ||
], | ||
"socialLinks": [ | ||
{ | ||
"icon": "link", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
"Google" | ||
], | ||
"patternsGoogleCalendar": [ | ||
"Lyaug" | ||
"Lyaug", | ||
"GDG" | ||
], | ||
"socialLinks": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"Sinatra" | ||
], | ||
"patternsGoogleCalendar": [ | ||
"Lyon.rb" | ||
"Lyon.rb", | ||
"LyonRB" | ||
], | ||
"socialLinks": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ | |
"JavaScript" | ||
], | ||
"patternsGoogleCalendar": [ | ||
"MUG" | ||
"MUG", | ||
"MTGLyon" | ||
], | ||
"socialLinks": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
"Organisations liberées" | ||
], | ||
"patternsGoogleCalendar": [ | ||
"TheNEO", | ||
"TheNEO" | ||
], | ||
"socialLinks": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters