feat: enhance signup form with new styling and noindex functionality
Added new CSS styles for the signup form, including a grid layout and improved note visibility. Updated the application logic to include a noindex option for specific pages, ensuring search engines do not index sensitive content. Modified tests to verify the presence of new elements and the correct application of noindex headers.
This commit is contained in:
1 parent
019f61bc4a
commit
ffec79cbec
5 files changed
+51
-4
No files matched your search
@@ -1794,6 +1794,27 @@ article.shift-card {
|
|||||||
font-size: 1.6rem;
|
font-size: 1.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.signup-lead {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-lead p {
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-note {
|
||||||
|
font-size: 0.92rem;
|
||||||
|
line-height: 1.45;
|
||||||
|
color: var(--hope-ink-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-form .hint {
|
||||||
|
font-size: 0.92rem;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
|
||||||
.name-pair {
|
.name-pair {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
|
|||||||
+7
-1
@@ -71,6 +71,8 @@ export function createApp(
|
|||||||
at,
|
at,
|
||||||
`${only.title} · Hope Volunteer`,
|
`${only.title} · Hope Volunteer`,
|
||||||
<EventPage config={config} event={only} now={at} month={c.req.query('month')} view={c.req.query('view')} path="/" />,
|
<EventPage config={config} event={only} now={at} month={c.req.query('month')} view={c.req.query('view')} path="/" />,
|
||||||
|
200,
|
||||||
|
{ noindex: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return page(
|
return page(
|
||||||
@@ -99,6 +101,8 @@ export function createApp(
|
|||||||
at,
|
at,
|
||||||
`${event.title} · Hope Volunteer`,
|
`${event.title} · Hope Volunteer`,
|
||||||
<EventPage config={config} event={event} now={at} month={c.req.query('month')} view={c.req.query('view')} />,
|
<EventPage config={config} event={event} now={at} month={c.req.query('month')} view={c.req.query('view')} />,
|
||||||
|
200,
|
||||||
|
{ noindex: true },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,11 +146,13 @@ function page(
|
|||||||
title: string,
|
title: string,
|
||||||
body: Child,
|
body: Child,
|
||||||
status: 200 | 404 | 500 = 200,
|
status: 200 | 404 | 500 = 200,
|
||||||
|
options?: { noindex?: boolean },
|
||||||
) {
|
) {
|
||||||
c.header('Cache-Control', 'no-store');
|
c.header('Cache-Control', 'no-store');
|
||||||
|
if (options?.noindex) c.header('X-Robots-Tag', 'noindex');
|
||||||
const account = readSession(db, c.req.header('cookie'), now);
|
const account = readSession(db, c.req.header('cookie'), now);
|
||||||
return c.html(
|
return c.html(
|
||||||
<Layout config={config} title={title} path={c.req.path} account={account ? { csrf: account.csrf } : null}>
|
<Layout config={config} title={title} path={c.req.path} noindex={options?.noindex} account={account ? { csrf: account.csrf } : null}>
|
||||||
{body}
|
{body}
|
||||||
</Layout>,
|
</Layout>,
|
||||||
status,
|
status,
|
||||||
|
|||||||
+6
-1
@@ -26,6 +26,7 @@ export function Layout(props: {
|
|||||||
title: string;
|
title: string;
|
||||||
path?: string;
|
path?: string;
|
||||||
turnstile?: boolean;
|
turnstile?: boolean;
|
||||||
|
noindex?: boolean;
|
||||||
account?: { csrf: string } | null;
|
account?: { csrf: string } | null;
|
||||||
children?: Child;
|
children?: Child;
|
||||||
}) {
|
}) {
|
||||||
@@ -44,6 +45,7 @@ export function Layout(props: {
|
|||||||
<head>
|
<head>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
{props.noindex ? <meta name="robots" content="noindex" /> : null}
|
||||||
<title>{props.title}</title>
|
<title>{props.title}</title>
|
||||||
<link rel="icon" href={asset(props.config, '/img/favicons/favicon.png')} />
|
<link rel="icon" href={asset(props.config, '/img/favicons/favicon.png')} />
|
||||||
<link rel="apple-touch-icon" href={asset(props.config, '/img/favicons/favicon-apple.png')} />
|
<link rel="apple-touch-icon" href={asset(props.config, '/img/favicons/favicon-apple.png')} />
|
||||||
@@ -1041,7 +1043,10 @@ function SignupForm(props: { config: AppConfig; shiftId: number; remaining: numb
|
|||||||
return (
|
return (
|
||||||
<form class="signup-form" method="post" action={appPath(props.config, `/s/${props.shiftId}`)}>
|
<form class="signup-form" method="post" action={appPath(props.config, `/s/${props.shiftId}`)}>
|
||||||
<h2>Sign up</h2>
|
<h2>Sign up</h2>
|
||||||
|
<div class="signup-lead">
|
||||||
<p>Choose how many people are coming, including you. This signup holds that many spots under your name. Another person can use the same email address.</p>
|
<p>Choose how many people are coming, including you. This signup holds that many spots under your name. Another person can use the same email address.</p>
|
||||||
|
<p class="signup-note">Your full name is listed on the public sign-up page. Email, phone, and notes stay off that page.</p>
|
||||||
|
</div>
|
||||||
<noscript>
|
<noscript>
|
||||||
<p class="error">Signing up needs JavaScript for the abuse check. The pantry has not published a contact method for help with signup.</p>
|
<p class="error">Signing up needs JavaScript for the abuse check. The pantry has not published a contact method for help with signup.</p>
|
||||||
</noscript>
|
</noscript>
|
||||||
@@ -1110,7 +1115,7 @@ function SignupForm(props: { config: AppConfig; shiftId: number; remaining: numb
|
|||||||
) : null}
|
) : null}
|
||||||
</label>
|
</label>
|
||||||
<div class="cf-turnstile" data-sitekey={form.siteKey} data-action="signup" />
|
<div class="cf-turnstile" data-sitekey={form.siteKey} data-action="signup" />
|
||||||
<p id="signup-turnstile-hint">This check confirms the signup came from a browser.</p>
|
<p class="signup-note" id="signup-turnstile-hint">This check confirms the signup came from a browser.</p>
|
||||||
<button type="submit">Sign up</button>
|
<button type="submit">Sign up</button>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ describe('public pages', () => {
|
|||||||
expect(html).toContain('Wednesday Sorting');
|
expect(html).toContain('Wednesday Sorting');
|
||||||
expect(html).toContain('Wednesday Greeting');
|
expect(html).toContain('Wednesday Greeting');
|
||||||
expect(html).toContain('Lane Wednesday');
|
expect(html).toContain('Lane Wednesday');
|
||||||
|
expect(html).toContain('<meta name="robots" content="noindex"');
|
||||||
|
expect(home.headers.get('x-robots-tag')).toBe('noindex');
|
||||||
expect(html).toContain('class="roster-mark" src="/img/sunburst.png?v=');
|
expect(html).toContain('class="roster-mark" src="/img/sunburst.png?v=');
|
||||||
expect(html).toContain('Live Greeting');
|
expect(html).toContain('Live Greeting');
|
||||||
expect(html).toContain('0/2 spots filled');
|
expect(html).toContain('0/2 spots filled');
|
||||||
@@ -116,6 +118,8 @@ describe('public pages', () => {
|
|||||||
expect(eventHtml).toContain('Sioux Center, Iowa');
|
expect(eventHtml).toContain('Sioux Center, Iowa');
|
||||||
expect(eventHtml).toContain('Wednesday Sorting');
|
expect(eventHtml).toContain('Wednesday Sorting');
|
||||||
expect(eventHtml).toContain('Lane Wednesday');
|
expect(eventHtml).toContain('Lane Wednesday');
|
||||||
|
expect(eventHtml).toContain('<meta name="robots" content="noindex"');
|
||||||
|
expect(event.headers.get('x-robots-tag')).toBe('noindex');
|
||||||
expect(eventHtml).toContain('Sign up');
|
expect(eventHtml).toContain('Sign up');
|
||||||
expect(eventHtml).not.toContain('shift-calendar');
|
expect(eventHtml).not.toContain('shift-calendar');
|
||||||
expect(eventHtml).not.toContain('November 2026');
|
expect(eventHtml).not.toContain('November 2026');
|
||||||
@@ -164,6 +168,9 @@ describe('public pages', () => {
|
|||||||
expect(shiftHtml).toContain('name="last_name"');
|
expect(shiftHtml).toContain('name="last_name"');
|
||||||
expect(shiftHtml).toContain('First name');
|
expect(shiftHtml).toContain('First name');
|
||||||
expect(shiftHtml).toContain('Last name');
|
expect(shiftHtml).toContain('Last name');
|
||||||
|
expect(shiftHtml).toContain('class="signup-note">Your full name is listed on the public sign-up page. Email, phone, and notes stay off that page.');
|
||||||
|
expect(shiftHtml).not.toContain('name="robots"');
|
||||||
|
expect(shift.headers.get('x-robots-tag')).toBeNull();
|
||||||
expect(shiftHtml).toContain('https://challenges.cloudflare.com/turnstile/v0/api.js');
|
expect(shiftHtml).toContain('https://challenges.cloudflare.com/turnstile/v0/api.js');
|
||||||
expect(shiftHtml).not.toContain('data-under-18');
|
expect(shiftHtml).not.toContain('data-under-18');
|
||||||
expect(shiftHtml).not.toContain('data-guardian');
|
expect(shiftHtml).not.toContain('data-guardian');
|
||||||
@@ -506,6 +513,7 @@ describe('public pages', () => {
|
|||||||
expect(html).toContain('<title>Volunteer shifts · Hope Volunteer</title>');
|
expect(html).toContain('<title>Volunteer shifts · Hope Volunteer</title>');
|
||||||
expect(html).toContain('<h1>Volunteer shifts</h1>');
|
expect(html).toContain('<h1>Volunteer shifts</h1>');
|
||||||
expect(html).toContain('No events are posted.');
|
expect(html).toContain('No events are posted.');
|
||||||
|
expect(html).not.toContain('name="robots"');
|
||||||
expect(html).not.toContain('Weekly pantry');
|
expect(html).not.toContain('Weekly pantry');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -557,7 +565,10 @@ describe('public pages', () => {
|
|||||||
published: 1,
|
published: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const html = await (await app.request('/')).text();
|
const home = await app.request('/');
|
||||||
|
const html = await home.text();
|
||||||
|
expect(home.headers.get('x-robots-tag')).toBeNull();
|
||||||
|
expect(html).not.toContain('name="robots"');
|
||||||
expect(html).toContain('<h1>Volunteer shifts</h1>');
|
expect(html).toContain('<h1>Volunteer shifts</h1>');
|
||||||
expect(html).toContain('aria-label="Published events"');
|
expect(html).toContain('aria-label="Published events"');
|
||||||
expect(html).toContain('View shifts');
|
expect(html).toContain('View shifts');
|
||||||
@@ -574,7 +585,10 @@ describe('public pages', () => {
|
|||||||
expect(html).not.toContain('Bagging');
|
expect(html).not.toContain('Bagging');
|
||||||
expect(html).not.toContain('class="day-card"');
|
expect(html).not.toContain('class="day-card"');
|
||||||
|
|
||||||
const event = await (await app.request('/e/volunteer-shifts')).text();
|
const eventResponse = await app.request('/e/volunteer-shifts');
|
||||||
|
const event = await eventResponse.text();
|
||||||
|
expect(eventResponse.headers.get('x-robots-tag')).toBe('noindex');
|
||||||
|
expect(event).toContain('<meta name="robots" content="noindex"');
|
||||||
expect(event).toContain('Bagging');
|
expect(event).toContain('Bagging');
|
||||||
expect(event).toContain('Bring a box.');
|
expect(event).toContain('Bring a box.');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ describe('capacity-safe signup', () => {
|
|||||||
const formHtml = await form.text();
|
const formHtml = await form.text();
|
||||||
expect(formHtml).toContain('How many people?');
|
expect(formHtml).toContain('How many people?');
|
||||||
expect(formHtml).toContain('This signup holds that many spots.');
|
expect(formHtml).toContain('This signup holds that many spots.');
|
||||||
|
expect(formHtml).toContain('Your full name is listed on the public sign-up page.');
|
||||||
expect(formHtml).toContain('value="4"');
|
expect(formHtml).toContain('value="4"');
|
||||||
|
|
||||||
const saved = await postSignup(
|
const saved = await postSignup(
|
||||||
|
|||||||
Reference in new issue
Block a user