diff --git a/docs/openapi.json b/docs/openapi.json
index 61cbdf7..2dcbd33 100644
--- a/docs/openapi.json
+++ b/docs/openapi.json
@@ -1953,6 +1953,150 @@
]
}
},
+ "/api/v1/federation/preview/weekly": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/WeeklyPreview"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Not authenticated",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "default": {
+ "$ref": "#/components/responses/DEFAULT_ERROR"
+ }
+ },
+ "summary": "Preview this week's summary",
+ "description": "What it would say right now, for the week still in progress. Never posted or stored.",
+ "tags": [
+ "Federation"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ]
+ }
+ },
+ "/api/v1/federation/posts": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Post"
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Not authenticated",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "default": {
+ "$ref": "#/components/responses/DEFAULT_ERROR"
+ }
+ },
+ "summary": "Your posts",
+ "description": "Newest first, including deleted ones (their text stays visible to you; deleted_at\nshows when).",
+ "tags": [
+ "Federation"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ]
+ }
+ },
+ "/api/v1/federation/posts/{post_id}": {
+ "delete": {
+ "responses": {
+ "409": {
+ "description": "Already deleted",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "No such post",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "204": {
+ "description": "No Content"
+ },
+ "401": {
+ "description": "Not authenticated",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "default": {
+ "$ref": "#/components/responses/DEFAULT_ERROR"
+ }
+ },
+ "summary": "Delete a post",
+ "description": "Sends a Delete to whoever received it.",
+ "tags": [
+ "Federation"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ]
+ },
+ "parameters": [
+ {
+ "in": "path",
+ "name": "post_id",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "minimum": 0
+ }
+ }
+ ]
+ },
"/api/v1/federation/profiles/{username}": {
"get": {
"responses": {
@@ -1998,6 +2142,60 @@
}
]
},
+ "/api/v1/federation/profiles/{username}/posts/{post_uuid}": {
+ "get": {
+ "responses": {
+ "404": {
+ "description": "Not found, not public, or deleted",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Error"
+ }
+ }
+ }
+ },
+ "200": {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PublicPost"
+ }
+ }
+ }
+ },
+ "default": {
+ "$ref": "#/components/responses/DEFAULT_ERROR"
+ }
+ },
+ "summary": "A public or unlisted post",
+ "description": "For the web UI's post page (the browser landing spot for a Note's `url`, since it\ncan't itself speak ActivityPub).",
+ "tags": [
+ "Federation"
+ ]
+ },
+ "parameters": [
+ {
+ "in": "path",
+ "name": "username",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ }
+ },
+ {
+ "in": "path",
+ "name": "post_uuid",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "minLength": 1
+ }
+ }
+ ]
+ },
"/api/v1/federation/followers": {
"get": {
"parameters": [
@@ -4183,6 +4381,19 @@
],
"maxLength": 500
},
+ "timezone": {
+ "type": "string",
+ "description": "IANA time zone, e.g. `Europe/London`. Decides when a week ends for the weekly summary.",
+ "example": "Europe/London"
+ },
+ "post_weekly_summary": {
+ "type": "boolean",
+ "description": "Post a weekly summary of your listening"
+ },
+ "post_milestones": {
+ "type": "boolean",
+ "description": "Post scrobble-count, artist-plays and top-10 milestones as you hit them"
+ },
"handle": {
"type": "string",
"readOnly": true,
@@ -4250,6 +4461,19 @@
],
"maxLength": 500
},
+ "timezone": {
+ "type": "string",
+ "description": "IANA time zone, e.g. `Europe/London`. Decides when a week ends for the weekly summary.",
+ "example": "Europe/London"
+ },
+ "post_weekly_summary": {
+ "type": "boolean",
+ "description": "Post a weekly summary of your listening"
+ },
+ "post_milestones": {
+ "type": "boolean",
+ "description": "Post scrobble-count, artist-plays and top-10 milestones as you hit them"
+ },
"handle": {
"type": "string",
"readOnly": true,
@@ -4276,6 +4500,48 @@
},
"additionalProperties": false
},
+ "WeeklyPreview": {
+ "type": "object",
+ "properties": {
+ "text": {
+ "type": "string"
+ },
+ "html": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
+ "Post": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "kind": {
+ "type": "string",
+ "description": "weekly or milestone"
+ },
+ "text": {
+ "type": "string"
+ },
+ "visibility": {
+ "type": "string"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "deleted_at": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "format": "date-time"
+ }
+ },
+ "additionalProperties": false
+ },
"PublicProfile": {
"type": "object",
"properties": {
@@ -4301,6 +4567,32 @@
},
"additionalProperties": false
},
+ "PublicPost": {
+ "type": "object",
+ "properties": {
+ "text": {
+ "type": "string"
+ },
+ "html": {
+ "type": "string"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "display_name": {
+ "type": "string"
+ },
+ "handle": {
+ "type": "string",
+ "example": "@alice@scrobble.example"
+ },
+ "profile_url": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
"Follower": {
"type": "object",
"properties": {
diff --git a/frontend/css/style.css b/frontend/css/style.css
index b846e83..9f4c983 100644
--- a/frontend/css/style.css
+++ b/frontend/css/style.css
@@ -919,6 +919,22 @@ input {
margin-top: 0.5rem;
}
+.preview-box {
+ padding: 1rem 1.25rem;
+ border-radius: var(--radius-control);
+ background: var(--paper-raised);
+ border: 1px solid var(--rule);
+ margin: 0.75rem 0 1.25rem;
+}
+
+.preview-box p {
+ margin: 0 0 0.5rem;
+}
+
+.preview-box p:last-child {
+ margin-bottom: 0;
+}
+
.field textarea {
min-height: 5rem;
padding: 0.5rem 0.75rem;
diff --git a/frontend/js/post.js b/frontend/js/post.js
new file mode 100644
index 0000000..930e91c
--- /dev/null
+++ b/frontend/js/post.js
@@ -0,0 +1,40 @@
+import { api } from "./api.js";
+import { errorBox, formatDate, h, replace } from "./dom.js";
+import { publicPage } from "./layout.js";
+
+const root = document.getElementById("post");
+const params = new URLSearchParams(location.search);
+const username = params.get("u") ?? "";
+const postId = params.get("id") ?? "";
+
+// A public page: never sends visitors to sign in.
+publicPage();
+
+try {
+ const post = await api(
+ `/federation/profiles/${encodeURIComponent(username)}/posts/${encodeURIComponent(postId)}`,
+ { auth: false },
+ );
+ document.title = `${post.display_name} · Scrobbler`;
+ replace(
+ root,
+ h(
+ "p",
+ { class: "muted" },
+ h("a", { href: post.profile_url }, post.display_name),
+ ` · ${post.handle}`,
+ ),
+ h("p", { style: "white-space: pre-line" }, post.text),
+ h("p", { class: "muted", title: formatDate(post.created_at) }, `Posted ${formatDate(post.created_at)}`),
+ );
+} catch (error) {
+ replace(
+ root,
+ error.status === 404
+ ? [
+ h("h1", {}, "No post here"),
+ h("p", { class: "lede" }, "This post doesn't exist, isn't public, or has been deleted."),
+ ]
+ : errorBox(error.message),
+ );
+}
diff --git a/frontend/js/posts.js b/frontend/js/posts.js
new file mode 100644
index 0000000..5323730
--- /dev/null
+++ b/frontend/js/posts.js
@@ -0,0 +1,80 @@
+import { api } from "./api.js";
+import { errorBox, formatDate, h, replace, timeAgo } from "./dom.js";
+import { signedInPage } from "./layout.js";
+
+const messages = document.getElementById("messages");
+const KIND_LABEL = { weekly: "Weekly summary", milestone: "Milestone" };
+const VISIBILITY_LABEL = { followers: "Followers only", unlisted: "Unlisted", public: "Public" };
+
+await signedInPage("sharing.html");
+await refresh();
+
+async function refresh() {
+ let posts;
+ try {
+ posts = await api("/federation/posts");
+ } catch (error) {
+ replace(
+ messages,
+ error.status === 404
+ ? h("p", { class: "notice" }, "This server doesn't share to the fediverse.")
+ : errorBox(error.message),
+ );
+ return;
+ }
+ replace(
+ document.getElementById("posts"),
+ posts.length
+ ? posts.map(postRow)
+ : h(
+ "li",
+ { class: "empty" },
+ "Nothing posted yet. Weekly summaries and milestones appear here once you're sharing.",
+ ),
+ );
+}
+
+function postRow(post) {
+ const actions = h("div", { class: "confirm" });
+ const reset = () =>
+ replace(
+ actions,
+ post.deleted_at
+ ? null
+ : h("button", { type: "button", class: "button button-quiet", onclick: askDelete }, "Delete"),
+ );
+ const askDelete = () =>
+ replace(
+ actions,
+ h("span", { class: "muted" }, "Delivered followers keep a copy; this only removes it from their timeline."),
+ h("button", { type: "button", class: "button button-danger", onclick: doDelete }, "Delete post"),
+ h("button", { type: "button", class: "button button-quiet", onclick: reset }, "Cancel"),
+ );
+ const doDelete = async () => {
+ try {
+ await api(`/federation/posts/${post.id}`, { method: "DELETE" });
+ replace(messages, h("p", { class: "notice notice-ok", role: "status" }, "Post deleted."));
+ } catch (error) {
+ replace(messages, errorBox(error.message));
+ }
+ await refresh();
+ };
+ reset();
+ return h(
+ "li",
+ {},
+ h(
+ "div",
+ { class: "row-head" },
+ h("span", { class: "row-title" }, KIND_LABEL[post.kind] ?? post.kind),
+ actions,
+ ),
+ h("p", { style: "white-space: pre-line" }, post.text),
+ h(
+ "p",
+ { class: "muted", title: formatDate(post.created_at) },
+ `${VISIBILITY_LABEL[post.visibility] ?? post.visibility} · Posted ${timeAgo(post.created_at)}`,
+ post.deleted_at ? ` · Deleted ${timeAgo(post.deleted_at)}` : null,
+ ),
+ );
+}
diff --git a/frontend/js/sharing.js b/frontend/js/sharing.js
index eaab3d0..3fe7fb8 100644
--- a/frontend/js/sharing.js
+++ b/frontend/js/sharing.js
@@ -5,8 +5,20 @@ import { signedInPage } from "./layout.js";
const form = document.getElementById("sharing");
const messages = document.getElementById("messages");
const handlePanel = document.getElementById("handle-panel");
-const FIELDS = ["enabled", "visibility", "manually_approves_followers", "discoverable", "indexable", "display_name", "bio"];
+const FIELDS = [
+ "enabled",
+ "visibility",
+ "manually_approves_followers",
+ "discoverable",
+ "indexable",
+ "post_weekly_summary",
+ "post_milestones",
+ "timezone",
+ "display_name",
+ "bio",
+];
+fillTimezoneChoices();
await signedInPage("sharing.html");
let settings;
@@ -26,6 +38,34 @@ if (settings) {
form.hidden = false;
form.elements.enabled.addEventListener("change", () => showHandle(form.elements.enabled.checked));
form.addEventListener("submit", save);
+ document.getElementById("preview-weekly").addEventListener("click", previewWeekly);
+}
+
+// Free text (validated server-side), with autocomplete from the browser's own IANA list
+// when it can supply one; a picker where that's available, a plain field otherwise.
+function fillTimezoneChoices() {
+ if (typeof Intl.supportedValuesOf !== "function") return;
+ const datalist = document.getElementById("timezones");
+ replace(datalist, Intl.supportedValuesOf("timeZone").map((zone) => h("option", { value: zone })));
+}
+
+async function previewWeekly() {
+ const box = document.getElementById("weekly-preview");
+ const button = document.getElementById("preview-weekly");
+ button.disabled = true;
+ try {
+ const preview = await api("/federation/preview/weekly");
+ replace(
+ box,
+ h("p", { class: "muted" }, "What this week's summary would say so far:"),
+ h("p", { style: "white-space: pre-line" }, preview.text),
+ );
+ box.hidden = false;
+ } catch (error) {
+ replace(messages, errorBox(error.message));
+ } finally {
+ button.disabled = false;
+ }
}
function fill(values) {
@@ -107,6 +147,9 @@ async function save(event) {
manually_approves_followers: form.elements.manually_approves_followers.checked,
discoverable: form.elements.discoverable.checked,
indexable: form.elements.indexable.checked,
+ post_weekly_summary: form.elements.post_weekly_summary.checked,
+ post_milestones: form.elements.post_milestones.checked,
+ timezone: form.elements.timezone.value.trim() || "UTC",
display_name: form.elements.display_name.value.trim() || null,
bio: form.elements.bio.value.trim() || null,
};
diff --git a/frontend/post.html b/frontend/post.html
new file mode 100644
index 0000000..d41f3fe
--- /dev/null
+++ b/frontend/post.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Post · Scrobbler
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/posts.html b/frontend/posts.html
new file mode 100644
index 0000000..a7e2381
--- /dev/null
+++ b/frontend/posts.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Posts · Scrobbler
+
+
+
+
+
+
+
+
+ Posts
+ Weekly summaries and milestones sent to the fediverse. Sharing settings
+
+
+
+
+
diff --git a/frontend/sharing.html b/frontend/sharing.html
index 1cade12..96ac78e 100644
--- a/frontend/sharing.html
+++ b/frontend/sharing.html
@@ -60,6 +60,29 @@
+
+