@tideworthy/tidysites-platform 0.10.8 → 0.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/editor/request.ts +13 -5
- package/src/routes/change.ts +13 -1
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.9
|
|
4
|
+
|
|
5
|
+
- Editor: the request panel greets the person by name and speaks plainly; the floating button is a pen, not a chat bubble. `GET /_tidy/change` says who is signed in.
|
|
6
|
+
|
|
3
7
|
## 0.10.8
|
|
4
8
|
|
|
5
9
|
- Editor: Request a change, from the bar and a floating button at the corner. A panel takes what to change and which page (the current one by default) and hands it to the platform through the control plane (`POST /_tidy/change`); it shows up under Changes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tideworthy/tidysites-platform",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9",
|
|
4
4
|
"description": "The Tidysites platform integration for EmDash sites: bootstrap, sessions, maintenance, health, and publish hooks under /_tidy/*.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/editor/request.ts
CHANGED
|
@@ -29,8 +29,16 @@ export function mountRequestChange(): void {
|
|
|
29
29
|
panel.replaceChildren();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
let who: { name: string | null } | null = null;
|
|
33
|
+
const firstName = () => (who?.name ?? "").trim().split(/\s+/)[0] || "";
|
|
34
|
+
|
|
35
|
+
async function render() {
|
|
36
|
+
if (!who) who = (await fetch(ROUTE, { credentials: "same-origin" }).then((r) => (r.ok ? r.json() : null)).catch(() => null)) as { name: string | null } | null;
|
|
37
|
+
const name = firstName();
|
|
38
|
+
const head = el("div", { class: "tidy-panel-head" }, [
|
|
39
|
+
el("h2", { text: name ? `Hi ${name},` : "Hi there," }),
|
|
40
|
+
el("p", { text: "We would love to help you make some adjustments to your website. Describe what you would like to see different or new, and we will get a version back to you as soon as possible." })
|
|
41
|
+
]);
|
|
34
42
|
const body = el("textarea", { id: "tidy-change-body", rows: "7", maxlength: "10000", required: "" });
|
|
35
43
|
const page = el("input", { id: "tidy-change-page", type: "text", value: here });
|
|
36
44
|
const err = el("p", { class: "tidy-field-note", hidden: "" });
|
|
@@ -53,7 +61,7 @@ export function mountRequestChange(): void {
|
|
|
53
61
|
sending = false;
|
|
54
62
|
if (r?.ok && j.ok) {
|
|
55
63
|
panel.replaceChildren(
|
|
56
|
-
el("div", { class: "tidy-panel-head" }, [el("h2", { text:
|
|
64
|
+
el("div", { class: "tidy-panel-head" }, [el("h2", { text: name ? `Thanks, ${name}.` : "Thanks." }), el("p", { text: "We have your request and will get a version back to you as soon as possible." })]),
|
|
57
65
|
el("div", { class: "tidy-panel-actions" }, [el("button", { type: "button", class: "tidy-btn", text: "Close" })])
|
|
58
66
|
);
|
|
59
67
|
panel.querySelector("button")?.addEventListener("click", close);
|
|
@@ -67,7 +75,7 @@ export function mountRequestChange(): void {
|
|
|
67
75
|
panel.replaceChildren(
|
|
68
76
|
head,
|
|
69
77
|
el("div", { class: "tidy-form" }, [
|
|
70
|
-
el("div", { class: "tidy-field" }, [el("label", { class: "tidy-field-label", for: "tidy-change-body", text: "What would you like
|
|
78
|
+
el("div", { class: "tidy-field" }, [el("label", { class: "tidy-field-label", for: "tidy-change-body", text: "What would you like to see different or new?" }), body]),
|
|
71
79
|
el("div", { class: "tidy-field" }, [el("label", { class: "tidy-field-label", for: "tidy-change-page", text: "Which page" }), page]),
|
|
72
80
|
err
|
|
73
81
|
]),
|
|
@@ -82,7 +90,7 @@ export function mountRequestChange(): void {
|
|
|
82
90
|
actions.prepend(barBtn);
|
|
83
91
|
|
|
84
92
|
const fab = el("button", { type: "button", class: "tidy-fab", title: "Request a change", "aria-label": "Request a change" });
|
|
85
|
-
fab.innerHTML = '<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="
|
|
93
|
+
fab.innerHTML = '<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z"/></svg>';
|
|
86
94
|
fab.addEventListener("click", render);
|
|
87
95
|
document.body.append(fab);
|
|
88
96
|
document.addEventListener("keydown", (e) => {
|
package/src/routes/change.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* own secret. The Astro session is the gate; the person's name and email
|
|
5
5
|
* come from the site's user record.
|
|
6
6
|
*
|
|
7
|
+
* GET → { name, email } of the signed-in person
|
|
7
8
|
* POST { body, pageUrl? } → { ok, changeId }
|
|
8
9
|
*/
|
|
9
10
|
import type { APIRoute } from "astro";
|
|
@@ -45,4 +46,15 @@ export const POST: APIRoute = platformRoute(
|
|
|
45
46
|
{ requireBearer: false }
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
/** Who is signed in, for the panel's greeting: { name, email } or 401. */
|
|
50
|
+
export const GET: APIRoute = platformRoute(
|
|
51
|
+
async (context, deps) => {
|
|
52
|
+
const session = context.session ? ((await context.session.get("user")) as { id?: string } | null) : null;
|
|
53
|
+
if (!session?.id) return new Response("Unauthorized", { status: 401 });
|
|
54
|
+
const user = await deps.store.findUserById(session.id);
|
|
55
|
+
return json({ name: user?.name ?? null, email: user?.email ?? null }, 200, { "cache-control": "no-store" });
|
|
56
|
+
},
|
|
57
|
+
{ requireBearer: false }
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export const ALL = methodNotAllowed("GET, POST");
|
package/src/version.ts
CHANGED