Google calendar integration
Two paths: weekly classes from the timetable, and all-day academic events. Related: Academic calendar, PNG/PDF.
Split#
flowchart TB
subgraph tt [Timetable]
GCB[GoogleCalendarButton]
Cal[utils/calendar.ts]
GCB --> Cal
end
subgraph ac [Academic]
CC[CalendarContent]
AC[utils/calendar-AC.ts]
CC --> AC
end
GSI[accounts.google.com/gsi/client]
GSI --> GCB
GSI --> CC
Cal --> API[calendar.googleapis.com/v3]
AC --> APILayout already injects apis.google.com/js/api.js and GSI. The button also appends GSI on mount.
Timetable button#
website/components/timeline/google-calendar-button.tsx
NEXT_PUBLIC_GOOGLE_CLIENT_ID, scope https://www.googleapis.com/auth/calendar.events, popup, hosted_domain: gmail.com.
sequenceDiagram participant U as User participant B as GoogleCalendarButton participant G as GSI participant C as createGoogleCalendarEvents participant API as Calendar v3 U->>B: click B->>G: initTokenClient G-->>B: access_token B->>C: WeekSchedule C-->>B: event bodies B->>API: POST primary/events (allSettled)
Event shape (classes)#
DTSTART/DTENDnext occurrence of that weekday,Asia/Kolkata- Summary:
{type} - {subject_name} - Location from the slot
RRULE:FREQ=WEEKLY;UNTIL=~5 months, skipped fortype === "C"- Same module can download a
.icswithout OAuth
Academic events#
All-day VALUE=DATE. End is the day after end.date. Holiday titles get a different color hint where the API allows it. iCal download does not need OAuth.
Failures#
Promise.allSettled on class POSTs. Partial failure alerts “Some events could not be added”. Token errors log and alert. No server-side refresh token.