Skip to content

Commit 07c67be

Browse files
aXenDeveloperclaude
andcommitted
feat(core): site offline mode with opening countdown
- Site offline mode: the public site shows a status notice card with an optional opening countdown while admins and moderators with the new permission keep using it, marked by a staff chip in the header. - AdminCP: edit the site status inline with a live preview and see the offline state in the debug panel. - API: site offline middleware gates public routes; auth, session and passkey routes stay reachable so staff can still sign in. - Settings: grouped side nav (Account / Preferences / Privacy & safety), privacy switches moved to /settings/privacy, settings breadcrumb removed. - Plan: plans/site-offline-mode.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7d68dd9 commit 07c67be

92 files changed

Lines changed: 2956 additions & 182 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE TABLE "core_site_status" (
2+
"id" integer PRIMARY KEY DEFAULT 1,
3+
"offline" boolean DEFAULT false NOT NULL,
4+
"message" jsonb DEFAULT '[]' NOT NULL,
5+
"opensAt" timestamp with time zone,
6+
"showCountdown" boolean DEFAULT true NOT NULL,
7+
"changedAt" timestamp with time zone DEFAULT now() NOT NULL,
8+
"changedById" integer,
9+
"updatedAt" timestamp DEFAULT now() NOT NULL
10+
);
11+
--> statement-breakpoint
12+
ALTER TABLE "core_site_status" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
13+
ALTER TABLE "core_site_status" ADD CONSTRAINT "core_site_status_changedById_core_users_id_fkey" FOREIGN KEY ("changedById") REFERENCES "core_users"("id") ON DELETE SET NULL;
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
{
2+
"type": "diff",
3+
"version": "9",
4+
"dialect": "postgres",
5+
"id": "7453f5c0-b352-419a-bc5e-314a1576c86f",
6+
"prevIds": [
7+
"20d31aad-bc7f-4e35-b1f6-059bd8899c2b"
8+
],
9+
"footprints": [
10+
{
11+
"statementType": "create_table",
12+
"statementTarget": [
13+
"table",
14+
"public",
15+
"core_site_status"
16+
],
17+
"writes": [
18+
"s|tbl|public.core_site_status",
19+
"n|tbl|public.core_site_status",
20+
"e|tbl|public.core_site_status",
21+
"n|rel|public.core_site_status",
22+
"n|type|public.core_site_status",
23+
"n|rel|public.core_site_status_pkey"
24+
],
25+
"reads": [
26+
"n|sch|public"
27+
]
28+
},
29+
{
30+
"statementType": "create_fk",
31+
"statementTarget": [
32+
"table",
33+
"public",
34+
"core_site_status"
35+
],
36+
"writes": [
37+
"s|fk|public.core_site_status.core_site_status_changedById_core_users_id_fkey",
38+
"n|fk|public.core_site_status.core_site_status_changedById_core_users_id_fkey",
39+
"e|fk|public.core_site_status.core_site_status_changedById_core_users_id_fkey",
40+
"n|con|public.core_site_status.core_site_status_changedById_core_users_id_fkey"
41+
],
42+
"reads": [
43+
"n|tbl|public.core_site_status",
44+
"n|sch|public",
45+
"n|tbl|public.core_users",
46+
"n|sch|public",
47+
"n|col|public.core_site_status.changedById",
48+
"n|col|public.core_users.id",
49+
"e|uniqueness|public.core_users.id"
50+
]
51+
}
52+
],
53+
"deltas": [
54+
{
55+
"op": "create",
56+
"row": {
57+
"schema": "public",
58+
"name": "core_site_status",
59+
"isRlsEnabled": true,
60+
"entityType": "tables"
61+
}
62+
},
63+
{
64+
"op": "create",
65+
"row": {
66+
"schema": "public",
67+
"table": "core_site_status",
68+
"name": "id",
69+
"type": "integer",
70+
"typeSchema": null,
71+
"notNull": true,
72+
"dimensions": 0,
73+
"default": "1",
74+
"generated": null,
75+
"identity": null,
76+
"entityType": "columns"
77+
}
78+
},
79+
{
80+
"op": "create",
81+
"row": {
82+
"schema": "public",
83+
"table": "core_site_status",
84+
"name": "offline",
85+
"type": "boolean",
86+
"typeSchema": null,
87+
"notNull": true,
88+
"dimensions": 0,
89+
"default": "false",
90+
"generated": null,
91+
"identity": null,
92+
"entityType": "columns"
93+
}
94+
},
95+
{
96+
"op": "create",
97+
"row": {
98+
"schema": "public",
99+
"table": "core_site_status",
100+
"name": "message",
101+
"type": "jsonb",
102+
"typeSchema": null,
103+
"notNull": true,
104+
"dimensions": 0,
105+
"default": "'[]'",
106+
"generated": null,
107+
"identity": null,
108+
"entityType": "columns"
109+
}
110+
},
111+
{
112+
"op": "create",
113+
"row": {
114+
"schema": "public",
115+
"table": "core_site_status",
116+
"name": "opensAt",
117+
"type": "timestamp with time zone",
118+
"typeSchema": null,
119+
"notNull": false,
120+
"dimensions": 0,
121+
"default": null,
122+
"generated": null,
123+
"identity": null,
124+
"entityType": "columns"
125+
}
126+
},
127+
{
128+
"op": "create",
129+
"row": {
130+
"schema": "public",
131+
"table": "core_site_status",
132+
"name": "showCountdown",
133+
"type": "boolean",
134+
"typeSchema": null,
135+
"notNull": true,
136+
"dimensions": 0,
137+
"default": "true",
138+
"generated": null,
139+
"identity": null,
140+
"entityType": "columns"
141+
}
142+
},
143+
{
144+
"op": "create",
145+
"row": {
146+
"schema": "public",
147+
"table": "core_site_status",
148+
"name": "changedAt",
149+
"type": "timestamp with time zone",
150+
"typeSchema": null,
151+
"notNull": true,
152+
"dimensions": 0,
153+
"default": "now()",
154+
"generated": null,
155+
"identity": null,
156+
"entityType": "columns"
157+
}
158+
},
159+
{
160+
"op": "create",
161+
"row": {
162+
"schema": "public",
163+
"table": "core_site_status",
164+
"name": "changedById",
165+
"type": "integer",
166+
"typeSchema": null,
167+
"notNull": false,
168+
"dimensions": 0,
169+
"default": null,
170+
"generated": null,
171+
"identity": null,
172+
"entityType": "columns"
173+
}
174+
},
175+
{
176+
"op": "create",
177+
"row": {
178+
"schema": "public",
179+
"table": "core_site_status",
180+
"name": "updatedAt",
181+
"type": "timestamp",
182+
"typeSchema": null,
183+
"notNull": true,
184+
"dimensions": 0,
185+
"default": "now()",
186+
"generated": null,
187+
"identity": null,
188+
"entityType": "columns"
189+
}
190+
},
191+
{
192+
"op": "create",
193+
"row": {
194+
"schema": "public",
195+
"table": "core_site_status",
196+
"name": "core_site_status_changedById_core_users_id_fkey",
197+
"nameExplicit": false,
198+
"columns": [
199+
"changedById"
200+
],
201+
"schemaTo": "public",
202+
"tableTo": "core_users",
203+
"columnsTo": [
204+
"id"
205+
],
206+
"onUpdate": "NO ACTION",
207+
"onDelete": "SET NULL",
208+
"entityType": "fks"
209+
}
210+
},
211+
{
212+
"op": "create",
213+
"row": {
214+
"schema": "public",
215+
"table": "core_site_status",
216+
"name": "core_site_status_pkey",
217+
"columns": [
218+
"id"
219+
],
220+
"nameExplicit": false,
221+
"entityType": "pks"
222+
}
223+
}
224+
]
225+
}

