Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d2a484b31 | ||
|
|
7f8afdcdbb | ||
|
|
a7ba6360e5 |
No files matched your search
@@ -33,7 +33,7 @@ cp .env.example .env # then set SECRET_KEY and POSTGRES_PAS
|
|||||||
docker compose up -d # db, api (:5050), worker, ui (:8080)
|
docker compose up -d # db, api (:5050), worker, ui (:8080)
|
||||||
```
|
```
|
||||||
|
|
||||||
Open http://localhost:8080, create an account, then go to **Apps** and create an app for
|
Open http://localhost:8080, create an account, then open **Apps** from the account menu (top right) and create an app for
|
||||||
a player. See [docs/admin-guide.md](docs/admin-guide.md) for the published images, full
|
a player. See [docs/admin-guide.md](docs/admin-guide.md) for the published images, full
|
||||||
configuration reference and production notes.
|
configuration reference and production notes.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ cp .env.example .env # then set SECRET_KEY and POSTGRES_PASSWORD
|
|||||||
SCROBBLER_IMAGE_TAG=main docker compose up -d --no-build # or drop --no-build to build locally
|
SCROBBLER_IMAGE_TAG=main docker compose up -d --no-build # or drop --no-build to build locally
|
||||||
```
|
```
|
||||||
|
|
||||||
Open `http://localhost:8080`, create an account, then go to **Apps** and create an app
|
Open `http://localhost:8080`, create an account, then open **Apps** from the account menu (top right) and create an app
|
||||||
for each player. Add `--profile monitoring` for Prometheus and Grafana.
|
for each player. Add `--profile monitoring` for Prometheus and Grafana.
|
||||||
|
|
||||||
Published images: `pkgs.daubney.dev/scrobbler/scrobbler-api` and
|
Published images: `pkgs.daubney.dev/scrobbler/scrobbler-api` and
|
||||||
|
|||||||
+6
-5
@@ -6,7 +6,8 @@ instance rather than using one, see the [admin guide](admin-guide.md) instead.
|
|||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
Register in the web UI, then go to **Apps** and create one app per player or scrobbler
|
Register in the web UI, then open the account menu at the top right (your picture and
|
||||||
|
name), go to **Apps** and create one app per player or scrobbler
|
||||||
client you use — each gets its own API key and shared secret, and can be revoked on its
|
client you use — each gets its own API key and shared secret, and can be revoked on its
|
||||||
own from the **Sessions** page without affecting the others. If a friend runs your
|
own from the **Sessions** page without affecting the others. If a friend runs your
|
||||||
instance, ask them for its address; that's the only thing you need from them to get
|
instance, ask them for its address; that's the only thing you need from them to get
|
||||||
@@ -47,7 +48,7 @@ scrobbler is one example; look for a plugin or a different player with 2.0 suppo
|
|||||||
|
|
||||||
## Importing history
|
## Importing history
|
||||||
|
|
||||||
Open **Import** in the web UI:
|
Open **Import** from the account menu:
|
||||||
|
|
||||||
- **An export file**:
|
- **An export file**:
|
||||||
- CSV from [lastfm-to-csv](https://benjaminbenben.com/lastfm-to-csv/), no header row,
|
- CSV from [lastfm-to-csv](https://benjaminbenben.com/lastfm-to-csv/), no header row,
|
||||||
@@ -67,8 +68,8 @@ skipped, so importing the same export again, or importing overlapping exports, i
|
|||||||
|
|
||||||
## Your profile image
|
## Your profile image
|
||||||
|
|
||||||
Click your name in the page header to open **Profile**, where you can give yourself a
|
Open the account menu at the top right (your picture and name) and choose **Profile**, where
|
||||||
picture, shown next to your name. Upload a JPEG, PNG or WebP image, or remove it again.
|
you can give yourself a picture, shown next to your name. Upload a JPEG, PNG or WebP image, or remove it again.
|
||||||
|
|
||||||
If your instance's admin has allowed it, you can also **use your Gravatar**. The server
|
If your instance's admin has allowed it, you can also **use your Gravatar**. The server
|
||||||
asks Gravatar for the picture linked to your account email, sending it a hash of that
|
asks Gravatar for the picture linked to your account email, sending it a hash of that
|
||||||
@@ -84,7 +85,7 @@ removal can take a while to show up everywhere.
|
|||||||
## Sharing on the fediverse
|
## Sharing on the fediverse
|
||||||
|
|
||||||
Only available if your instance's admin has turned this on — ask them, or check whether
|
Only available if your instance's admin has turned this on — ask them, or check whether
|
||||||
**Sharing** appears in the navigation. Turn it on there, and you're findable as
|
**Sharing** appears in the account menu. Turn it on there, and you're findable as
|
||||||
`@name@<your instance's host>` from Mastodon and other fediverse apps.
|
`@name@<your instance's host>` from Mastodon and other fediverse apps.
|
||||||
|
|
||||||
- Follows are accepted automatically, or wait for your approval if you turn that on
|
- Follows are accepted automatically, or wait for your approval if you turn that on
|
||||||
|
|||||||
+81
-9
@@ -206,23 +206,91 @@ code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.account {
|
.account {
|
||||||
|
position: relative; /* anchors the menu */
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
display: flex;
|
|
||||||
gap: 1rem;
|
|
||||||
align-items: center;
|
|
||||||
color: var(--ink-soft);
|
color: var(--ink-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
.account-link {
|
.account-trigger {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
padding: 0.25rem 0.5rem 0.25rem 0.25rem;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: var(--radius-control);
|
||||||
|
background: none;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
font: inherit;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.account-link:hover .account-name {
|
.account-trigger:hover,
|
||||||
|
.account-trigger[aria-expanded="true"] {
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
|
border-color: var(--rule);
|
||||||
|
background: var(--paper-raised);
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-trigger[data-current] .account-name {
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A three-line "hamburger" icon, drawn with two borders and a shadow-free centre bar */
|
||||||
|
.account-icon {
|
||||||
|
width: 1rem;
|
||||||
|
height: 0.7rem;
|
||||||
|
border-block: 2px solid currentColor;
|
||||||
|
background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 0.35rem);
|
||||||
|
right: 0;
|
||||||
|
z-index: 10;
|
||||||
|
min-width: 12rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.35rem;
|
||||||
|
list-style: none;
|
||||||
|
background: var(--paper-raised);
|
||||||
|
border: 1px solid var(--rule);
|
||||||
|
border-radius: var(--radius-control);
|
||||||
|
box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu-item {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
border: 0;
|
||||||
|
border-radius: calc(var(--radius-control) - 2px);
|
||||||
|
background: none;
|
||||||
|
color: var(--ink-soft);
|
||||||
|
font: inherit;
|
||||||
|
text-align: left;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu-item:hover,
|
||||||
|
.account-menu-item:focus-visible {
|
||||||
|
color: var(--ink);
|
||||||
|
background: var(--bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu-item[aria-current="page"] {
|
||||||
|
color: var(--ink);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu-end {
|
||||||
|
margin-top: 0.35rem;
|
||||||
|
padding-top: 0.35rem;
|
||||||
|
border-top: 1px solid var(--rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
.account-avatar {
|
.account-avatar {
|
||||||
@@ -864,9 +932,13 @@ input {
|
|||||||
margin-inline: -8px;
|
margin-inline: -8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.account {
|
/* Just the picture and the icon; the name is still the button's accessible label */
|
||||||
margin-left: 0;
|
.account-name {
|
||||||
width: 100%;
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-menu {
|
||||||
|
min-width: min(16rem, calc(100vw - 32px));
|
||||||
}
|
}
|
||||||
|
|
||||||
.keys,
|
.keys,
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ async function change(action, done) {
|
|||||||
say(h("p", { class: "notice notice-ok" }, done));
|
say(h("p", { class: "notice notice-ok" }, done));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
say(errorBox(describeError(error)));
|
say(errorBox(describeError(error)));
|
||||||
|
// The change may have half-happened, or the page was out of date: show what's true now.
|
||||||
|
user = await api("/auth/me").catch(() => user);
|
||||||
}
|
}
|
||||||
render();
|
render();
|
||||||
const slot = document.querySelector(".account-avatar");
|
const slot = document.querySelector(".account-avatar");
|
||||||
|
|||||||
+102
-17
@@ -8,6 +8,12 @@ const NAV = [
|
|||||||
["index.html", "Overview"],
|
["index.html", "Overview"],
|
||||||
["history.html", "History"],
|
["history.html", "History"],
|
||||||
["art.html", "Album art"],
|
["art.html", "Album art"],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Account pages live in the menu under the user's name. "Sharing" joins them (after
|
||||||
|
// Profile) when the server federates.
|
||||||
|
const MENU = [
|
||||||
|
["account.html", "Profile"],
|
||||||
["apps.html", "Apps"],
|
["apps.html", "Apps"],
|
||||||
["sessions.html", "Sessions"],
|
["sessions.html", "Sessions"],
|
||||||
["import.html", "Import"],
|
["import.html", "Import"],
|
||||||
@@ -22,20 +28,9 @@ export async function signedInPage(active) {
|
|||||||
const header = document.getElementById("site-header");
|
const header = document.getElementById("site-header");
|
||||||
replace(header, brand(), nav(active));
|
replace(header, brand(), nav(active));
|
||||||
const user = await api("/auth/me");
|
const user = await api("/auth/me");
|
||||||
addSharingLink(header.querySelector("nav ul"), active);
|
const menu = accountMenu(user, active);
|
||||||
header.append(
|
header.append(menu.element);
|
||||||
h(
|
addSharingLink(menu.list, active);
|
||||||
"div",
|
|
||||||
{ class: "account" },
|
|
||||||
h(
|
|
||||||
"a",
|
|
||||||
{ class: "account-link", href: "account.html", title: "Your profile image" },
|
|
||||||
h("span", { class: "account-avatar" }, avatarImage(user, "avatar-sm")),
|
|
||||||
h("span", { class: "account-name" }, user.username),
|
|
||||||
),
|
|
||||||
h("button", { type: "button", class: "link-button", onclick: signOut }, "Sign out"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +62,95 @@ function nav(active) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The account menu: a button showing the user's picture and name that opens a list of
|
||||||
|
// account pages and "Sign out". Returns the element and its <ul> (for late additions).
|
||||||
|
function accountMenu(user, active) {
|
||||||
|
const list = h("ul", { class: "account-menu", id: "account-menu", hidden: true });
|
||||||
|
for (const [href, label] of MENU) list.append(menuLink(href, label, active));
|
||||||
|
list.append(
|
||||||
|
h(
|
||||||
|
"li",
|
||||||
|
{ class: "account-menu-end" },
|
||||||
|
h("button", { type: "button", class: "account-menu-item", onclick: signOut }, "Sign out"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const trigger = h(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
type: "button",
|
||||||
|
class: "account-trigger",
|
||||||
|
"aria-haspopup": "true",
|
||||||
|
"aria-expanded": "false",
|
||||||
|
"aria-controls": "account-menu",
|
||||||
|
"aria-label": `Account menu for ${user.username}`,
|
||||||
|
},
|
||||||
|
h("span", { class: "account-avatar" }, avatarImage(user, "avatar-sm")),
|
||||||
|
h("span", { class: "account-name" }, user.username),
|
||||||
|
h("span", { class: "account-icon", "aria-hidden": "true" }),
|
||||||
|
);
|
||||||
|
const element = h("div", { class: "account" }, trigger, list);
|
||||||
|
|
||||||
|
const items = () => [...list.querySelectorAll("a, button")];
|
||||||
|
const setOpen = (open, focus) => {
|
||||||
|
list.hidden = !open;
|
||||||
|
trigger.setAttribute("aria-expanded", String(open));
|
||||||
|
if (open && focus === "first") items()[0]?.focus();
|
||||||
|
if (open && focus === "last") items().at(-1)?.focus();
|
||||||
|
if (!open && focus) trigger.focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
trigger.addEventListener("click", () => setOpen(list.hidden));
|
||||||
|
trigger.addEventListener("keydown", (event) => {
|
||||||
|
if (event.key === "ArrowDown") {
|
||||||
|
event.preventDefault();
|
||||||
|
setOpen(true, "first");
|
||||||
|
} else if (event.key === "ArrowUp") {
|
||||||
|
event.preventDefault();
|
||||||
|
setOpen(true, "last");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
list.addEventListener("keydown", (event) => {
|
||||||
|
const all = items();
|
||||||
|
const at = all.indexOf(document.activeElement);
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
setOpen(false, true);
|
||||||
|
} else if (event.key === "ArrowDown") {
|
||||||
|
event.preventDefault();
|
||||||
|
all[(at + 1) % all.length].focus();
|
||||||
|
} else if (event.key === "ArrowUp") {
|
||||||
|
event.preventDefault();
|
||||||
|
all[(at - 1 + all.length) % all.length].focus();
|
||||||
|
} else if (event.key === "Home") {
|
||||||
|
event.preventDefault();
|
||||||
|
all[0].focus();
|
||||||
|
} else if (event.key === "End") {
|
||||||
|
event.preventDefault();
|
||||||
|
all.at(-1).focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Close when focus or a click lands outside the menu.
|
||||||
|
document.addEventListener("click", (event) => {
|
||||||
|
if (!element.contains(event.target)) setOpen(false);
|
||||||
|
});
|
||||||
|
element.addEventListener("focusout", (event) => {
|
||||||
|
if (event.relatedTarget && !element.contains(event.relatedTarget)) setOpen(false);
|
||||||
|
});
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (event.key === "Escape" && !list.hidden) setOpen(false, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mark the trigger when the page being viewed is one of the menu's.
|
||||||
|
if (MENU.some(([href]) => href === active) || active === SHARING) {
|
||||||
|
trigger.setAttribute("data-current", "true");
|
||||||
|
}
|
||||||
|
return { element, list };
|
||||||
|
}
|
||||||
|
|
||||||
|
function menuLink(href, label, active) {
|
||||||
|
return h("li", {}, h("a", { class: "account-menu-item", href, "aria-current": href === active ? "page" : false }, label));
|
||||||
|
}
|
||||||
|
|
||||||
async function signOut() {
|
async function signOut() {
|
||||||
try {
|
try {
|
||||||
await api("/auth/logout", { method: "POST" });
|
await api("/auth/logout", { method: "POST" });
|
||||||
@@ -101,9 +185,10 @@ async function federationAvailable() {
|
|||||||
return available;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SHARING = "sharing.html";
|
||||||
|
|
||||||
async function addSharingLink(list, active) {
|
async function addSharingLink(list, active) {
|
||||||
if (!list || !(await federationAvailable())) return;
|
if (!(await federationAvailable())) return;
|
||||||
const href = "sharing.html";
|
list.children[0].after(menuLink(SHARING, "Sharing", active)); // right after Profile
|
||||||
list.append(h("li", {}, h("a", { href, "aria-current": href === active ? "page" : false }, "Sharing")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user