Skip to content

Commit 3c9dc33

Browse files
committed
implemented exclusion dates, pl readme
1 parent e614e26 commit 3c9dc33

File tree

6 files changed

+115
-33
lines changed

6 files changed

+115
-33
lines changed

README.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,40 @@ An online tool that makes adding your schedule to Google Calendar faster and eas
33

44
You can test it [here](https://srflp.github.io/planeo/).
55

6-
Simply fill out the form, submit it and enjoy the schedule in Google Calendar 📅.
6+
Simply fill out the form, submit it and enjoy the schedule in your Google Calendar 📅.
7+
8+
Currently the form is adjusted to suit the needs of students attending the Faculty of Computing and Telecommunications of the Poznan University of Technology.
79

810
_Read this in other languages: [Polski](README.pl.md)_
911

1012

1113
## About the project
1214

13-
The main goal of this project is to help students in integrating their schedule with Google Calendar.
14-
15-
### Why?
15+
The main goal of this project is to help students in transferring their schedule into Google Calendar.
1616

17-
Such personalized tool as planeo makes the process much more intuitive, because it perfectly suits the needs.
17+
### Why not adding the schedule manually?
1818

19-
Adding the timetable manually is highly time-consuming. If you've never tried it, I'm sure, the easiest option is planeo.
19+
planeo makes the process much more intuitive, because it's tailored to do just one thing - adding a schedule.
2020

21-
Google Calendar is an incredible multi-purpose tool, but it is event-oriented. It's easy to add single events or simple recurring events, but when it comes to complex recurring events, for example such occurring in a timespan beetween two dates, it's doable but not enjoyable.
21+
Adding the timetable to Google Calendar manually is highly time-consuming.
2222

2323
### What does it exactly do?
2424

25-
After you fill out the form and submit it, the data you typed in is preprocessed.
26-
27-
// TODO
25+
After you fill out the form and submit it, the data you typed in is preprocessed and submitted to Google Calendar API in special form.
2826

2927
## Technical details
30-
The entire project was written in plain JavaScript, without the use of any JS frameworks.
28+
The entire project was written in plain JavaScript, without the use of any massive JS frameworks.
3129

3230
### Dependencies
3331
#### Development side
34-
- [babel](https://github.com/babel/babel) - it transpiles modern JS to JS that is able to run in the most browsers
35-
- [webpack](https://github.com/webpack/webpack) - combined with babel it bundles the source code into single bundle.js file
32+
- [babel](https://github.com/babel/babel) - it transpiles ES6 JS to ES5 that is able to run in the most browsers
33+
- [webpack](https://github.com/webpack/webpack) - launches babel and bundles the source code into single bundle.js file
3634

3735
#### Production side
3836
- [Bootstrap](https://github.com/twbs/bootstrap) - UI (CSS only)
3937
- [flatpickr](https://github.com/flatpickr/flatpickr) - datepickers
40-
- [loadjs](https://github.com/muicss/loadjs) - for loading Google API directly from JavaScript
38+
- [loadjs](https://github.com/muicss/loadjs) - for loading Google API Client Library directly with JavaScript
39+
- [dayjs](https://github.com/iamkun/dayjs) - lightweight library to manage complex date manipulation
4140

4241
## Installation
4342
If you want to run it on your own computer/server:

README.pl.md

+61-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
11
# planeo
22

3-
// TODO
3+
Narzędzie, które pozwala dodać Twój plan zajęć do Kalendarza Google szybciej i prościej, niż gdyby robić to ręcznie.
44

5-
_Read this in other languages: [English](README.md)_
5+
Możesz przetestować je [tutaj](https://srflp.github.io/planeo/).
6+
7+
Formularz jest dostosowany obecnie do planów zajęć Wydziału Intformatyki i Telekomunikacji Politechniki Poznańskiej.
8+
9+
_Read this in other languages: [English](README.md)_
10+
11+
## O projekcie
12+
13+
Głównym celem tego projektu jest ułatwienie studentom dodawania swoich planów do Kalendarza Google.
14+
15+
### Dlaczego nie dodawać planu ręcznie?
16+
17+
planeo znacząco upraszcza proces dodawania planu do Kalendarza, robienie tego ręcznie jest bardzo czasochłonne.
18+
19+
### Co ten program tak właściwie robi?
20+
21+
Po wypełnieniu formularza i wysłaniu go, planeo przetwarza wpisane dane i przekazuje je do API Kalendarza Google.
22+
To tak w bardzo dużym uproszczeniu. W rzeczywistości, proces po kliknięciu „Dodaj” wygląda tak:
23+
- dodawane są całodniowe wydarzenia znakujące początki i końce semestru
24+
- w poniedziałek każdego tygodnia semestru dodawane jest całodniowe wydarzenie oznaczające, czy dany tydzień jest tygodniem parzystym, czy nieparzystym (na podstawie informacji z formularza, czy pierwszy tydzień jest parzysty/nieparzysty)
25+
- wyszukiwana jest pierwsza data wystąpienia danego zajęcia w semestrze (uwzględniając parzystości tygodni i występujące święta, podczas których zajęć nie ma), a następnie dodawane jest cykliczne wydarzenie (ang. recurrent event) z tą datą jako datą początku, oraz datą końca semestru jako datę końca cyklicznego wydarzenia. Cykliczne wydarzenia mają częstotliwość określoną na 1 tydzień (przy ustawieniu "wszystkie tygodnie") lub 2 tygodnie (przy wybraniu opcji "parzyste"/"nieparzyste"). Do informacji o cykliczności wydarzenia dołączane są wyjątki, czyli wszystkie daty w których zajęcia się nie odbędą (święta).
26+
- jako całodniowe wydarzenia dodawane są dni wolne od zajęć dydaktycznych (święta)
27+
28+
## Detale techniczne
29+
Cały projekt został napisany w czystym JavaScripcie, bez użycia żadnych dużych JSowych frameworków.
30+
31+
### Zależności
32+
#### Development side
33+
- [babel](https://github.com/babel/babel) - transpiluje JSa w standardzie ES6 do standardu ES5 który jest obsługiwany przez zdecydowaną większość przeglądarek
34+
- [webpack](https://github.com/webpack/webpack) - uruchamia babela i bundluje kod w pojedynczy plik bundle.js
35+
36+
#### Production side
37+
- [Bootstrap](https://github.com/twbs/bootstrap) - interfejs użytkownika (sam CSS)
38+
- [flatpickr](https://github.com/flatpickr/flatpickr) - kalendarzyki do wyboru daty
39+
- [loadjs](https://github.com/muicss/loadjs) - do wczytywania Google API Client Library bezpośrednio z poziomu JavaScriptu
40+
- [dayjs](https://github.com/iamkun/dayjs) - lekka biblioteka do wygodnego operowania na datach
41+
42+
## Instalacja
43+
Jeśli chcesz uruchomić ten projekt na swoim komputerze:
44+
1. sklonuj repozytorium
45+
2. uruchom `npm install` będąc w katalogu projekty
46+
3. wejdź do folderu `dist` i uruchom z jego poziomu serwer HTTP, np.
47+
```
48+
$ python3 -m http.server 8000
49+
```
50+
4. uruchom webpacka:
51+
```
52+
npx webpack
53+
```
54+
Automatycznie będzie on nadzorował zmiany w projekcie i auktualizował plik bundle.js z każdą zmianą.
55+
56+
### Inne
57+
Dodatkowo możesz nadać lokalnemu adresowi strony adres publiczny używając ngroka (aby np. przetestować apkę na telefonie):
58+
```
59+
./ngrok http localhost:8000
60+
```
61+
Aktualizacja brancha gh-pages:
62+
```
63+
git subtree push --prefix dist origin gh-pages
64+
```

dist/bundle.js

+14-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/googleCalendar/CalendarEvent.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
import dayjs from "dayjs"
22
import customParseFormat from 'dayjs/plugin/customParseFormat';
3+
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
34
dayjs.extend(customParseFormat);
5+
dayjs.extend(isSameOrBefore);
46

57
export default class CalendarEvent {
68
constructor(event) {
79
this.summary = event.name;
8-
this.startDate = event.startDate.format('YYYY-MM-DD'); // expects Date object
9-
this.endDate = event.endDate.format('YYYY-MM-DD');
1010
this.allDay = event.allDay; // boolean
11-
if (!this.allDay) {
11+
this.startDate = event.startDate.format('YYYY-MM-DD'); // expects Date object
12+
if (this.allDay) {
13+
this.endDate = event.endDate.add(1, 'day').format('YYYY-MM-DD'); // correction of Google Calendar bug
14+
} else {
15+
this.endDate = event.endDate.format('YYYY-MM-DD');
1216
this.startDateTime = dayjs(this.startDate + ' ' + event.startHour, 'YYYY-MM-DD HH:mm').toISOString();
1317
this.endDateTime = dayjs(this.endDate + ' ' + event.endHour, 'YYYY-MM-DD HH:mm').toISOString();
1418
}
1519
if (event.recurrence) {
1620
this.recurrence = [
1721
[
1822
'RRULE:FREQ=WEEKLY',
19-
'UNTIL=' + event.recurrence.endDate.format('YYYYMMDDTHHmmss[Z]'),
23+
'UNTIL=' + event.recurrence.endDate.add(1, 'day').format('YYYYMMDDTHHmmss[Z]'),
2024
'INTERVAL=' + event.recurrence.interval,
2125
'WKST=MO', // the week start date
2226
'BYDAY=' + event.recurrence.days.map(this.weekdayToRruleShortcut).join(','),
2327
].join(';'),
28+
...this.generateExDates(event.recurrence.exDates, event.startHour),
2429
];
2530
}
2631

@@ -65,4 +70,20 @@ export default class CalendarEvent {
6570
'niedziela': 'SU',
6671
}[weekday];
6772
}
73+
74+
generateExDates(dates, startHour) {
75+
const exRules = [];
76+
if (dates) {
77+
dates.forEach((date => {
78+
if (date.length === 1) {
79+
date[1] = date[0];
80+
}
81+
while(date[0].isSameOrBefore(date[1])) {
82+
exRules.push(`EXDATE;TZID=Europe/Warsaw:${date[0].format(`YYYYMMDDT${startHour.split(':').join('')}00`)}`);
83+
date[0] = date[0].add(1, 'day');
84+
}
85+
}));
86+
}
87+
return exRules;
88+
}
6889
}

src/googleCalendar/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ export default async function addAndFillInCalendar(data, statusBox) {
3333
statusBox.setOperationStatus("Trwa dodawanie zajęć...");
3434
await addLessons(calendarId, data, semesterStartDate, semesterEndDate);
3535

36-
// TODO addHolidays
3736
statusBox.setOperationStatus("Trwa dodawanie dni wolnych...");
3837
await addHolidays(calendarId, data.holidays);
3938

40-
// TODO removeLessonsOnHolidays
41-
4239
statusBox.setOperationStatus(`Kalendarz „${data.calendarName}” został dodany`, false);
4340
} catch (error) {
4441
console.error(error);
@@ -117,6 +114,7 @@ async function addLessons(calendarId, data, semesterStartDate, semesterEndDate)
117114
endDate: semesterEndDate,
118115
days: [lesson.weekday],
119116
interval: interval,
117+
exDates: getParsedHolidayDates(data.holidays),
120118
}
121119
});
122120

src/helpers.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,4 @@ export const weekdays = ['poniedziałek', 'wtorek', 'środa', 'czwartek', 'piąt
2828

2929
export function weekdaySort(a, b) {
3030
return weekdays.indexOf(a.weekday) - weekdays.indexOf(b.weekday);
31-
}
32-
33-
// export function addDays(date, days) {
34-
// const result = new Date(date);
35-
// result.setDate(result.getDate() + days);
36-
// return result;
37-
// }
31+
}

0 commit comments

Comments
 (0)