prunelle 0.1.1 → 0.7.2
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/LICENSE +21 -0
- package/llms.txt +137 -40
- package/package.json +11 -2
- package/src/a11y/declaration.ts +373 -0
- package/src/a11y/index.ts +477 -0
- package/src/a11y/rgaa-map.ts +230 -0
- package/src/attrs.ts +11 -3
- package/src/build/bundle.ts +89 -41
- package/src/build/byte-size.ts +11 -0
- package/src/build/client-entries.ts +3 -2
- package/src/build/client-plugin.ts +11 -5
- package/src/build/client-prune.ts +56 -6
- package/src/build/compile.ts +13 -10
- package/src/build/ecoindex.ts +238 -0
- package/src/build/files.ts +15 -0
- package/src/build/first-load.ts +85 -14
- package/src/build/graph.ts +29 -39
- package/src/build/index.ts +225 -122
- package/src/build/island-promote.ts +311 -0
- package/src/build/islands.ts +14 -203
- package/src/build/manifest.ts +56 -116
- package/src/build/output.ts +3 -6
- package/src/build/plugin-host.ts +115 -41
- package/src/build/precompress.ts +16 -3
- package/src/build/prerender.ts +177 -39
- package/src/build/reach.ts +200 -0
- package/src/build/render-rules.ts +2 -2
- package/src/build/report.ts +48 -5
- package/src/build/resolve.ts +8 -6
- package/src/build/routes.ts +175 -10
- package/src/build/static-headers.ts +112 -0
- package/src/build/static.ts +139 -39
- package/src/build/status-pages.ts +127 -0
- package/src/build/style-bundles.ts +526 -0
- package/src/cli/check-forms.ts +636 -0
- package/src/cli/check-imports.ts +31 -0
- package/src/cli/check-links.ts +632 -0
- package/src/cli/check-security.ts +64 -0
- package/src/cli/check.ts +101 -26
- package/src/cli/commands.ts +120 -11
- package/src/cli/docs.ts +403 -0
- package/src/cli/inspect.ts +105 -15
- package/src/cli/mcp-tools.ts +492 -0
- package/src/cli/mcp.ts +205 -0
- package/src/cli/new.ts +16 -5
- package/src/cli/render.ts +416 -0
- package/src/cli/upgrade-names.ts +73 -13
- package/src/cli/upgrade.ts +156 -22
- package/src/compiler/analyze.ts +87 -54
- package/src/compiler/browser-globals.ts +140 -17
- package/src/compiler/cacheability-private.ts +566 -0
- package/src/compiler/cacheability.ts +335 -0
- package/src/compiler/compliance-eco.ts +71 -0
- package/src/compiler/compliance-rgaa.ts +614 -0
- package/src/compiler/compliance-urls.ts +148 -0
- package/src/compiler/compliance.ts +407 -352
- package/src/compiler/data-keys.ts +199 -192
- package/src/compiler/dev-source.ts +87 -0
- package/src/compiler/dom-attrs.ts +138 -65
- package/src/compiler/dom.ts +517 -442
- package/src/compiler/expr-context.ts +260 -81
- package/src/compiler/foreign-imports.ts +88 -0
- package/src/compiler/mistakes.ts +23 -2
- package/src/compiler/props-body.ts +60 -0
- package/src/compiler/props.ts +87 -36
- package/src/compiler/scope.ts +400 -333
- package/src/compiler/server-only.ts +190 -151
- package/src/compiler/shared.ts +42 -14
- package/src/compiler/signal-reads.ts +6 -2
- package/src/compiler/spread-handlers.ts +295 -0
- package/src/compiler/ssr-prunelle-tags.ts +27 -14
- package/src/compiler/ssr.ts +220 -89
- package/src/context.ts +34 -0
- package/src/dev/error-log.ts +177 -0
- package/src/dev/host-check.ts +32 -0
- package/src/dev/index.ts +94 -34
- package/src/dev/open-editor.ts +228 -0
- package/src/dev/protocol.ts +3 -0
- package/src/dev/reload.ts +5 -3
- package/src/dev/supervisor.ts +50 -25
- package/src/dev/watchers.ts +74 -13
- package/src/dom/action.ts +47 -21
- package/src/dom/attrs.ts +15 -3
- package/src/dom/extras.ts +57 -40
- package/src/dom/index.ts +54 -14
- package/src/dom/island.ts +102 -68
- package/src/dom/loop.ts +66 -32
- package/src/eco/declaration.ts +328 -0
- package/src/eco/index.ts +69 -0
- package/src/index.ts +2 -2
- package/src/jsx-runtime.ts +2 -2
- package/src/plugins/config.ts +18 -12
- package/src/plugins/context.ts +44 -1
- package/src/plugins/index.ts +2 -2
- package/src/plugins/load.ts +30 -10
- package/src/plugins/order.ts +38 -1
- package/src/plugins/public.ts +6 -3
- package/src/plugins/services.ts +84 -0
- package/src/plugins/types.ts +51 -2
- package/src/reactivity/graph.ts +10 -0
- package/src/reactivity/index.ts +24 -16
- package/src/reactivity/selector.ts +31 -4
- package/src/reactivity/store.ts +64 -20
- package/src/server/action-flash.ts +158 -0
- package/src/server/action-protect.ts +199 -0
- package/src/server/action-registry.ts +1 -1
- package/src/server/action.ts +188 -152
- package/src/server/app-secret.ts +63 -0
- package/src/server/assets.ts +34 -2
- package/src/server/compress.ts +96 -10
- package/src/server/consent.ts +59 -22
- package/src/server/cookies.ts +16 -2
- package/src/server/document.ts +25 -10
- package/src/server/env.ts +14 -0
- package/src/server/errors.ts +308 -65
- package/src/server/form-schema.ts +337 -0
- package/src/server/health.ts +275 -0
- package/src/server/http.ts +186 -39
- package/src/server/index.ts +272 -273
- package/src/server/loader.ts +15 -2
- package/src/server/page.ts +15 -0
- package/src/server/param-matchers.ts +112 -0
- package/src/server/plugin-host.ts +125 -88
- package/src/server/public.ts +6 -5
- package/src/server/rate-limit.ts +102 -36
- package/src/server/request-body.ts +1 -1
- package/src/server/route-cache.ts +541 -0
- package/src/server/route-table.ts +356 -11
- package/src/server/router.ts +125 -40
- package/src/server/routing.ts +112 -63
- package/src/server/sanitize-html.ts +309 -0
- package/src/server/security.ts +279 -52
- package/src/server/serve-handlers.ts +31 -7
- package/src/server/standard-schema.ts +17 -0
- package/src/server/start.ts +60 -16
- package/src/server/static-dir.ts +91 -12
- package/src/server/stream.ts +68 -27
- package/src/ssr/consent-banner.ts +58 -0
- package/src/ssr/context.ts +106 -8
- package/src/ssr/index.ts +151 -4
- package/src/ssr/navigation.ts +2 -2
- package/src/ssr/region.ts +40 -19
- package/src/style.ts +64 -1
- package/src/test/browser.ts +28 -13
- package/src/test/index.ts +97 -12
- package/src/ts-plugin/diagnostics.ts +505 -0
- package/src/ts-plugin/fixes.ts +364 -0
- package/src/ts-plugin/index.ts +194 -0
- package/templates/_shared/AGENTS.md +2 -2
- package/templates/_shared/gitignore +5 -0
- package/templates/_shared/mcp.json +11 -0
- package/templates/_shared/src/routes/legal.tsx +15 -1
- package/templates/_shared/tsconfig.json +5 -0
- package/templates/app/.env.example +4 -0
- package/templates/app/package.json +2 -1
- package/templates/app/prunelle.config.ts +2 -0
- package/templates/app/src/auth.ts +4 -6
- package/templates/app/src/mail.ts +4 -0
- package/templates/app/src/routes/_layout.tsx +9 -1
- package/templates/app/src/routes/dashboard/index.tsx +42 -8
- package/templates/app/src/routes/login.tsx +49 -30
- package/templates/app/src/routes/privacy.tsx +25 -0
- package/templates/app/src/styles/app.css +8 -1
- package/templates/app/tests/app.test.ts +44 -3
- package/templates/blog/package.json +1 -1
- package/templates/blog/prunelle.config.ts +1 -1
- package/templates/blog/src/routes/_layout.tsx +6 -1
- package/templates/blog/src/routes/index.tsx +5 -1
- package/templates/blog/src/styles/app.css +6 -1
- package/templates/fullstack/package.json +1 -1
- package/templates/fullstack/src/components/GreetForm.tsx +2 -1
- package/templates/fullstack/src/routes/_layout.tsx +4 -0
- package/templates/fullstack/src/styles/app.css +11 -1
- package/templates/minimal/package.json +1 -1
- package/templates/minimal/src/routes/_layout.tsx +4 -0
- package/templates/minimal/src/styles/app.css +11 -1
- package/ts-plugin.cjs +4277 -0
|
@@ -10,6 +10,7 @@ export default function Layout({ children, locals }: LayoutProps) {
|
|
|
10
10
|
<Head>
|
|
11
11
|
<title>__APP_NAME__</title>
|
|
12
12
|
</Head>
|
|
13
|
+
<a href="#main" class="skip-link">Skip to content</a>
|
|
13
14
|
<div class="wrap">
|
|
14
15
|
<header data-layout="split" class="site-header">
|
|
15
16
|
<a href="/" class="site-brand">__APP_NAME__</a>
|
|
@@ -24,7 +25,14 @@ export default function Layout({ children, locals }: LayoutProps) {
|
|
|
24
25
|
)
|
|
25
26
|
: <Button href="/login" variant="outline" size="sm">Sign in</Button>}
|
|
26
27
|
</header>
|
|
27
|
-
<main>{children}</main>
|
|
28
|
+
<main id="main">{children}</main>
|
|
29
|
+
<footer class="site-footer">
|
|
30
|
+
<Cluster>
|
|
31
|
+
<a href="/legal">Legal notice</a>
|
|
32
|
+
<a href="/privacy">Privacy</a>
|
|
33
|
+
<a href="/accessibilite" lang="fr">Accessibilité : non conforme</a>
|
|
34
|
+
</Cluster>
|
|
35
|
+
</footer>
|
|
28
36
|
</div>
|
|
29
37
|
<Toaster />
|
|
30
38
|
</>
|
|
@@ -1,13 +1,47 @@
|
|
|
1
1
|
import type { PageProps } from 'prunelle'
|
|
2
|
-
import { Card, CardBody, CardHeader } from '@prunellejs/ui'
|
|
2
|
+
import { Button, Card, CardBody, CardHeader, Checkbox, Cluster, Notice, Stack } from '@prunellejs/ui'
|
|
3
|
+
import { Head } from 'prunelle'
|
|
4
|
+
import { auth } from '../../auth'
|
|
5
|
+
|
|
6
|
+
export default async function DashboardPage({ locals, url }: PageProps) {
|
|
7
|
+
// A refused export or deletion comes back here with a code naming why.
|
|
8
|
+
const message = auth.formMessage(url)
|
|
9
|
+
const refusal = message?.form === 'account' ? message : undefined
|
|
3
10
|
|
|
4
|
-
export default async function DashboardPage({ locals }: PageProps) {
|
|
5
11
|
return (
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
<Stack gap="lg">
|
|
13
|
+
<Head><title>Dashboard - __APP_NAME__</title></Head>
|
|
14
|
+
<h1 class="page-title">Dashboard</h1>
|
|
15
|
+
<Card>
|
|
16
|
+
<CardBody>
|
|
17
|
+
<p class="m-0">Signed in as <strong>{locals.user?.email}</strong>.</p>
|
|
18
|
+
</CardBody>
|
|
19
|
+
</Card>
|
|
20
|
+
<Card>
|
|
21
|
+
<CardHeader><h2 class="card-title">Your data</h2></CardHeader>
|
|
22
|
+
<CardBody>
|
|
23
|
+
<Stack gap="md">
|
|
24
|
+
{refusal && (
|
|
25
|
+
<Notice tone="danger" role="alert">
|
|
26
|
+
{refusal.text}
|
|
27
|
+
{refusal.code === 'account.reauth-required' && <>. <a href="/login">Sign in</a></>}
|
|
28
|
+
</Notice>
|
|
29
|
+
)}
|
|
30
|
+
<Cluster>
|
|
31
|
+
<Button href="/auth/me/export" variant="outline">Download my data</Button>
|
|
32
|
+
</Cluster>
|
|
33
|
+
<form action="/auth/me/delete" method="post">
|
|
34
|
+
<Stack gap="sm">
|
|
35
|
+
<input type="hidden" name="redirect" value="/" />
|
|
36
|
+
<Checkbox name="confirm" label="Delete my account and everything kept with it, for good" required />
|
|
37
|
+
<Cluster>
|
|
38
|
+
<Button type="submit" tone="danger" variant="outline">Delete my account</Button>
|
|
39
|
+
</Cluster>
|
|
40
|
+
</Stack>
|
|
41
|
+
</form>
|
|
42
|
+
</Stack>
|
|
43
|
+
</CardBody>
|
|
44
|
+
</Card>
|
|
45
|
+
</Stack>
|
|
12
46
|
)
|
|
13
47
|
}
|
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PageProps } from 'prunelle'
|
|
2
|
+
import { Button, Card, CardBody, CardHeader, Field, Grid, Notice, Stack } from '@prunellejs/ui'
|
|
3
|
+
import { Head } from 'prunelle'
|
|
4
|
+
import { auth } from '../auth'
|
|
5
|
+
|
|
6
|
+
export default function LoginPage({ url }: PageProps) {
|
|
7
|
+
// A failed sign-in or sign-up comes back here with a code naming its form and, when it is about one, its field.
|
|
8
|
+
const message = auth.formMessage(url)
|
|
9
|
+
const fieldError = (form: 'signin' | 'signup', field: 'email' | 'password') =>
|
|
10
|
+
message?.form === form && message.field === field ? message.text : undefined
|
|
11
|
+
const formNotice = (form: 'signin' | 'signup') =>
|
|
12
|
+
message?.form === form && message.field === undefined
|
|
13
|
+
? <Notice tone={message.tone} role={message.tone === 'danger' ? 'alert' : 'status'}>{message.text}</Notice>
|
|
14
|
+
: undefined
|
|
2
15
|
|
|
3
|
-
export default function LoginPage() {
|
|
4
16
|
return (
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
<Stack gap="lg">
|
|
18
|
+
<Head><title>Sign in - __APP_NAME__</title></Head>
|
|
19
|
+
<h1 class="page-title">Sign in or create an account</h1>
|
|
20
|
+
<Grid min="md" gap="lg">
|
|
21
|
+
<Card>
|
|
22
|
+
<CardHeader><h2 class="card-title">Sign in</h2></CardHeader>
|
|
23
|
+
<CardBody>
|
|
24
|
+
<form action="/auth/signin" method="post">
|
|
25
|
+
<Stack gap="sm">
|
|
26
|
+
{formNotice('signin')}
|
|
27
|
+
<input type="hidden" name="redirect" value="/dashboard" />
|
|
28
|
+
<Field id="in-email" label="Email" required><input id="in-email" name="email" type="email" autocomplete="email" required /></Field>
|
|
29
|
+
<Field id="in-pass" label="Password" error={fieldError('signin', 'password')} required><input id="in-pass" name="password" type="password" autocomplete="current-password" required /></Field>
|
|
30
|
+
<Button type="submit" tone="accent">Sign in</Button>
|
|
31
|
+
</Stack>
|
|
32
|
+
</form>
|
|
33
|
+
</CardBody>
|
|
34
|
+
</Card>
|
|
35
|
+
<Card>
|
|
36
|
+
<CardHeader><h2 class="card-title">Create account</h2></CardHeader>
|
|
37
|
+
<CardBody>
|
|
38
|
+
<form action="/auth/signup" method="post">
|
|
39
|
+
<Stack gap="sm">
|
|
40
|
+
{formNotice('signup')}
|
|
41
|
+
<input type="hidden" name="redirect" value="/dashboard" />
|
|
42
|
+
<Field id="up-email" label="Email" error={fieldError('signup', 'email')} required><input id="up-email" name="email" type="email" autocomplete="email" required /></Field>
|
|
43
|
+
<Field id="up-pass" label="Password" hint="Min 12 characters" error={fieldError('signup', 'password')} required><input id="up-pass" name="password" type="password" autocomplete="new-password" minlength="12" required /></Field>
|
|
44
|
+
<p class="form-note">Your email is used only to run your account. <a href="/privacy">How your data is handled</a></p>
|
|
45
|
+
<Button type="submit" tone="accent">Create account</Button>
|
|
46
|
+
</Stack>
|
|
47
|
+
</form>
|
|
48
|
+
</CardBody>
|
|
49
|
+
</Card>
|
|
50
|
+
</Grid>
|
|
51
|
+
</Stack>
|
|
33
52
|
)
|
|
34
53
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Head } from 'prunelle'
|
|
2
|
+
|
|
3
|
+
// What the RGPD (art. 13) asks to tell people when their data is collected, written for what @prunellejs/auth stores by default; `prunelle check` warns until every placeholder below is replaced.
|
|
4
|
+
// Change it when the app collects more, or when you change the auth plugin's storeIp, storeUserAgent or sessionTtlSeconds.
|
|
5
|
+
export default function Privacy() {
|
|
6
|
+
return (
|
|
7
|
+
<section>
|
|
8
|
+
<Head>
|
|
9
|
+
<title>Privacy</title>
|
|
10
|
+
</Head>
|
|
11
|
+
<h1>Privacy</h1>
|
|
12
|
+
<h2>Who is responsible</h2>
|
|
13
|
+
<p>__APP_NAME__ is run by [to fill in: your name or your company's, as on the legal notice]. For any question about your data, write to [to fill in: a contact email].</p>
|
|
14
|
+
<h2>What we collect and why</h2>
|
|
15
|
+
<p>To create your account and sign you in: your email address and a hash of your password, never the password itself. This is needed to provide the service you sign up for (RGPD art. 6.1.b).</p>
|
|
16
|
+
<p>To keep you signed in and protect your account: a session cookie, which the site cannot work without and which therefore needs no consent, and for each session the name of your browser and a shortened IP address with its last part removed.</p>
|
|
17
|
+
<h2>How long we keep it</h2>
|
|
18
|
+
<p>A session ends 30 days after your last visit, or when you sign out, and is then deleted. An account whose email address is not confirmed within 7 days is deleted. Your account is kept until you delete it from your dashboard.</p>
|
|
19
|
+
<h2>Who receives it</h2>
|
|
20
|
+
<p>Nobody else: the data stays with our host, [to fill in: the host's name], and is not shared or sold.</p>
|
|
21
|
+
<h2>Your rights</h2>
|
|
22
|
+
<p>Once signed in, your <a href="/dashboard">dashboard</a> lets you download everything we keep about you and delete your account. To correct your data or object to its use, write to the address above. If you are not satisfied with our answer, you can complain to the CNIL (cnil.fr).</p>
|
|
23
|
+
</section>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
body { margin: 0; background: var(--ui-paper); color: var(--ui-ink); font-family: var(--ui-font-body); }
|
|
2
2
|
.wrap { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
|
|
3
3
|
.site-header { padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--ui-line); }
|
|
4
|
-
.site-brand { font-family: var(--ui-font-display); font-size: 1.3rem; font-weight: 700; text-decoration: none; color: inherit; }
|
|
4
|
+
.site-brand { display: inline-flex; align-items: center; min-block-size: 2.75rem; font-family: var(--ui-font-display); font-size: 1.3rem; font-weight: 700; text-decoration: none; color: inherit; }
|
|
5
5
|
.page-title { margin: 0; font-family: var(--ui-font-display); }
|
|
6
6
|
.page-lead { margin: 0; color: var(--ui-muted); }
|
|
7
7
|
.m-0 { margin: 0; }
|
|
8
|
+
.site-footer { margin-top: 3rem; padding-top: 0.5rem; border-top: 1px solid var(--ui-line); color: var(--ui-muted); }
|
|
9
|
+
.form-note { margin: 0; color: var(--ui-muted); font-size: 0.9rem; }
|
|
10
|
+
.form-note a, [data-ui="notice"] a { color: inherit; }
|
|
11
|
+
.skip-link { display: inline-flex; align-items: center; min-block-size: 2.75rem; position: absolute; inset-inline-start: 1rem; top: -6rem; z-index: 100; padding: 0.6rem 1rem; background: var(--ui-paper); color: var(--ui-ink); border: 1px solid var(--ui-line); }
|
|
12
|
+
.skip-link:focus { top: 1rem; }
|
|
13
|
+
.site-footer a { display: inline-flex; align-items: center; min-block-size: 2.75rem; color: inherit; }
|
|
14
|
+
.card-title { margin: 0; font: inherit; }
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { TestApp } from 'prunelle/test'
|
|
2
2
|
import { beforeAll, describe, expect, it } from 'bun:test'
|
|
3
|
-
import {
|
|
3
|
+
import { mkdtempSync } from 'node:fs'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { join, resolve } from 'node:path'
|
|
4
6
|
import { testApp } from 'prunelle/test'
|
|
5
7
|
|
|
6
8
|
const root = resolve(import.meta.dir, '..')
|
|
7
|
-
|
|
9
|
+
// A file the app and this test both open, so a user the test creates can sign in to the app.
|
|
10
|
+
process.env.AUTH_DB ??= join(mkdtempSync(join(tmpdir(), '__APP_NAME__-')), 'auth.sqlite')
|
|
11
|
+
const { auth } = await import('../src/auth')
|
|
8
12
|
|
|
9
13
|
describe('__APP_NAME__', () => {
|
|
10
14
|
let app: TestApp
|
|
@@ -20,10 +24,47 @@ describe('__APP_NAME__', () => {
|
|
|
20
24
|
|
|
21
25
|
const login = await app.get('/login')
|
|
22
26
|
expect(login.status).toBe(200)
|
|
23
|
-
|
|
27
|
+
const loginHtml = await login.text()
|
|
28
|
+
expect(loginHtml).toContain('/auth/signin')
|
|
29
|
+
expect(loginHtml).toContain('href="/privacy"')
|
|
30
|
+
|
|
31
|
+
const privacy = await app.get('/privacy')
|
|
32
|
+
expect(privacy.status).toBe(200)
|
|
24
33
|
expect(app.errors).toEqual([])
|
|
25
34
|
})
|
|
26
35
|
|
|
36
|
+
it('shows a failed sign-in on the login page, not as JSON', async () => {
|
|
37
|
+
const res = await app.submit('/auth/signin', { email: 'nobody@example.com', password: 'wrong-password-123' }, { referer: 'http://localhost/login' })
|
|
38
|
+
expect(res.status).toBe(303)
|
|
39
|
+
const page = await (await app.get(res.headers.get('location')!)).text()
|
|
40
|
+
expect(page).toContain('role="alert"')
|
|
41
|
+
expect(page).toContain('Invalid email or password')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('lets a signed-in user download their data and delete their account from the dashboard', async () => {
|
|
45
|
+
const credentials = { email: 'ada@example.com', password: 'correct-horse-battery' }
|
|
46
|
+
await auth.createUser({ ...credentials, emailVerified: true })
|
|
47
|
+
const fromLogin = { referer: 'http://localhost/login' }
|
|
48
|
+
const fromDashboard = { referer: 'http://localhost/dashboard' }
|
|
49
|
+
expect((await app.submit('/auth/signin', { ...credentials, redirect: '/dashboard' }, fromLogin)).headers.get('location')).toBe('/dashboard')
|
|
50
|
+
|
|
51
|
+
const dashboard = await (await app.get('/dashboard')).text()
|
|
52
|
+
expect(dashboard).toContain('href="/auth/me/export"')
|
|
53
|
+
expect(dashboard).toContain('action="/auth/me/delete"')
|
|
54
|
+
const refused = await (await app.get('/dashboard?error=account.reauth-required')).text()
|
|
55
|
+
expect(refused).toContain('Sign in again to confirm it is you')
|
|
56
|
+
expect(refused).toContain('<a href="/login">Sign in</a>')
|
|
57
|
+
|
|
58
|
+
const dump = await app.get('/auth/me/export', fromDashboard)
|
|
59
|
+
expect(dump.status).toBe(200)
|
|
60
|
+
expect((await dump.json() as { user: { email: string } }).user.email).toBe('ada@example.com')
|
|
61
|
+
|
|
62
|
+
const deleted = await app.submit('/auth/me/delete', { confirm: 'on', redirect: '/' }, fromDashboard)
|
|
63
|
+
expect(deleted.headers.get('location')).toBe('/')
|
|
64
|
+
expect((await app.get('/dashboard')).status).toBe(302)
|
|
65
|
+
expect((await app.submit('/auth/signin', credentials, fromLogin)).headers.get('location')).toBe('/login?error=signin.invalid-credentials')
|
|
66
|
+
})
|
|
67
|
+
|
|
27
68
|
it('redirects unauthenticated requests from /dashboard to /login', async () => {
|
|
28
69
|
const res = await app.get('/dashboard')
|
|
29
70
|
expect(res.status).toBe(302)
|
|
@@ -8,7 +8,7 @@ export default defineConfig({
|
|
|
8
8
|
lang: 'en',
|
|
9
9
|
plugins: [
|
|
10
10
|
ui({ grammar: 'editorial' }),
|
|
11
|
-
seo({ site: 'https://example.com', titleTemplate: '%s — __APP_NAME__' }),
|
|
11
|
+
seo({ site: 'https://example.com', titleTemplate: '%s — __APP_NAME__', description: 'Articles & notes from __APP_NAME__', image: '/og.png' }),
|
|
12
12
|
content({
|
|
13
13
|
feeds: [{
|
|
14
14
|
path: '/rss.xml',
|
|
@@ -8,12 +8,17 @@ export default function Layout({ children }: { children: PrunelleChild }) {
|
|
|
8
8
|
<Head>
|
|
9
9
|
<title>__APP_NAME__</title>
|
|
10
10
|
</Head>
|
|
11
|
+
<a href="#main" class="skip-link">Skip to content</a>
|
|
11
12
|
<div class="wrap">
|
|
12
13
|
<header data-layout="split" class="site-header">
|
|
13
14
|
<a href="/" class="site-brand">__APP_NAME__</a>
|
|
14
15
|
<a href="/rss.xml" class="site-rss">RSS</a>
|
|
15
16
|
</header>
|
|
16
|
-
<main>{children}</main>
|
|
17
|
+
<main id="main">{children}</main>
|
|
18
|
+
<footer class="site-footer">
|
|
19
|
+
<a href="/legal">Legal notice</a>
|
|
20
|
+
<a href="/accessibilite" lang="fr">Accessibilité : non conforme</a>
|
|
21
|
+
</footer>
|
|
17
22
|
</div>
|
|
18
23
|
</>
|
|
19
24
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Badge, Card, CardBody, CardFooter, CardHeader, Cluster, Stack } from '@prunellejs/ui'
|
|
2
|
+
import { Head } from 'prunelle'
|
|
2
3
|
import { posts } from '../posts'
|
|
3
4
|
|
|
4
5
|
export const prerender = true
|
|
@@ -7,11 +8,14 @@ export default async function BlogIndex() {
|
|
|
7
8
|
const list = posts.all()
|
|
8
9
|
return (
|
|
9
10
|
<Stack gap="lg">
|
|
11
|
+
<Head>
|
|
12
|
+
<title>Articles</title>
|
|
13
|
+
</Head>
|
|
10
14
|
<h1 class="page-title">Articles</h1>
|
|
11
15
|
{list.map(post => (
|
|
12
16
|
<Card key={post.slug}>
|
|
13
17
|
<CardHeader>
|
|
14
|
-
<a href={`/blog/${post.slug}`} class="post-link">{post.data.title}</a>
|
|
18
|
+
<h2 class="card-title"><a href={`/blog/${post.slug}`} class="post-link">{post.data.title}</a></h2>
|
|
15
19
|
</CardHeader>
|
|
16
20
|
<CardBody>
|
|
17
21
|
<p class="post-desc">{post.data.description ?? ''}</p>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
body { margin: 0; background: var(--ui-paper); color: var(--ui-ink); font-family: var(--ui-font-body); }
|
|
2
2
|
.wrap { max-width: 46rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
|
|
3
3
|
.site-header { padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--ui-line); }
|
|
4
|
-
.site-brand { font-family: var(--ui-font-display); font-size: 1.35rem; font-weight: 700; text-decoration: none; color: inherit; }
|
|
4
|
+
.site-brand { display: inline-flex; align-items: center; min-block-size: 2.75rem; font-family: var(--ui-font-display); font-size: 1.35rem; font-weight: 700; text-decoration: none; color: inherit; }
|
|
5
5
|
.site-rss { font-size: 0.9rem; color: var(--ui-muted); }
|
|
6
6
|
.page-title { margin: 0; font-family: var(--ui-font-display); }
|
|
7
7
|
.post-link { color: inherit; text-decoration: none; }
|
|
8
8
|
.post-desc { margin: 0; color: var(--ui-muted); }
|
|
9
9
|
.post-title { font-family: var(--ui-font-display); margin-bottom: 0.25rem; }
|
|
10
10
|
.post-meta { color: var(--ui-muted); margin-top: 0; }
|
|
11
|
+
.skip-link { display: inline-flex; align-items: center; min-block-size: 2.75rem; position: absolute; inset-inline-start: 1rem; top: -6rem; z-index: 100; padding: 0.6rem 1rem; background: var(--ui-paper); color: var(--ui-ink); border: 1px solid var(--ui-line); }
|
|
12
|
+
.skip-link:focus { top: 1rem; }
|
|
13
|
+
.site-footer a { display: inline-flex; align-items: center; min-block-size: 2.75rem; color: inherit; }
|
|
14
|
+
.site-footer { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 3rem; padding-top: 0.5rem; border-top: 1px solid var(--ui-line); color: var(--ui-muted); }
|
|
15
|
+
.card-title { margin: 0; font: inherit; }
|
|
@@ -15,13 +15,14 @@ export function GreetForm() {
|
|
|
15
15
|
<form class="greet-form" action={greet.url} method="post" onSubmit={onSubmit}>
|
|
16
16
|
<input
|
|
17
17
|
name="name"
|
|
18
|
+
autocomplete="name"
|
|
18
19
|
aria-label="Your name"
|
|
19
20
|
placeholder="Your name"
|
|
20
21
|
value={name.value}
|
|
21
22
|
onInput={(e) => { name.value = (e.target as HTMLInputElement).value }}
|
|
22
23
|
/>
|
|
23
24
|
<button type="submit">Greet</button>
|
|
24
|
-
|
|
25
|
+
<span role="status">{reply.value}</span>
|
|
25
26
|
</form>
|
|
26
27
|
)
|
|
27
28
|
}
|
|
@@ -9,6 +9,10 @@ export default function Layout({ children }: { children: PrunelleChild }) {
|
|
|
9
9
|
<title>__APP_NAME__</title>
|
|
10
10
|
</Head>
|
|
11
11
|
<main>{children}</main>
|
|
12
|
+
<footer class="site-footer">
|
|
13
|
+
<a href="/legal">Legal notice</a>
|
|
14
|
+
<a href="/accessibilite" lang="fr">Accessibilité : non conforme</a>
|
|
15
|
+
</footer>
|
|
12
16
|
</>
|
|
13
17
|
)
|
|
14
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
*, *::before, *::after { box-sizing: border-box; }
|
|
2
2
|
body {
|
|
3
3
|
margin: 0;
|
|
4
|
-
font-family:
|
|
4
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
|
|
5
5
|
line-height: 1.6;
|
|
6
6
|
color: #111827;
|
|
7
7
|
background: #fafafa;
|
|
@@ -27,3 +27,13 @@ button:hover { background: #f3f4f6; }
|
|
|
27
27
|
gap: 0.5rem;
|
|
28
28
|
align-items: center;
|
|
29
29
|
}
|
|
30
|
+
.site-footer {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
gap: 1rem;
|
|
34
|
+
max-width: 44rem;
|
|
35
|
+
margin: 0 auto 2rem;
|
|
36
|
+
padding: 0.5rem 1.5rem 0;
|
|
37
|
+
border-top: 1px solid #e5e7eb;
|
|
38
|
+
}
|
|
39
|
+
.site-footer a { display: inline-flex; align-items: center; min-height: 2.75rem; color: #4b5563; }
|
|
@@ -9,6 +9,10 @@ export default function Layout({ children }: { children: PrunelleChild }) {
|
|
|
9
9
|
<title>__APP_NAME__</title>
|
|
10
10
|
</Head>
|
|
11
11
|
<main>{children}</main>
|
|
12
|
+
<footer class="site-footer">
|
|
13
|
+
<a href="/legal">Legal notice</a>
|
|
14
|
+
<a href="/accessibilite" lang="fr">Accessibilité : non conforme</a>
|
|
15
|
+
</footer>
|
|
12
16
|
</>
|
|
13
17
|
)
|
|
14
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
*, *::before, *::after { box-sizing: border-box; }
|
|
2
2
|
body {
|
|
3
3
|
margin: 0;
|
|
4
|
-
font-family:
|
|
4
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
|
|
5
5
|
line-height: 1.6;
|
|
6
6
|
color: #111827;
|
|
7
7
|
background: #fafafa;
|
|
@@ -20,3 +20,13 @@ button {
|
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
}
|
|
22
22
|
button:hover { background: #f3f4f6; }
|
|
23
|
+
.site-footer {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-wrap: wrap;
|
|
26
|
+
gap: 1rem;
|
|
27
|
+
max-width: 44rem;
|
|
28
|
+
margin: 0 auto 2rem;
|
|
29
|
+
padding: 0.5rem 1.5rem 0;
|
|
30
|
+
border-top: 1px solid #e5e7eb;
|
|
31
|
+
}
|
|
32
|
+
.site-footer a { display: inline-flex; align-items: center; min-height: 2.75rem; color: #4b5563; }
|