‎apps/web/content/docs/dev/events/built-in-events.mdx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,50 @@ these events for side effects such as a thank-you notification.
737737
**A listener would** send a receipt notification, post to a sales channel, or
738738
clear a cached page that shows the buyer's purchases.
739739

740+
## Site status events
741+
742+
One name, exported from `@vitnode/api/events/site` as
743+
`siteStatusUpdatedEvent`. It fires **after** the save has committed and the
744+
cached status is expired.
745+
746+
| Event | Payload | Fires when |
747+
| --------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------- |
748+
| `site.status.updated` | `{ offline, switched, opensAt, changedById }` | An admin switches the site off or on, or edits its message, in the **Site status** card on **AdminCP → Debug Panel** |
749+
750+
<Accordions>
751+
<Accordion title="site.status.updated">
752+
753+
Emitted by `PUT /admin/site/status`. A save that only edits the offline
754+
message fires it too, with `switched: false`. See
755+
[Site offline mode](/docs/dev/site-offline-mode).
756+
757+
<TypeTable
758+
type={{
759+
offline: {
760+
description: 'Whether the site is offline after this save.',
761+
type: 'boolean',
762+
},
763+
switched: {
764+
description: 'Whether this save flipped `offline`.',
765+
type: 'boolean',
766+
},
767+
opensAt: {
768+
description: 'The planned opening time as an ISO string, or `null` without a countdown.',
769+
type: 'string | null',
770+
},
771+
changedById: {
772+
description: 'Id of the admin who saved it.',
773+
type: 'number | null',
774+
},
775+
}}
776+
/>
777+
778+
**A listener would** post "We're back!" to a chat webhook when
779+
`switched && !offline`.
780+
781+
</Accordion>
782+
</Accordions>
783+
740784
## Page layout events
741785

742786
One name, exported from `@vitnode/api/events/pages` as

‎apps/web/content/docs/dev/meta.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"cli",
5555
"deployments",
5656
"updates",
57+
"site-offline-mode",
5758
"debugging",
5859
"swagger",
5960
"contribution",
53.4 KB
Loading

0 commit comments

Comments
 (0)