-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·105 lines (90 loc) · 3.53 KB
/
Copy pathindex.php
File metadata and controls
executable file
·105 lines (90 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// https://github.com/LindaLawton/Google-APIs-PHP-Samples/tree/master/Samples/Calendar%20API
require_once('api.php');
use \StopLight\Settings;
use Phpfastcache\Helper\Psr16Adapter;
$defaultDriver = 'Files';
$cache = new Psr16Adapter($defaultDriver);
$lost_connection = false;
$credentialsPath = __DIR__ . DIRECTORY_SEPARATOR . 'credentials' . DIRECTORY_SEPARATOR . 'credentials.json';
$client = getGoogleClient($credentialsPath);
$settings = new Settings(__DIR__ . '/settings.json');
$calendar = null;
$calendarId = null;
try {
if ($client) {
$calendar = new Google\Service\Calendar($client);
} else {
throw new Exception('No Google client');
}
} catch (Exception $e) {
$lost_connection = true;
}
$calendarList = get_calendar_list($calendar);
if (!isset($_GET['c'])) {
if (!empty($settings->get('calendarId'))) {
$calendarId = $settings->get('calendarId');
} else {
$calendarId = $calendarList[0];
}
header('Location: ?c=' . $calendarId);
} else {
$calendarId = $_GET['c'];
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Stoplight</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="./css/main.css"/>
</head>
<body>
<main id="frame">
<h1 class="w-100 fs-1" id="status">Loading</h1>
<h2 class="w-100 fs-6 m-0" id="subtitle"></h2>
<pre id="error-msg"></pre>
<footer class="fw-lighter fs-6 opacity-25">
<div class="p-1 d-inline position-fixed bottom-0 start-0" id="calendar-id"><?php print $calendarId; ?></div>
<div class="p-1 d-inline position-fixed bottom-0 end-0" id="event-type"></div>
</footer>
</main>
<nav class="navbar fixed-top bg-transparent navbar--closed" data-bs-theme="dark" id="navbar">
<div class="container-fluid justify-content-end gap-2">
<div class="d-flex">
<form class="" id="form">
<label class="text-light" for="calendar">Calendar:</label>
<select id="calendar" name="c">
<?php print_calendar_options($calendarList, $calendarId); ?>
</select>
</form>
<button type="button" class="btn-close" aria-label="Close Settings" id="close"></button>
<a class="btn btn-light btn-sm" id="open">
<span class="visually-hidden">Settings</span>
<i class="bi-gear"></i>
</a>
</div>
<div class="d-flex justify-content-end">
<a href="#" id="fs" class="btn btn-light btn-sm">
<span class="visually-hidden">Fullscreen</span>
<i class="bi bi-arrows-fullscreen"></i>
</a>
</div>
</div>
</nav>
<span id="bar" class="bar"></span>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
<script type="text/javascript">
import('./js/main.js').then((module) => {
module.main.init('/endpoint.php?c=<?php print $calendarId; ?>');
});
</script>
</body>
</html>