@tideworthy/tidysites-platform 0.10.2 → 0.10.4

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.4
4
+
5
+ - Editor: the bar has a 1px white bottom edge, so it stands off a dark header as well as a light one.
6
+
7
+ ## 0.10.3
8
+
9
+ - Editor: one bar on the staging site for everyone. A visitor gets Sign in to edit, which goes through the platform's door for the site (`<control>/sites/<id>/sign-in?back=`) and comes back signed in; a signed-in editor gets Edit and the controls as before. The bar is taller, named "Staging website" with an amber edge and a line on what staging is. The publish crawl never sees it.
10
+
3
11
  ## 0.10.2
4
12
 
5
13
  - Editor: the Revisions list starts after the newest publish, which is what is live now and has nothing to view or restore; a deep link to it opens the list. Inside the revision viewer EmDash's pill is hidden along with the bar.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tideworthy/tidysites-platform",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
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",
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  /**
3
3
  * The Tideworthy on-site editor. Mount it from the layout on every page; it
4
- * renders nothing for a visitor and, for a signed-in editor, a bar across the
5
- * top of the page: "Edit" while editing is off, the editor's controls while
6
- * it is on (the `emdash-edit-mode` cookie, set and cleared by /_tidy/edit).
4
+ * renders one bar across the top of the staging site for everyone: Sign in
5
+ * for a visitor, "Edit" for a signed-in editor while editing is off, the
6
+ * editor's controls while it is on (the `emdash-edit-mode` cookie, set and
7
+ * cleared by /_tidy/edit). The live site, a crawl of staging, never has it.
7
8
  * Block pages hand it the entry they show, the block schemas the template
8
9
  * declares, and the block list as rendered; the template frames each custom
9
10
  * block with `data-tidy-block` (its key) and `data-tidy-type`, and wraps the
@@ -16,6 +17,7 @@
16
17
  * height) so a template's sticky header can sit below it.
17
18
  */
18
19
  import type { Block, BlockTypeSchema } from "./ops";
20
+ import { workerEnv } from "../lib/env";
19
21
 
