CI / validate-monitoring (push) Successful in 10s
CI / lint (push) Successful in 14s
CI / federation-interop (push) Successful in 1m15s
CI / test (push) Successful in 7m2s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 5s
A Profile page to upload, use Gravatar or remove the image, the avatar in the page header and on the public profile, a Sharing switch for it, and user/admin guide notes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
import { api } from "./api.js";
|
|
import { avatarImage } from "./avatar.js";
|
|
import { errorBox, h, replace } from "./dom.js";
|
|
import { publicPage } from "./layout.js";
|
|
|
|
const root = document.getElementById("profile");
|
|
const username = new URLSearchParams(location.search).get("u") ?? "";
|
|
|
|
// A public page: never sends visitors to sign in.
|
|
publicPage();
|
|
|
|
try {
|
|
const profile = await api(`/federation/profiles/${encodeURIComponent(username)}`, { auth: false });
|
|
document.title = `${profile.display_name} · Scrobbled`;
|
|
const copy = h("button", { type: "button", class: "button button-quiet" }, "Copy handle");
|
|
copy.addEventListener("click", async () => {
|
|
try {
|
|
await navigator.clipboard.writeText(profile.handle);
|
|
copy.textContent = "Copied";
|
|
} catch {
|
|
copy.textContent = "Select and copy it above";
|
|
}
|
|
});
|
|
replace(
|
|
root,
|
|
profile.has_avatar
|
|
? avatarImage(profile, "avatar-xl", `/federation/profiles/${encodeURIComponent(username)}/avatar`)
|
|
: null,
|
|
h("h1", {}, profile.display_name),
|
|
h("div", { class: "approve-app handle" }, profile.handle),
|
|
profile.bio ? h("p", { class: "lede profile-bio" }, profile.bio) : null,
|
|
profile.now_playing
|
|
? h("p", { class: "now-playing" }, "Now playing: ", h("strong", {}, profile.now_playing))
|
|
: null,
|
|
h("h2", { class: "profile-follow" }, "Follow from the fediverse"),
|
|
h(
|
|
"p",
|
|
{ class: "muted" },
|
|
"Search for the handle above in Mastodon or any other fediverse app, then follow.",
|
|
),
|
|
h("div", { class: "button-row" }, copy),
|
|
);
|
|
} catch (error) {
|
|
replace(
|
|
root,
|
|
error.status === 404
|
|
? [h("h1", {}, "No profile here"), h("p", { class: "lede" }, "No one on this server shares their listening under that name.")]
|
|
: errorBox(error.message),
|
|
);
|
|
}
|