Sharing settings and public profile pages (phase 1, step 5)
- sharing.html: switch sharing on/off, see the handle (with the "permanent once followed" warning and a note that following comes later), choose who sees posts (followers only by default; help text on why approval matters), follower approval, directory and search opt-ins, display name and bio; save status shown by the button - profile.html?u=<name>: the public page browsers land on from an actor URL: name, handle (with copy), bio and how to follow; never asks the visitor to sign in - "Sharing" appears in the nav only when the server federates (remembered per tab) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
0b10469514
commit
c0b9e85519
6 files changed
+361
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { api } from "./api.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} · Scrobbler`;
|
||||
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,
|
||||
h("h1", {}, profile.display_name),
|
||||
h("div", { class: "approve-app handle" }, profile.handle),
|
||||
profile.bio ? h("p", { class: "lede profile-bio" }, profile.bio) : 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),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user