20
22
  interface Props {
21
23
  collection?: string;
@@ -34,25 +36,34 @@ const { collection, id, field = "sections", blocks, value, records = [], label =
34
36
  const signedIn = Boolean(Astro.session ? await Astro.session.get("user") : null);
35
37
  const active = Astro.cookies.get("emdash-edit-mode")?.value === "true";
36
38
  const here = Astro.url.pathname + Astro.url.search;
39
+ // A visitor on the staging site (sessions exist only there) gets a slim bar
40
+ // with Sign in: the platform door signs them in as what they are there and
41
+ // sends them back here. The publish crawl never sees it.
42
+ const env = await workerEnv();
43
+ const signInUrl =
44
+ !signedIn && Astro.session && Astro.request.headers.get("user-agent") !== "tidysites-publish" && typeof env?.TIDY_CONTROL_ORIGIN === "string" && typeof env?.TIDY_SITE_ID === "string"
45
+ ? `${env.TIDY_CONTROL_ORIGIN.replace(/\/+$/, "")}/sites/${encodeURIComponent(env.TIDY_SITE_ID)}/sign-in?back=${encodeURIComponent(here)}`
46
+ : null;
37
47
  const toggle = (on: boolean) => `/_tidy/edit?on=${on ? 1 : 0}&to=${encodeURIComponent(here)}`;
38
48
  // Any entry page is editable: a sections page gets the frames and the picker,
39
49
  // an article page gets the bar (Publish, Business details, Done) over EmDash's
40
50
  // inline prose editing. One editor on the site, never two.
41
51
  const editable = active && Boolean(collection && id);
42
52
  const config = editable ? JSON.stringify({ collection, id, field, blocks: blocks ?? [], value: value ?? [], records, done: toggle(false) }) : null;
43
- const htmlClass = !signedIn ? "" : !active ? "tidy-has-bar tidy-idle" : "tidy-has-bar";
53
+ const htmlClass = !signedIn ? (signInUrl ? "tidy-has-bar tidy-idle" : "") : !active ? "tidy-has-bar tidy-idle" : "tidy-has-bar";
44
54
  ---
45
- {signedIn && (
55
+ {(signedIn || signInUrl) && (
46
56
  <>
47
57
  <div class="tidy-bar" id="tidy-bar" role="region" aria-label="Site editing">
48
- <span class="tidy-bar-label">{label}</span>
58
+ <span class="tidy-bar-label"><span class="tidy-bar-dot" aria-hidden="true"></span>{label} website<span class="tidy-bar-note">A private copy for working on it. Visitors see the live website.</span></span>
49
59
  <div class="tidy-bar-actions" id="tidy-bar-actions">
50
- {!active && <a class="tidy-btn tidy-btn-primary" href={toggle(true)}>Edit</a>}
51
- {active && !editable && <a class="tidy-btn" href={toggle(false)}>Done</a>}
60
+ {!signedIn && <a class="tidy-btn tidy-btn-primary" href={signInUrl!}>Sign in to edit</a>}
61
+ {signedIn && !active && <a class="tidy-btn tidy-btn-primary" href={toggle(true)}>Edit</a>}
62
+ {signedIn && active && !editable && <a class="tidy-btn" href={toggle(false)}>Done</a>}
52
63
  </div>
53
64
  </div>
54
65
  <script is:inline define:vars={{ htmlClass }}>document.documentElement.className += " " + htmlClass;</script>
55
- <script src="./revisions.ts"></script>
66
+ {signedIn && <script src="./revisions.ts"></script>}
56
67
  </>
57
68
  )}
58
69
  {config && (
@@ -64,10 +75,13 @@ const htmlClass = !signedIn ? "" : !active ? "tidy-has-bar tidy-idle" : "tidy-ha
64
75
  <style is:global>
65
76
  /* EmDash's own pill never shows under the bar; its inline prose editing keeps working underneath. */
66
77
  html.tidy-has-bar #emdash-toolbar { display: none !important; }
67
- html.tidy-has-bar { --tidy-bar: 44px; }
78
+ html.tidy-has-bar { --tidy-bar: 52px; }
68
79
  html.tidy-has-bar body { padding-top: var(--tidy-bar); }
69
- .tidy-bar { position: fixed; top: 0; left: 0; right: 0; height: var(--tidy-bar, 44px); z-index: 2147483000; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; box-sizing: border-box; background: #17211c; color: #fff; font: 500 13px/1 system-ui, sans-serif; box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 6px 20px rgba(0,0,0,.18); }
70
- .tidy-bar-label { opacity: .7; letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
80
+ .tidy-bar { position: fixed; top: 0; left: 0; right: 0; height: var(--tidy-bar, 52px); z-index: 2147483000; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; box-sizing: border-box; background: #17211c; color: #fff; font: 500 13px/1 system-ui, sans-serif; border-top: 3px solid #f0b429; border-bottom: 1px solid #fff; box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 6px 20px rgba(0,0,0,.18); }
81
+ .tidy-bar-label { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; font-weight: 600; }
82
+ .tidy-bar-dot { width: 9px; height: 9px; border-radius: 50%; background: #f0b429; box-shadow: 0 0 0 3px rgba(240,180,41,.25); flex: none; }
83
+ .tidy-bar-note { font-weight: 400; font-size: 13px; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
84
+ @media (max-width: 720px) { .tidy-bar-note { display: none; } }
71
85
  .tidy-bar-actions { display: flex; align-items: center; gap: 8px; }
72
86
  .tidy-bar-actions a { text-decoration: none; }
73
87
  .tidy-bar .tidy-btn { padding: 6px 12px; }
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Kept in step with package.json by the release checklist in MAINTAINING.md. */
2
- export const VERSION = "0.10.2";
2
+ export const VERSION = "0.10.4";
3
3
  export const PLUGIN_ID = "tidy-platform";