项目作者: xou816

项目描述 :
Emploi du temps倒中央
高级语言: JavaScript
项目地址: git://github.com/xou816/edt-ecn.git
创建时间: 2017-08-23T17:24:08Z
项目社区:https://github.com/xou816/edt-ecn

开源协议:

下载


ECN calendars not supported at the moment :(

edt-ecn

A API + React app to aggregate and filter calendars for Centrale Nantes. Calendars are served as JSON or ICS.

You can find it here: edt-ecn.herokuapp.com.

Docker usage

Build

Using a build image for the client:

  1. cd client
  2. docker build -f Dockerfile.build -t edt-ecn-build-client .
  3. docker run --rm -e PUBLIC='http://localhost' -v $PWD/src:/var/app/src -v $PWD/build/:/var/app/build edt-ecn-build-client:latest

The PUBLIC variable has to be adapted.

Same for the API:

  1. cd api
  2. docker build -f Dockerfile.build -t edt-ecn-build-api .
  3. docker run --rm -v $PWD/src:/var/app/src -v $PWD/build/:/var/app/build edt-ecn-build-api:latest

Build the actual image (with a proper tag for Heroku):

  1. # from root folder
  2. docker build -t registry.heroku.com/edt-ecn/web -f Dockerfile.web .

Run

To run it on port 80, proceed as such (create a network, start a Redis container):

  1. docker network create edt
  2. docker run --network edt --name myredis -d redis
  3. docker run -p 80:3000 --network edt -e REDISTOGO_URL='http://redis:@myredis:6379' registry.heroku.com/edt-ecn/web:latest

The REDISTOGO_URL variable is used by Heroku, but can be used to work locally with a Redis container (required).

Development

You need to have a Redis instance running locally (locahost:6379).

API

  1. npm run build
  2. npm start

Alternatively, run Typescript in watch mode when developping (you will still have to restart the API manually).

  1. npm run watch
  2. npm start

Client

If building and running locally, set the PUBLIC environment variable so that it matches where you client will run (http://localhost:3000 by default).

Build the Express app (proxies API calls to the actual API + performs SSR):

  1. npm run build-back

Build the frontend with Webpack:

  1. export PUBLIC=http://localhost:3000
  2. npm run build-front

Run the frontend with live-reload:

  1. npm run dev

Run the Express app:

  1. npm run start

Aggregated and filtered calendars

Calendar formats

The original calendars are found here. Each calendar has a unique identifier, which can be used to retrieve it using the API :

  1. /api/calendar/custom/:id.ics

or

  1. /api/calendar/custom/:id

for the JSON version, which looks like this:

  1. {
  2. "meta": [
  3. {
  4. "id": "g999",
  5. "filter": [
  6. 1, 2, 3
  7. ]
  8. }
  9. ],
  10. "version": "version_one",
  11. "events": [
  12. {
  13. "id": "2522",
  14. "colour": "#7FFF7F",
  15. "start": "2025-09-04T06:00:00.000Z",
  16. "end": "2025-09-04T08:00:00.000Z",
  17. "subject": "SUBJECT",
  18. "full_subject": "Subject but Fancier",
  19. "location": "R217",
  20. "description": "...",
  21. "organizer": "teacher@ec-nantes.fr",
  22. "calendar": "g999",
  23. "category": "CM"
  24. }
  25. ]
  26. }

Calendar aggregation

Multiple calendars can be aggregated.

  1. /api/calendar/custom/g304+g305.ics

Calendars are separated by a +. Filtered and unfiltered calendars can be aggregated.

Finding a free room

A utility to search for a free room (WIP).

  1. /api/freeroom/:from/:to

Parameters are UNIX timestamps.