From e19c9dc612b689f3b81ee05e8c7efb9147706586 Mon Sep 17 00:00:00 2001
From: Nic Limper
Date: Thu, 23 Mar 2023 23:40:06 +0100
Subject: [PATCH] added content: google calendar
via google apps script, see /data/calendar.txt
---
ESP32_AP-Flasher/data/calendar.txt | 46 +++++++++
ESP32_AP-Flasher/data/www/index.html | 1 +
ESP32_AP-Flasher/data/www/main.js | 3 +-
ESP32_AP-Flasher/include/contentmanager.h | 3 +-
ESP32_AP-Flasher/platformio.ini | 2 +-
ESP32_AP-Flasher/src/contentmanager.cpp | 118 +++++++++++++++++++++-
6 files changed, 168 insertions(+), 5 deletions(-)
create mode 100644 ESP32_AP-Flasher/data/calendar.txt
diff --git a/ESP32_AP-Flasher/data/calendar.txt b/ESP32_AP-Flasher/data/calendar.txt
new file mode 100644
index 00000000..5997a802
--- /dev/null
+++ b/ESP32_AP-Flasher/data/calendar.txt
@@ -0,0 +1,46 @@
+To use Google Apps Script to get all events for the next day and return them via JSON in a web app, you can follow these steps:
+
+Create a new Google Apps Script project by going to https://script.google.com and clicking on "New project".
+
+In the script editor, create a new function called "getEventsForNextDay" that will fetch all events for the next day and return them in JSON format:
+
+function getEventsForNextDay() {
+ var start = new Date();
+ var end = new Date();
+ end.setDate(end.getDate() + 1);
+ var calendars = CalendarApp.getAllCalendars();
+ var events = [];
+ for (var i = 0; i < calendars.length; i++) {
+ var calendar = calendars[i];
+ var eventsInCalendar = calendar.getEvents(start, end);
+ for (var j = 0; j < eventsInCalendar.length; j++) {
+ var event = eventsInCalendar[j];
+ events.push({
+ title: event.getTitle(),
+ start: Math.floor(event.getStartTime().getTime() / 1000),
+ end: Math.floor(event.getEndTime().getTime() / 1000),
+ location: event.getLocation(),
+ description: event.getDescription()
+ });
+ }
+ }
+ // Sort events by start date/time
+ events.sort(function(a, b) {
+ return a.start - b.start;
+ });
+ return JSON.stringify(events);
+}
+
+function doGet() {
+ var content = getEventsForNextDay();
+ var output = ContentService.createTextOutput(content);
+ output.setMimeType(ContentService.MimeType.JSON);
+ return output;
+}
+
+
+This function calls the getEventsForNextDay() function to get the events in JSON format, creates a text output with the JSON content, sets the MIME type to JSON, and returns the output.
+
+Deploy the web app by clicking on "Deploy > New Deployment" in the script editor. Choose "Web app" as the deployment type, set the access to "Anyone, even anonymous", and click on "Deploy". Make sure to take note of the web app URL generated by Google.
+
+Test the web app by visiting the web app URL in a web browser. You should see the events for the next day in JSON format.
diff --git a/ESP32_AP-Flasher/data/www/index.html b/ESP32_AP-Flasher/data/www/index.html
index 337e9c9e..9b70dc31 100644
--- a/ESP32_AP-Flasher/data/www/index.html
+++ b/ESP32_AP-Flasher/data/www/index.html
@@ -35,6 +35,7 @@
+