Web UI: static HTML/CSS/JS frontend, hosted separately from the API
CI / lint (push) Successful in 9s
CI / test (push) Successful in 31s
CI / notify (push) Successful in 5s

- Plain HTML + vanilla JS modules, no build step; talks to /api/v1 with
  a bearer token and only ever inserts server data as text
- Overview: now-playing dot-matrix display with live progress, totals,
  30-day plays meter, top artists/tracks by period, recent plays
- History (paged, grouped by day), Apps (create/delete, reveal/copy
  keys, player setup details), Sessions (revoke), sign-in approval page
  for the Last.fm desktop auth flow, sign in and registration
- Light and dark themes, responsive to phone widths, vendored fonts
  (SIL OFL) so the UI has no third-party requests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 14:11:37 +01:00
1 parent 0d49311848
commit b509cd2b60
24 files changed
+1879

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Allow access · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/approve.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<div class="auth" id="approve"></div>
</main>
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Apps · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/apps.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<h1 class="page-title">Apps</h1>
<p class="lede">Each player or scrobbler you connect needs an API key and shared secret. Create one per app, so you can remove any of them without affecting the others.</p>
<div id="messages"></div>
<section aria-labelledby="new-title">
<h2 id="new-title" class="visually-hidden">Create an app</h2>
<form class="inline-form" id="create-app">
<div class="field">
<label for="app-name">App name</label>
<input id="app-name" name="name" required maxlength="100" placeholder="Living room player" autocomplete="off">
</div>
<button class="button" type="submit">Create app</button>
</form>
</section>
<section aria-labelledby="apps-title">
<h2 id="apps-title" class="section-head">Your apps</h2>
<ul class="rows" id="apps"></ul>
</section>
<section class="setup" aria-labelledby="setup-title">
<h2 id="setup-title">Connecting a player</h2>
<p class="muted">In your player's scrobbling settings, choose a custom Last.fm-compatible server and enter:</p>
<dl id="setup"></dl>
</section>
</main>
</body>
</html>
+5
View File
@@ -0,0 +1,5 @@
// Where the Scrobbler API lives. The UI container rewrites this file from the
// API_BASE_URL environment variable at start-up; edit it by hand otherwise.
window.SCROBBLER_CONFIG = {
apiBaseUrl: "http://localhost:5050",
};
+781
View File
@@ -0,0 +1,781 @@
@import url("../fonts/fonts.css");
/* ---- Tokens ------------------------------------------------------------------
Paper and ink carry the page; the panel is a hi-fi front panel whose amber
display glow is used nowhere else. */
:root {
color-scheme: light;
--paper: #e8ecf1;
--paper-raised: #f4f6f9;
--ink: #18202c;
--ink-soft: #4a5566;
--slate: #5b6b82;
--rule: #c9d0da;
--bar: #cdd6e2;
--danger: #b3412e;
--ok: #2f6e4f;
--focus: #2f5da8;
--panel: #1c2330;
--panel-edge: #2a3445;
--panel-text: #b9c3d2;
--glow: #f2a541;
--glow-dim: #3a3326;
--font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
--font-display: "Doto", "Instrument Sans", monospace;
/* Type scale: a 1.25 ratio on a 16px base */
--step--1: 0.8rem;
--step-0: 1rem;
--step-1: 1.25rem;
--step-2: 1.563rem;
--step-3: 1.953rem;
--step-4: 2.441rem;
--radius-control: 6px;
--radius-panel: 14px;
--measure: 70ch;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
color-scheme: dark;
--paper: #12171f;
--paper-raised: #19202b;
--ink: #e3e8ef;
--ink-soft: #a7b1c0;
--slate: #8795aa;
--rule: #2c3543;
--bar: #273142;
--danger: #e0806c;
--ok: #7cc3a0;
--focus: #8fb4f0;
--panel: #0b0f16;
--panel-edge: #232c3a;
}
}
:root[data-theme="dark"] {
color-scheme: dark;
--paper: #12171f;
--paper-raised: #19202b;
--ink: #e3e8ef;
--ink-soft: #a7b1c0;
--slate: #8795aa;
--rule: #2c3543;
--bar: #273142;
--danger: #e0806c;
--ok: #7cc3a0;
--focus: #8fb4f0;
--panel: #0b0f16;
--panel-edge: #232c3a;
}
/* ---- Base ----------------------------------------------------------------- */
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--paper);
color: var(--ink);
font-family: var(--font-ui);
font-size: var(--step-0);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
line-height: 1.15;
margin: 0;
font-weight: 650;
letter-spacing: -0.01em;
}
h1 {
font-size: var(--step-3);
}
h2 {
font-size: var(--step-1);
}
p {
margin: 0;
max-width: var(--measure);
}
a {
color: inherit;
text-underline-offset: 0.2em;
text-decoration-thickness: 1px;
}
:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
code {
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.9em;
overflow-wrap: anywhere;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* ---- Shell ---------------------------------------------------------------- */
.site-header {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem 2rem;
max-width: 1120px;
margin: 0 auto;
padding: 1.25rem 16px;
}
.brand {
display: inline-flex;
align-items: center;
gap: 0.6rem;
font-weight: 700;
font-size: var(--step-1);
text-decoration: none;
}
/* A small round "power" lamp */
.brand-mark {
width: 0.7rem;
height: 0.7rem;
border-radius: 50%;
background: var(--glow);
box-shadow: 0 0 0 3px var(--panel), 0 0 10px 1px color-mix(in srgb, var(--glow) 60%, transparent);
}
.site-header nav ul {
display: flex;
flex-wrap: wrap;
gap: 0.25rem 1.25rem;
margin: 0;
padding: 0;
list-style: none;
}
.site-header nav a {
color: var(--ink-soft);
text-decoration: none;
padding: 0.25rem 0;
border-bottom: 2px solid transparent;
}
.site-header nav a:hover {
color: var(--ink);
}
.site-header nav a[aria-current="page"] {
color: var(--ink);
border-bottom-color: var(--ink);
}
.account {
margin-left: auto;
display: flex;
gap: 1rem;
align-items: baseline;
color: var(--ink-soft);
}
main {
max-width: 1120px;
margin: 0 auto;
padding: 0.5rem 16px 4rem;
}
.page-title {
margin: 1.5rem 0 0.5rem;
}
.lede {
color: var(--ink-soft);
margin-bottom: 2rem;
}
section + section {
margin-top: 3rem;
}
.section-head {
display: flex;
flex-wrap: wrap;
align-items: baseline;
justify-content: space-between;
gap: 0.75rem 1.5rem;
margin-bottom: 1rem;
}
/* ---- Controls ------------------------------------------------------------- */
button,
input {
font: inherit;
color: inherit;
}
.button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
min-height: 2.5rem;
padding: 0.4rem 1.1rem;
border: 1px solid var(--ink);
border-radius: var(--radius-control);
background: var(--ink);
color: var(--paper);
font-weight: 600;
cursor: pointer;
text-decoration: none;
}
.button:hover {
background: color-mix(in srgb, var(--ink) 85%, var(--paper));
}
.button[disabled] {
opacity: 0.6;
cursor: progress;
}
.button-quiet {
background: transparent;
color: var(--ink);
border-color: var(--rule);
}
.button-quiet:hover {
background: var(--paper-raised);
}
.button-danger {
background: var(--danger);
border-color: var(--danger);
color: #fff;
}
.button-danger:hover {
background: color-mix(in srgb, var(--danger) 85%, #000);
}
.link-button {
border: 0;
padding: 0;
background: none;
color: var(--ink-soft);
text-decoration: underline;
text-underline-offset: 0.2em;
cursor: pointer;
}
.link-button:hover {
color: var(--ink);
}
.field {
display: grid;
gap: 0.35rem;
margin-bottom: 1.1rem;
}
.field label {
font-weight: 600;
}
.field .hint {
color: var(--ink-soft);
font-size: var(--step--1);
}
.field input {
min-height: 2.6rem;
padding: 0.5rem 0.75rem;
border: 1px solid var(--rule);
border-radius: var(--radius-control);
background: var(--paper-raised);
}
.field input:focus-visible {
border-color: var(--focus);
}
.inline-form {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
align-items: end;
}
.inline-form .field {
flex: 1 1 16rem;
margin: 0;
}
/* Segmented control, like an input selector on an amplifier */
.selector {
display: inline-flex;
margin: 0;
min-inline-size: 0;
border: 0;
padding: 3px;
border-radius: calc(var(--radius-control) + 3px);
background: var(--panel);
gap: 2px;
}
.selector input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.selector label {
padding: 0.3rem 0.8rem;
border-radius: var(--radius-control);
color: var(--panel-text);
font-size: var(--step--1);
font-weight: 600;
cursor: pointer;
}
.selector input:checked + label {
background: var(--panel-edge);
color: var(--glow);
}
.selector input:focus-visible + label {
outline: 2px solid var(--glow);
outline-offset: 1px;
}
.notice {
padding: 0.75rem 1rem;
border-radius: var(--radius-control);
border-left: 4px solid var(--slate);
background: var(--paper-raised);
margin-bottom: 1.25rem;
}
.notice-error {
border-left-color: var(--danger);
}
.notice-ok {
border-left-color: var(--ok);
}
.muted {
color: var(--ink-soft);
}
.empty {
color: var(--ink-soft);
padding: 1.5rem 0;
}
/* ---- Front panel (overview) ---------------------------------------------- */
.panel {
display: grid;
grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
grid-template-areas:
"display readouts"
"spectrum spectrum";
gap: 1.5rem 2rem;
padding: 1.75rem;
margin: 1.5rem 0 3rem;
border-radius: var(--radius-panel);
background: var(--panel);
color: var(--panel-text);
box-shadow: inset 0 1px 0 var(--panel-edge);
}
.display {
grid-area: display;
min-height: 9.5rem;
padding: 1.1rem 1.25rem;
border-radius: 8px;
background: #06080c;
box-shadow: inset 0 0 0 1px var(--panel-edge), inset 0 8px 24px rgb(0 0 0 / 0.6);
overflow: hidden;
}
.display-status {
font-size: var(--step--1);
color: var(--slate);
margin-bottom: 0.4rem;
}
.display-track {
font-family: var(--font-display);
font-weight: 700;
font-size: clamp(1.6rem, 4vw, var(--step-4));
line-height: 1.05;
color: var(--glow);
text-shadow: 0 0 12px color-mix(in srgb, var(--glow) 55%, transparent);
overflow-wrap: anywhere;
}
.display-idle .display-track {
color: var(--glow-dim);
text-shadow: none;
}
.display-meta {
margin-top: 0.5rem;
color: var(--panel-text);
}
.display-meta strong {
color: #e6ebf2;
font-weight: 600;
}
.progress {
display: flex;
align-items: center;
gap: 0.75rem;
margin-top: 0.9rem;
font-size: var(--step--1);
font-variant-numeric: tabular-nums;
color: var(--slate);
}
.progress-track {
flex: 1;
height: 3px;
background: var(--glow-dim);
border-radius: 2px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: var(--glow);
width: 0;
}
.readouts {
grid-area: readouts;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
align-content: center;
gap: 1rem;
margin: 0;
}
.readouts div {
display: grid;
gap: 0.15rem;
}
.readouts dt {
font-size: var(--step--1);
color: var(--slate);
order: 2;
}
.readouts dd {
margin: 0;
font-size: var(--step-2);
font-weight: 650;
color: #e6ebf2;
font-variant-numeric: tabular-nums;
}
.spectrum {
grid-area: spectrum;
}
.spectrum svg {
display: block;
width: 100%;
height: 96px;
}
.spectrum .seg-on {
fill: var(--glow);
}
.spectrum .seg-off {
fill: var(--glow-dim);
}
.spectrum-axis {
display: flex;
justify-content: space-between;
margin-top: 0.5rem;
font-size: var(--step--1);
color: var(--slate);
}
/* ---- Ranked lists --------------------------------------------------------- */
.charts {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
gap: 2.5rem 3rem;
}
.ranking {
list-style: none;
margin: 0;
padding: 0;
}
.ranking li {
position: relative;
display: grid;
grid-template-columns: 2rem minmax(0, 1fr) auto;
gap: 0.75rem;
align-items: baseline;
padding: 0.55rem 0;
border-bottom: 1px solid var(--rule);
}
.ranking .rank {
color: var(--slate);
font-variant-numeric: tabular-nums;
text-align: right;
}
.ranking .name {
overflow-wrap: anywhere;
}
.ranking .by {
display: block;
color: var(--ink-soft);
font-size: var(--step--1);
}
.ranking .plays {
font-variant-numeric: tabular-nums;
color: var(--ink-soft);
}
/* Relative play count, drawn as a hairline meter along the row's bottom edge */
.ranking .meter {
position: absolute;
left: 2.75rem;
bottom: -1px;
height: 2px;
background: var(--slate);
}
/* ---- Listening log -------------------------------------------------------- */
.log {
list-style: none;
margin: 0;
padding: 0;
}
.log li {
display: grid;
grid-template-columns: 8rem minmax(0, 1fr);
gap: 1rem;
padding: 0.6rem 0;
border-bottom: 1px solid var(--rule);
}
/* Clock times (HH:MM) need far less room than relative times */
.log-clock li {
grid-template-columns: 3.5rem minmax(0, 1fr);
}
.log time {
color: var(--ink-soft);
font-variant-numeric: tabular-nums;
}
.log .track {
font-weight: 600;
}
.log .by {
color: var(--ink-soft);
}
.log-day {
margin: 2rem 0 0.25rem;
font-size: var(--step-0);
color: var(--ink-soft);
font-weight: 600;
}
.pager {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
margin-top: 2rem;
}
/* ---- Apps & sessions ------------------------------------------------------ */
.rows {
list-style: none;
margin: 0;
padding: 0;
border-top: 1px solid var(--rule);
}
.rows > li {
padding: 1.1rem 0;
border-bottom: 1px solid var(--rule);
}
.row-head {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: baseline;
gap: 0.5rem 1rem;
}
.row-title {
font-weight: 650;
font-size: var(--step-1);
}
.keys {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
gap: 0.4rem 1rem;
margin: 0.9rem 0 0;
}
.keys dt {
color: var(--ink-soft);
}
.keys dd {
margin: 0;
display: flex;
flex-wrap: wrap;
gap: 0.5rem 1rem;
align-items: baseline;
}
.confirm {
display: inline-flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
.setup {
padding: 1.25rem 1.5rem;
border-radius: var(--radius-panel);
background: var(--paper-raised);
border: 1px solid var(--rule);
}
.setup dl {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
gap: 0.5rem 1.25rem;
margin: 1rem 0 0;
}
.setup dt {
color: var(--ink-soft);
}
.setup dd {
margin: 0;
}
/* ---- Auth pages ----------------------------------------------------------- */
.auth {
max-width: 26rem;
margin: 3rem auto 0;
}
.auth h1 {
margin-bottom: 0.5rem;
}
.auth .lede {
margin-bottom: 1.75rem;
}
.auth .button {
width: 100%;
margin-top: 0.5rem;
}
.auth-alt {
margin-top: 1.5rem;
color: var(--ink-soft);
}
.approve-app {
font-family: var(--font-display);
font-weight: 700;
font-size: var(--step-3);
color: var(--glow);
background: var(--panel);
padding: 1rem 1.25rem;
border-radius: 8px;
margin: 1.25rem 0;
overflow-wrap: anywhere;
}
.button-row {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
/* ---- Small screens -------------------------------------------------------- */
@media (max-width: 760px) {
.panel {
grid-template-columns: minmax(0, 1fr);
grid-template-areas:
"display"
"readouts"
"spectrum";
padding: 1rem;
margin-inline: -8px;
}
.account {
margin-left: 0;
width: 100%;
}
.keys,
.setup dl {
grid-template-columns: minmax(0, 1fr);
}
.keys dt,
.setup dt {
margin-top: 0.4rem;
}
}
@media (prefers-reduced-motion: no-preference) {
.progress-fill {
transition: width 1s linear;
}
}
Binary file not shown.
Binary file not shown.
+39
View File
@@ -0,0 +1,39 @@
/* Vendored from Google Fonts. Doto and Instrument Sans are licensed under the SIL Open Font License 1.1. */
/* Doto latin-ext */
@font-face {
font-family: 'Doto';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(doto-latin-ext.woff) format('woff');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Doto latin */
@font-face {
font-family: 'Doto';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(doto-latin.woff) format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Instrument Sans latin-ext */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 400 700;
font-stretch: 100%;
font-display: swap;
src: url(instrument-sans-latin-ext.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Instrument Sans latin */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 400 700;
font-stretch: 100%;
font-display: swap;
src: url(instrument-sans-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
Binary file not shown.
Binary file not shown.
+21
View File
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>History · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/history.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<h1 class="page-title">History</h1>
<p class="lede" id="history-summary">Every track you've scrobbled, newest first.</p>
<div id="history"></div>
<nav class="pager" aria-label="Pages" id="pager"></nav>
</main>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Overview · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/dashboard.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<h1 class="visually-hidden">Overview</h1>
<div id="panel" class="panel" aria-live="polite"></div>
<section aria-labelledby="charts-title">
<div class="section-head">
<h2 id="charts-title">Most played</h2>
<fieldset class="selector" id="period">
<legend class="visually-hidden">Period</legend>
</fieldset>
</div>
<div class="charts">
<div><h3 class="muted">Artists</h3><ol class="ranking" id="top-artists"></ol></div>
<div><h3 class="muted">Tracks</h3><ol class="ranking" id="top-tracks"></ol></div>
</div>
</section>
<section aria-labelledby="recent-title">
<div class="section-head">
<h2 id="recent-title">Recently played</h2>
<a href="history.html">Full history</a>
</div>
<ol class="log" id="recent"></ol>
</section>
</main>
</body>
</html>
+89
View File
@@ -0,0 +1,89 @@
// Thin client for the Scrobbler /api/v1 JSON API.
const TOKEN_KEY = "scrobbler.token";
export const apiBase = (window.SCROBBLER_CONFIG?.apiBaseUrl || "http://localhost:5050").replace(/\/+$/, "");
export function getToken() {
try {
return localStorage.getItem(TOKEN_KEY);
} catch {
return null;
}
}
export function setToken(token) {
try {
if (token) localStorage.setItem(TOKEN_KEY, token);
else localStorage.removeItem(TOKEN_KEY);
} catch {
// Storage unavailable (private mode): the session lasts until the tab closes.
}
}
export class ApiError extends Error {
constructor(status, code, message, details) {
super(message);
this.status = status;
this.code = code;
this.details = details;
}
}
// Only same-site page names are allowed as a post-login destination.
export function safeNext(value) {
return /^[a-z]+\.html(\?[\w=&%.-]*)?$/.test(value || "") ? value : "index.html";
}
export function redirectToLogin() {
const here = location.pathname.split("/").pop() || "index.html";
location.href = `login.html?next=${encodeURIComponent(safeNext(here + location.search))}`;
}
export async function api(path, { method = "GET", body, auth = true } = {}) {
const headers = {};
if (body !== undefined) headers["Content-Type"] = "application/json";
const token = getToken();
if (auth && token) headers.Authorization = `Bearer ${token}`;
let response;
try {
response = await fetch(`${apiBase}/api/v1${path}`, {
method,
headers,
body: body === undefined ? undefined : JSON.stringify(body),
});
} catch {
throw new ApiError(0, "network", `Can't reach the Scrobbler API at ${apiBase}. Check that it's running.`);
}
if (response.status === 401 && auth) {
setToken(null);
redirectToLogin();
throw new ApiError(401, "unauthorized", "Your session has ended. Sign in again.");
}
if (response.status === 204) return null;
const data = await response.json().catch(() => null);
if (!response.ok) {
const error = data?.error ?? {};
throw new ApiError(
response.status,
error.code ?? "error",
error.message ?? `The API returned an error (${response.status}).`,
error.details,
);
}
return data;
}
// Turn webargs validation details into a single readable sentence.
export function describeError(error) {
const fields = error.details?.json ?? error.details?.query;
if (fields) {
return Object.entries(fields)
.map(([field, messages]) => `${field}: ${[].concat(messages).join(" ")}`)
.join(" ");
}
return error.message;
}
+61
View File
@@ -0,0 +1,61 @@
import { ApiError, api } from "./api.js";
import { errorBox, h, replace } from "./dom.js";
import { signedInPage } from "./layout.js";
const root = document.getElementById("approve");
const token = new URLSearchParams(location.search).get("token");
await signedInPage("");
if (!token) {
replace(root, h("h1", {}, "Nothing to approve"), h("p", { class: "lede" }, "This link is missing its token. Start signing in from your player again."));
} else {
try {
const info = await api(`/tokens/${encodeURIComponent(token)}`);
info.approved ? showApproved(info.app_name) : showRequest(info.app_name);
} catch (error) {
showProblem(error);
}
}
function showRequest(appName) {
const allow = h("button", { type: "button", class: "button" }, "Allow access");
allow.addEventListener("click", async () => {
allow.disabled = true;
try {
await api("/tokens/approve", { method: "POST", body: { token } });
showApproved(appName);
} catch (error) {
allow.disabled = false;
root.append(errorBox(error.message));
}
});
replace(
root,
h("h1", {}, "Allow access?"),
h("div", { class: "approve-app" }, appName),
h("p", { class: "lede" }, "It wants to scrobble to your account and read your listening history. You can revoke this at any time from Sessions."),
h("div", { class: "button-row" }, allow, h("a", { class: "button button-quiet", href: "index.html" }, "Don't allow")),
);
}
function showApproved(appName) {
replace(
root,
h("h1", {}, "Access allowed"),
h("div", { class: "approve-app" }, appName),
h("p", { class: "lede" }, "It can now scrobble to your account. Go back to it to finish signing in."),
h("a", { class: "button button-quiet", href: "sessions.html" }, "View sessions"),
);
}
function showProblem(error) {
const expired = error instanceof ApiError && error.status === 404;
replace(
root,
h("h1", {}, expired ? "This link has expired" : "Something went wrong"),
expired
? h("p", { class: "lede" }, "Sign-in links last an hour and work once. Start signing in from your player again to get a new one.")
: errorBox(error.message),
);
}
+122
View File
@@ -0,0 +1,122 @@
import { api, apiBase, describeError } from "./api.js";
import { errorBox, formatDate, h, replace } from "./dom.js";
import { signedInPage } from "./layout.js";
const list = document.getElementById("apps");
const messages = document.getElementById("messages");
const form = document.getElementById("create-app");
const user = await signedInPage("apps.html");
renderSetup();
await refresh();
form.addEventListener("submit", async (event) => {
event.preventDefault();
const button = form.querySelector("button");
button.disabled = true;
replace(messages);
try {
const created = await api("/apps", { method: "POST", body: { name: form.elements.name.value.trim() } });
form.reset();
await refresh(created.api_key);
replace(messages, h("p", { class: "notice notice-ok", role: "status" }, `Created ${created.name}. Copy its key and secret into the player.`));
} catch (error) {
replace(messages, errorBox(describeError(error)));
} finally {
button.disabled = false;
}
});
async function refresh(revealKey) {
try {
const apps = await api("/apps");
if (!apps.length) {
replace(list, h("li", { class: "empty" }, "No apps yet. Create one above for each player you want to connect."));
return;
}
replace(list, apps.map((app) => appRow(app, app.api_key === revealKey)));
} catch (error) {
replace(list, h("li", {}, errorBox(error.message)));
}
}
function appRow(app, reveal) {
const row = h("li");
const secret = h("code", {}, reveal ? app.shared_secret : "••••••••••••••••");
const toggle = h("button", { type: "button", class: "link-button" }, reveal ? "Hide" : "Show");
let shown = reveal;
toggle.addEventListener("click", () => {
shown = !shown;
secret.textContent = shown ? app.shared_secret : "••••••••••••••••";
toggle.textContent = shown ? "Hide" : "Show";
});
const actions = h("div", { class: "confirm" });
const askDelete = () =>
replace(
actions,
h("span", { class: "muted" }, "Players using this app stop scrobbling."),
h("button", { type: "button", class: "button button-danger", onclick: () => remove(app, actions) }, "Delete app"),
h("button", { type: "button", class: "button button-quiet", onclick: resetActions }, "Keep it"),
);
const resetActions = () =>
replace(actions, h("button", { type: "button", class: "button button-quiet", onclick: askDelete }, "Delete"));
resetActions();
return replace(
row,
h("div", { class: "row-head" }, h("span", { class: "row-title" }, app.name), actions),
h(
"dl",
{ class: "keys" },
h("dt", {}, "API key"),
h("dd", {}, h("code", {}, app.api_key), copyButton(app.api_key)),
h("dt", {}, "Shared secret"),
h("dd", {}, secret, toggle, copyButton(app.shared_secret)),
h("dt", {}, "Created"),
h("dd", {}, formatDate(app.created_at)),
),
);
}
async function remove(app, actions) {
try {
await api(`/apps/${encodeURIComponent(app.api_key)}`, { method: "DELETE" });
await refresh();
replace(messages, h("p", { class: "notice notice-ok", role: "status" }, `Deleted ${app.name}.`));
} catch (error) {
replace(actions, errorBox(error.message));
}
}
function copyButton(value) {
const button = h("button", { type: "button", class: "link-button" }, "Copy");
button.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(value);
button.textContent = "Copied";
} catch {
button.textContent = "Select and copy manually";
}
setTimeout(() => {
button.textContent = "Copy";
}, 2000);
});
return button;
}
function renderSetup() {
replace(
document.getElementById("setup"),
h("dt", {}, "API URL"),
h("dd", {}, h("code", {}, `${apiBase}/2.0/`)),
h("dt", {}, "Username"),
h("dd", {}, h("code", {}, user.username)),
h("dt", {}, "Password"),
h("dd", {}, "Your Scrobbler password"),
h("dt", {}, "Key and secret"),
h("dd", {}, "From one of the apps above"),
h("dt", {}, "API reference"),
h("dd", {}, h("a", { href: `${apiBase}/api/docs` }, "Interactive API docs")),
);
}
+255
View File
@@ -0,0 +1,255 @@
import { api } from "./api.js";
import { errorBox, formatDate, formatDuration, h, num, replace, timeAgo } from "./dom.js";
import { signedInPage } from "./layout.js";
const PERIODS = [
["7day", "7 days"],
["1month", "30 days"],
["12month", "12 months"],
["overall", "All time"],
];
const PERIOD_KEY = "scrobbler.period";
const SEGMENTS = 10; // lit segments per spectrum column at the busiest day
const NOW_PLAYING_POLL_MS = 30_000;
const panel = document.getElementById("panel");
const main = document.getElementById("main");
let progressTimer;
await signedInPage("index.html");
renderPeriodSelector();
await Promise.all([loadPanel(), loadTop(currentPeriod()), loadRecent()]).catch(showError);
setInterval(() => refreshDisplay().catch(() => {}), NOW_PLAYING_POLL_MS);
function showError(error) {
main.prepend(errorBox(error.message));
}
// ---- Front panel ------------------------------------------------------------
async function loadPanel() {
const [nowPlaying, summary, counts, recent] = await Promise.all([
api("/me/now-playing"),
api("/me/summary"),
api("/me/counts?period=1month&bucket=day"),
api("/me/recent?limit=1"),
]);
const display = h("div", { class: "display" });
replace(panel, display, readouts(summary), spectrum(counts));
renderDisplay(display, nowPlaying.now_playing, recent.items[0]);
}
async function refreshDisplay() {
const display = panel.querySelector(".display");
if (!display) return;
const [nowPlaying, recent] = await Promise.all([api("/me/now-playing"), api("/me/recent?limit=1")]);
renderDisplay(display, nowPlaying.now_playing, recent.items[0]);
}
function renderDisplay(display, playing, last) {
clearInterval(progressTimer);
display.classList.toggle("display-idle", !playing);
if (!playing) {
replace(
display,
h("p", { class: "display-status" }, "Idle"),
h("p", { class: "display-track" }, "Nothing playing"),
last
? h(
"p",
{ class: "display-meta" },
"Last played ",
h("strong", {}, last.track),
" by ",
h("strong", {}, last.artist),
`, ${timeAgo(last.played_at)}`,
)
: h("p", { class: "display-meta" }, "Connect a player on the Apps page to start scrobbling."),
);
return;
}
const fill = h("div", { class: "progress-fill" });
const elapsed = h("span", {});
replace(
display,
h("p", { class: "display-status" }, "Now playing"),
h("p", { class: "display-track" }, playing.track),
h(
"p",
{ class: "display-meta" },
h("strong", {}, playing.artist),
playing.album ? [" from ", h("strong", {}, playing.album)] : null,
),
playing.duration
? h(
"div",
{ class: "progress" },
elapsed,
h("div", { class: "progress-track", "aria-hidden": "true" }, fill),
h("span", {}, formatDuration(playing.duration)),
)
: null,
);
if (playing.duration) {
const started = new Date(playing.started_at).getTime();
const tick = () => {
const seconds = Math.min(playing.duration, (Date.now() - started) / 1000);
elapsed.textContent = formatDuration(seconds);
fill.style.width = `${(seconds / playing.duration) * 100}%`;
};
tick();
progressTimer = setInterval(tick, 1000);
}
}
function readouts(summary) {
const item = (value, label) => h("div", {}, h("dt", {}, label), h("dd", {}, num(value)));
return h(
"dl",
{ class: "readouts" },
item(summary.scrobbles, "scrobbles"),
item(summary.artists, "artists"),
item(summary.tracks, "tracks"),
);
}
// Daily plays for the last 30 days, drawn as a segmented level meter.
function spectrum(counts) {
const NS = "http://www.w3.org/2000/svg";
const width = 1000;
const height = 96;
const gap = 4;
const max = Math.max(1, ...counts.map((c) => c.count));
const columnWidth = width / counts.length;
const segmentHeight = height / SEGMENTS;
const total = counts.reduce((sum, c) => sum + c.count, 0);
const svg = document.createElementNS(NS, "svg");
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
svg.setAttribute("preserveAspectRatio", "none");
svg.setAttribute("role", "img");
svg.setAttribute("aria-label", `Plays per day over the last ${counts.length} days: ${num(total)} in total`);
counts.forEach((day, i) => {
const lit = day.count ? Math.max(1, Math.round((day.count / max) * SEGMENTS)) : 0;
const group = document.createElementNS(NS, "g");
const title = document.createElementNS(NS, "title");
title.textContent = `${formatDate(day.start)}: ${num(day.count)} ${day.count === 1 ? "play" : "plays"}`;
group.append(title);
for (let s = 0; s < SEGMENTS; s++) {
const rect = document.createElementNS(NS, "rect");
rect.setAttribute("x", i * columnWidth + gap / 2);
rect.setAttribute("y", height - (s + 1) * segmentHeight + 1.5);
rect.setAttribute("width", columnWidth - gap);
rect.setAttribute("height", segmentHeight - 3);
rect.setAttribute("class", s < lit ? "seg-on" : "seg-off");
group.append(rect);
}
svg.append(group);
});
return h(
"div",
{ class: "spectrum" },
svg,
h(
"div",
{ class: "spectrum-axis" },
h("span", {}, formatDate(counts[0].start)),
h("span", {}, `${num(total)} plays in 30 days`),
h("span", {}, "Today"),
),
);
}
// ---- Most played ------------------------------------------------------------
function currentPeriod() {
try {
const saved = localStorage.getItem(PERIOD_KEY);
if (PERIODS.some(([value]) => value === saved)) return saved;
} catch {
// Storage unavailable: fall back to the default.
}
return "7day";
}
function renderPeriodSelector() {
const selector = document.getElementById("period");
const active = currentPeriod();
for (const [value, label] of PERIODS) {
const id = `period-${value}`;
selector.append(
h("input", { type: "radio", name: "period", id, value, checked: value === active }),
h("label", { for: id }, label),
);
}
selector.addEventListener("change", (event) => {
try {
localStorage.setItem(PERIOD_KEY, event.target.value);
} catch {
// Not remembered; that's fine.
}
loadTop(event.target.value).catch(showError);
});
}
async function loadTop(period) {
const [artists, tracks] = await Promise.all([
api(`/me/top/artists?period=${period}&limit=10`),
api(`/me/top/tracks?period=${period}&limit=10`),
]);
renderRanking(document.getElementById("top-artists"), artists.items, false);
renderRanking(document.getElementById("top-tracks"), tracks.items, true);
}
function renderRanking(list, items, withArtist) {
if (!items.length) {
replace(list, h("li", { class: "empty" }, "No plays in this period."));
return;
}
const max = items[0].playcount;
replace(
list,
items.map((item) =>
h(
"li",
{},
h("span", { class: "rank" }, item.rank),
h("span", { class: "name" }, item.name, withArtist ? h("span", { class: "by" }, item.artist) : null),
h("span", { class: "plays" }, num(item.playcount)),
h("span", {
class: "meter",
"aria-hidden": "true",
style: `width: calc((100% - 2.75rem) * ${item.playcount / max})`,
}),
),
),
);
}
// ---- Recently played ----------------------------------------------------------
async function loadRecent() {
const recent = await api("/me/recent?limit=10");
const list = document.getElementById("recent");
if (!recent.items.length) {
replace(list, h("li", { class: "empty" }, "No scrobbles yet. Connect a player on the Apps page."));
return;
}
replace(
list,
recent.items.map((s) =>
h(
"li",
{},
h("time", { datetime: s.played_at, title: new Date(s.played_at).toLocaleString() }, timeAgo(s.played_at)),
h("span", {}, h("span", { class: "track" }, s.track), h("span", { class: "by" }, ` by ${s.artist}`)),
),
),
);
}
+67
View File
@@ -0,0 +1,67 @@
// DOM helpers. Server data only ever reaches the page as text nodes or attribute
// values, never as HTML, so track names can't inject markup.
export function h(tag, attrs = {}, ...children) {
const el = document.createElement(tag);
for (const [key, value] of Object.entries(attrs ?? {})) {
if (value === false || value === null || value === undefined) continue;
if (key.startsWith("on") && typeof value === "function") el.addEventListener(key.slice(2), value);
else if (key === "class") el.className = value;
else if (key === "dataset") Object.assign(el.dataset, value);
else el.setAttribute(key, value === true ? "" : String(value));
}
append(el, children);
return el;
}
function append(el, children) {
for (const child of children.flat(Infinity)) {
if (child === null || child === undefined || child === false) continue;
el.append(child instanceof Node ? child : document.createTextNode(String(child)));
}
}
export function replace(el, ...children) {
el.replaceChildren();
append(el, children);
return el;
}
const numberFormat = new Intl.NumberFormat();
export const num = (n) => numberFormat.format(n);
const relative = new Intl.RelativeTimeFormat(undefined, { numeric: "auto" });
const UNITS = [
["year", 365 * 86400],
["month", 30 * 86400],
["week", 7 * 86400],
["day", 86400],
["hour", 3600],
["minute", 60],
];
export function timeAgo(value) {
const seconds = (new Date(value).getTime() - Date.now()) / 1000;
for (const [unit, size] of UNITS) {
if (Math.abs(seconds) >= size) return relative.format(Math.round(seconds / size), unit);
}
return "just now";
}
export const formatTime = (value) =>
new Date(value).toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
export const formatDay = (value) =>
new Date(value).toLocaleDateString(undefined, { weekday: "long", day: "numeric", month: "long", year: "numeric" });
export const formatDate = (value) =>
new Date(value).toLocaleDateString(undefined, { day: "numeric", month: "short", year: "numeric" });
export function formatDuration(seconds) {
const s = Math.max(0, Math.floor(seconds));
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
}
export function errorBox(message) {
return h("p", { class: "notice notice-error", role: "alert" }, message);
}
+67
View File
@@ -0,0 +1,67 @@
import { api } from "./api.js";
import { errorBox, formatDay, formatTime, h, num, replace } from "./dom.js";
import { signedInPage } from "./layout.js";
const PER_PAGE = 50;
const container = document.getElementById("history");
const pager = document.getElementById("pager");
await signedInPage("history.html");
const page = Math.max(1, Number.parseInt(new URLSearchParams(location.search).get("page"), 10) || 1);
try {
const result = await api(`/me/recent?page=${page}&limit=${PER_PAGE}`);
render(result);
} catch (error) {
replace(container, errorBox(error.message));
}
function render(result) {
document.getElementById("history-summary").textContent =
`${num(result.total)} scrobbles, newest first. Page ${result.page} of ${result.total_pages}.`;
if (!result.items.length) {
replace(container, h("p", { class: "empty" }, "Nothing here yet. Tracks appear once a connected player scrobbles them."));
return;
}
// Group by local calendar day.
const days = new Map();
for (const scrobble of result.items) {
const key = new Date(scrobble.played_at).toDateString();
if (!days.has(key)) days.set(key, []);
days.get(key).push(scrobble);
}
replace(
container,
[...days.values()].map((scrobbles) => [
h("h2", { class: "log-day" }, formatDay(scrobbles[0].played_at)),
h(
"ol",
{ class: "log log-clock" },
scrobbles.map((s) =>
h(
"li",
{},
h("time", { datetime: s.played_at }, formatTime(s.played_at)),
h(
"span",
{},
h("span", { class: "track" }, s.track),
h("span", { class: "by" }, ` by ${s.artist}`),
s.album ? h("span", { class: "by" }, `, from ${s.album}`) : null,
),
),
),
),
]),
);
replace(
pager,
result.page > 1 ? h("a", { class: "button button-quiet", href: `?page=${result.page - 1}` }, "Newer") : h("span"),
result.page < result.total_pages
? h("a", { class: "button button-quiet", href: `?page=${result.page + 1}` }, "Older")
: h("span"),
);
}
+62
View File
@@ -0,0 +1,62 @@
// Shared page shell: site header, navigation, sign-in guard.
import { api, getToken, redirectToLogin, setToken } from "./api.js";
import { h, replace } from "./dom.js";
const NAV = [
["index.html", "Overview"],
["history.html", "History"],
["apps.html", "Apps"],
["sessions.html", "Sessions"],
];
// Renders the header and returns the signed-in user (redirecting if there isn't one).
export async function signedInPage(active) {
if (!getToken()) {
redirectToLogin();
return new Promise(() => {}); // navigation is under way
}
const header = document.getElementById("site-header");
replace(header, brand(), nav(active));
const user = await api("/auth/me");
header.append(
h(
"div",
{ class: "account" },
h("span", { class: "account-name" }, user.username),
h("button", { type: "button", class: "link-button", onclick: signOut }, "Sign out"),
),
);
return user;
}
export function publicPage() {
replace(document.getElementById("site-header"), brand());
}
function brand() {
return h("a", { class: "brand", href: "index.html" }, h("span", { class: "brand-mark", "aria-hidden": "true" }), "Scrobbler");
}
function nav(active) {
return h(
"nav",
{ "aria-label": "Main" },
h(
"ul",
{},
NAV.map(([href, label]) =>
h("li", {}, h("a", { href, "aria-current": href === active ? "page" : false }, label)),
),
),
);
}
async function signOut() {
try {
await api("/auth/logout", { method: "POST" });
} finally {
setToken(null);
location.href = "login.html";
}
}
+29
View File
@@ -0,0 +1,29 @@
import { api, describeError, getToken, safeNext, setToken } from "./api.js";
import { errorBox, replace } from "./dom.js";
import { publicPage } from "./layout.js";
publicPage();
const next = safeNext(new URLSearchParams(location.search).get("next"));
if (getToken()) location.replace(next);
const form = document.getElementById("login");
const messages = document.getElementById("messages");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const button = form.querySelector("button");
button.disabled = true;
replace(messages);
try {
const { token } = await api("/auth/login", {
method: "POST",
auth: false,
body: { username: form.elements.username.value.trim(), password: form.elements.password.value },
});
setToken(token);
location.href = next;
} catch (error) {
replace(messages, errorBox(describeError(error)));
button.disabled = false;
}
});
+31
View File
@@ -0,0 +1,31 @@
import { api, describeError, setToken } from "./api.js";
import { errorBox, replace } from "./dom.js";
import { publicPage } from "./layout.js";
publicPage();
const form = document.getElementById("register");
const messages = document.getElementById("messages");
form.addEventListener("submit", async (event) => {
event.preventDefault();
if (!form.reportValidity()) return;
const button = form.querySelector("button");
button.disabled = true;
replace(messages);
try {
const { token } = await api("/auth/register", {
method: "POST",
auth: false,
body: {
username: form.elements.username.value.trim(),
email: form.elements.email.value.trim(),
password: form.elements.password.value,
},
});
setToken(token);
location.href = "apps.html";
} catch (error) {
replace(messages, errorBox(describeError(error)));
button.disabled = false;
}
});
+60
View File
@@ -0,0 +1,60 @@
import { api } from "./api.js";
import { errorBox, formatDate, h, replace, timeAgo } from "./dom.js";
import { signedInPage } from "./layout.js";
const list = document.getElementById("sessions");
const messages = document.getElementById("messages");
await signedInPage("sessions.html");
await refresh();
async function refresh() {
try {
const sessions = await api("/sessions");
if (!sessions.length) {
replace(list, h("li", { class: "empty" }, "No players are signed in. They appear here once they sign in with an app's key."));
return;
}
replace(list, sessions.map(sessionRow));
} catch (error) {
replace(list, h("li", {}, errorBox(error.message)));
}
}
function sessionRow(session) {
const actions = h("div", { class: "confirm" });
const reset = () =>
replace(actions, h("button", { type: "button", class: "button button-quiet", onclick: ask }, "Revoke"));
const ask = () =>
replace(
actions,
h("button", { type: "button", class: "button button-danger", onclick: () => revoke(session, actions) }, "Revoke access"),
h("button", { type: "button", class: "button button-quiet", onclick: reset }, "Cancel"),
);
reset();
return h(
"li",
{},
h(
"div",
{ class: "row-head" },
h(
"span",
{},
h("span", { class: "row-title" }, session.app_name),
h("span", { class: "muted", title: formatDate(session.created_at) }, ` Signed in ${timeAgo(session.created_at)}`),
),
actions,
),
);
}
async function revoke(session, actions) {
try {
await api(`/sessions/${session.id}`, { method: "DELETE" });
await refresh();
replace(messages, h("p", { class: "notice notice-ok", role: "status" }, `Revoked ${session.app_name}.`));
} catch (error) {
replace(actions, errorBox(error.message));
}
}
+34
View File
@@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sign in · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/login.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<div class="auth">
<h1>Sign in</h1>
<p class="lede">See what you've been listening to.</p>
<div id="messages"></div>
<form id="login" novalidate>
<div class="field">
<label for="username">Username</label>
<input id="username" name="username" autocomplete="username" required>
</div>
<div class="field">
<label for="password">Password</label>
<input id="password" name="password" type="password" autocomplete="current-password" required>
</div>
<button class="button" type="submit">Sign in</button>
</form>
<p class="auth-alt">New here? <a href="register.html">Create an account</a></p>
</div>
</main>
</body>
</html>
+40
View File
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Create an account · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/register.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<div class="auth">
<h1>Create an account</h1>
<p class="lede">Your listening history stays on this server.</p>
<div id="messages"></div>
<form id="register" novalidate>
<div class="field">
<label for="username">Username</label>
<input id="username" name="username" autocomplete="username" required minlength="2" maxlength="32" pattern="[A-Za-z0-9_.\-]+" aria-describedby="username-hint">
<span class="hint" id="username-hint">Letters, numbers, dots, dashes and underscores. Players use this to sign in.</span>
</div>
<div class="field">
<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email" required>
</div>
<div class="field">
<label for="password">Password</label>
<input id="password" name="password" type="password" autocomplete="new-password" required minlength="8" aria-describedby="password-hint">
<span class="hint" id="password-hint">At least 8 characters.</span>
</div>
<button class="button" type="submit">Create account</button>
</form>
<p class="auth-alt">Already have an account? <a href="login.html">Sign in</a></p>
</div>
</main>
</body>
</html>
+21
View File
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sessions · Scrobbler</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css">
<script src="config.js"></script>
<script type="module" src="js/sessions.js"></script>
</head>
<body>
<header class="site-header" id="site-header"></header>
<main id="main">
<h1 class="page-title">Sessions</h1>
<p class="lede">Players you've signed in to Scrobbler. Revoking one signs it out straight away; it has to sign in again before it can scrobble.</p>
<div id="messages"></div>
<ul class="rows" id="sessions"></ul>
</main>
</body>
</html>