Calendar (Dynamic)
Use this calendar if you want to integrate your class’s Google Calendar into the website.
Directions
- Ensure there is a calendar for your course. You may reuse the previous semester’s calendar if it exists. We suggest that calendars belong to a course’s SPA. Directions for creating a new calendar here.
- In the calendar’s settings under “Access permissions for events,” ensure that “Make calendar available to public” is checked and the dropdown next to it is set to “See all event details,” otherwise your calendar events won’t show up.
- In
config.yml, setgoogle_calendar_idto the calendar’s Calendar ID from the settings page. - If there is not a Google Cloud project associated with your course, create a new project. You should ensure that the project you create is associated with your course SPA, or at the very least a @berkeley.edu email. Doing so will ensure that you create the project under Berkeley/Learning and any associated billing will be taken care of by the university.
- Enable the Google Calendar API. Instructions here
- Create a Google API Key. You may be able to reuse the previous semester’s API key if one exists.
- Open the Google Cloud Console
- Access “APIs & Services” from the left side bar.
- Click “Create credentials” -> “API key.” Set
google_api_keyinconfig.ymlto the key you obtain. - Click on the newly created key to update the settings. Rename the key to something more useful like “COURSE NAME Calendar Key.” Under “Application restrictions” choose “Websites” and add a restriction for your course website (use the single domain, e.g. “https://data8.com”). You should also restrict the APIs that can be accessed with the key (only select the Google Calendar API). Don’t forget to click “Save.”
- Create calendar events for your class using this new calendar.
- You may want to take advantage of the recurring event feature.
- View/edit event types in the
event_typessection ofconfig.yml. Your Google Calendar titles should have the appropriate prefix or suffix matching these event types. For example, if your calendar event title is “[Data 101] Lecture”,_config.ymlshould havesuffix: Lecture. If instead, your calendar event title is “Lecture - Pivots and Joins”,_config.ymlshould haveprefix: Lecture. We recommend only changingsuffix/prefixand none of the other fields.
As long as you have properly restricted your API key (see above), it is fine to publicly commit the API key (the key is also visible on client side even if your course website repo is private; this is unavoidable).
Google Cloud does not support localhost for allowed websites, so you will only be able to check if the dynamic calendar works by deploying your website with these changes.
The above directions are based loosely on this which is now out of date.
Properties of event_types in config.yml
prefix/suffix: Looks at the prefix / suffix of an event and sets the styling if it finds a match (see above).background_color: Hex code for the background color.text_color: Hex code for the text color.class: Class ID of the event (e.g.cal-lecturefor lecture events).icon: Fontawesome icon placed on the event (e.g.fa-school), more can be found infontawesome/cssor by visiting fontawesome.
Note: As you update the calendar, you’ll find that some files use the phrase “fullcalendar” and some use “calendar_dynamic”. Both refer to the dynamic calendar. fullcalendar is an open source JavaScript calendar we’re using to deliver the dynamic calendar.