feat: usos sign-in, private calendar feed and timetable archive

This commit is contained in:
hh committed 2026-10-11 00:47:38 +00:00
commit 7d4e21f977
33 files changed
+3270

No files matched your search

+115
View File
@@ -0,0 +1,115 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<title>usoscal</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%231f6f54'/%3E%3Cpath d='M4 6h8M4 9h8M4 12h5' stroke='%23fff' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E">
<style>
:root {
color-scheme: light dark;
--bg: #f6f5f1; --ink: #1c1d1a; --soft: #5d6058; --line: #d9d7ce; --field: #fff;
--accent: #1f6f54; --on-accent: #fff; --warn: #9a3b1e;
}
@media (prefers-color-scheme: dark) {
:root { --bg: #151714; --ink: #e9e8e1; --soft: #a2a59b; --line: #33362f; --field: #1d201c; --accent: #6cc3a0; --on-accent: #0d1a14; --warn: #f0997a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 38rem; margin: 0 auto; padding: 3.5rem 1.25rem 4rem; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; text-wrap: pretty; }
.date { white-space: nowrap; }
.lede { color: var(--soft); margin-bottom: 2rem; }
.soft { color: var(--soft); font-size: .9rem; }
.warn { color: var(--warn); }
section { border-top: 1px solid var(--line); padding: 1.5rem 0 .75rem; }
form { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
input[type=text] { flex: 1 1 16rem; min-width: 0; font: .85rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; padding: .6rem .7rem; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 6px; }
button, .button { font: inherit; font-weight: 550; padding: .55rem .95rem; border-radius: 6px; border: 1px solid var(--line); background: var(--field); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.danger { color: var(--warn); }
button:focus-visible, .button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: flex; gap: .55rem; align-items: baseline; padding: .5rem 0; margin-bottom: .1rem; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); transform: translateY(1px); }
</style>
</head>
<body>
<main>
<h1>usoscal</h1>
<p class="lede">Your USOS timetable as a calendar subscription that can keep the classes that have already passed.</p>
{{if .Error}}
<section>
<p class="warn">{{.Error}}</p>
<p><a class="button" href="/">Back</a></p>
</section>
{{else if not .SignedIn}}
<section>
<p>Sign in with your university account and you get a private calendar address for Google Calendar, Apple Calendar, Outlook or anything else that reads iCalendar. Every class carries the course, the class type, the room with the building address, and the lecturer.</p>
<p>USOS only exports what is ahead of today. Turn on the archive and past classes stay in your calendar.</p>
<form class="row" method="post" action="/login"><button class="primary">Sign in with USOS</button></form>
<p class="soft">USOS will ask you to allow reading your studies and to keep that access while you are offline, which the daily update needs. The access tokens are stored encrypted, and signing out revokes them.</p>
</section>
{{else}}
<p>Signed in as <strong>{{.Name}}</strong>.</p>
{{if not .Connected}}
<section>
<p class="warn">{{if .SyncError}}{{.SyncError}}{{else}}USOS access is missing. Sign in again to resume updates.{{end}}</p>
<form class="row" method="post" action="/login"><button class="primary">Sign in with USOS again</button></form>
</section>
{{end}}
<section>
<h2>Calendar address</h2>
{{if .FeedURL}}
<div class="row">
<input type="text" readonly value="{{.FeedURL}}" aria-label="Calendar address">
<a class="button primary" href="{{.WebcalURL}}">Subscribe</a>
</div>
<p class="soft">Add it as a subscription by URL, not as a file import, so it keeps updating. Anyone who has this address can read your timetable. Issuing a new one or revoking it stops the current address at once.</p>
<div class="row">
<form method="post" action="/link"><button name="action" value="rotate">Issue a new address</button></form>
<form method="post" action="/link"><button class="danger" name="action" value="revoke">Revoke</button></form>
</div>
{{else}}
<p>There is no active address.</p>
<form class="row" method="post" action="/link"><button class="primary" name="action" value="rotate">Create an address</button></form>
{{end}}
</section>
<section>
<h2>Archive</h2>
<form method="post" action="/archive">
<label><input type="checkbox" name="archive" {{if .Archive}}checked{{end}}> <span>Keep classes after they have passed</span></label>
<p class="soft">The first run also fetches earlier terms, as far back as USOS still has them. Turning the archive off deletes the stored past.</p>
<div class="row"><button>Save</button></div>
</form>
{{if .Backfilling}}<p class="soft">Earlier terms are being fetched, reload in a minute.</p>{{end}}
</section>
<section>
<h2>Status</h2>
<p class="soft">
{{if .Events}}{{.Events}} classes in the calendar, the earliest on <span class="date">{{.First}}</span>.{{else}}No classes in the calendar yet.{{end}}
{{if .Synced}}Last updated from USOS on <span class="date">{{.Synced}}</span>.{{else if .Connected}}The first update is running, reload in a minute.{{end}}
</p>
{{if and .Connected .SyncError}}<p class="warn">{{.SyncError}}</p>{{end}}
</section>
<section>
<h2>Sign out</h2>
<form method="post" action="/logout">
<p class="soft">Signing out revokes this app's access in USOS, deletes the stored tokens and stops the calendar address.</p>
<label><input type="checkbox" name="delete"> <span>Also delete my stored timetable</span></label>
<div class="row"><button class="danger">Sign out and disconnect</button></div>
</form>
</section>
{{end}}
</main>
</body>
</html>