feat: give the app its own nav under the pantry header
Site links now follow hopefoodpantrysc.org. Calendar, Coordinator, and Log out sit in a separate white pill on every page.
This commit is contained in:
1 parent
ec259f58b2
commit
03da30dbbc
5 files changed
+660
-458
No files matched your search
+98
-94
@@ -13,6 +13,11 @@ function asset(config: AppConfig, file: string): string {
|
||||
return appPath(config, file);
|
||||
}
|
||||
|
||||
function pathIs(path: string | undefined, target: string): boolean {
|
||||
if (!path) return false;
|
||||
return path === target || path.startsWith(`${target}/`);
|
||||
}
|
||||
|
||||
export function Layout(props: {
|
||||
config: AppConfig;
|
||||
title: string;
|
||||
@@ -22,8 +27,9 @@ export function Layout(props: {
|
||||
children?: Child;
|
||||
}) {
|
||||
const home = appPath(props.config, '/');
|
||||
const privacy = appPath(props.config, '/privacy');
|
||||
const coordinator = appPath(props.config, props.account ? '/admin' : '/login');
|
||||
const coordinatorHere = pathIs(props.path, coordinator);
|
||||
const volunteeringCurrent = props.path === home ? 'page' : undefined;
|
||||
const logo = asset(props.config, '/img/logo.png');
|
||||
const menu = asset(props.config, '/img/icons/menu.svg');
|
||||
const close = asset(props.config, '/img/icons/close.svg');
|
||||
@@ -46,85 +52,72 @@ export function Layout(props: {
|
||||
<a class="skip-link" href="#content">
|
||||
Skip to content
|
||||
</a>
|
||||
<header class="site-header">
|
||||
<a class="logo-link" href={`${PANTRY_SITE}/`}>
|
||||
<img class="logo" src={logo} alt="Hope Food Pantry" />
|
||||
</a>
|
||||
<input class="nav-toggle" id="nav-toggle" type="checkbox" />
|
||||
<label class="btn-mobile-nav" for="nav-toggle">
|
||||
<img class="icon-mobile-nav icon-open" src={menu} alt="" />
|
||||
<img class="icon-mobile-nav icon-close" src={close} alt="" />
|
||||
<span class="sr-only">Menu</span>
|
||||
</label>
|
||||
<div class="header-side">
|
||||
<nav aria-label="Primary">
|
||||
<ul class="nav-links">
|
||||
<li>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/`}>
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/about.html`}>
|
||||
About
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/faq.html`}>
|
||||
FAQ
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="main-nav-link" href={home} aria-current={props.path === home ? 'page' : undefined}>
|
||||
Volunteering
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/#contact`}>
|
||||
Contact
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn" href="https://donorbox.org/hope-food-pantry-1">
|
||||
Donate
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<ul class="utility-links">
|
||||
<header class="header">
|
||||
<nav class="nav" aria-label="Primary">
|
||||
<a href={`${PANTRY_SITE}/`}>
|
||||
<img class="logo" src={logo} alt="Hope Food Pantry logo" />
|
||||
</a>
|
||||
<ul class="nav-links">
|
||||
<li>
|
||||
<a href={home} aria-current={props.path === home ? 'page' : undefined}>
|
||||
Calendar
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/`}>
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={privacy} aria-current={props.path === privacy ? 'page' : undefined}>
|
||||
Privacy
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/about`}>
|
||||
About
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={coordinator}>Coordinator</a>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/faq`}>
|
||||
FAQ
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="main-nav-link" href={home} aria-current={volunteeringCurrent}>
|
||||
Volunteering
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/#contact`}>
|
||||
Contact
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn" href="https://donorbox.org/hope-food-pantry-1">
|
||||
Donate
|
||||
</a>
|
||||
</li>
|
||||
{props.account ? (
|
||||
<li>
|
||||
<form method="post" action={appPath(props.config, '/logout')} class="utility-logout">
|
||||
<input type="hidden" name="csrf" value={props.account.csrf} />
|
||||
<button type="submit">Log out</button>
|
||||
</form>
|
||||
</li>
|
||||
) : null}
|
||||
</ul>
|
||||
</div>
|
||||
<button class="btn-mobile-nav" type="button" aria-expanded="false" aria-label="Menu">
|
||||
<img class="icon-mobile-nav" src={menu} alt="" name="open" />
|
||||
<img class="icon-mobile-nav" src={close} alt="" name="close" />
|
||||
</button>
|
||||
</nav>
|
||||
</header>
|
||||
<main id="content" tabIndex={-1}>
|
||||
<div class="session-bar">
|
||||
<a href={home} aria-current={props.path === home ? 'page' : undefined}>
|
||||
Calendar
|
||||
</a>
|
||||
<a href={coordinator} class={props.account ? undefined : 'session-entry'} aria-current={coordinatorHere ? 'page' : undefined}>
|
||||
Coordinator
|
||||
</a>
|
||||
{props.account ? (
|
||||
<form method="post" action={appPath(props.config, '/logout')} class="session-logout">
|
||||
<input type="hidden" name="csrf" value={props.account.csrf} />
|
||||
<button type="submit">Log out</button>
|
||||
</form>
|
||||
) : null}
|
||||
</div>
|
||||
{props.children}
|
||||
</main>
|
||||
<footer class="site-footer">
|
||||
<img class="footer-wave" src={wave} alt="" />
|
||||
<div class="footer-nav">
|
||||
<div class="footer-brand">
|
||||
<a class="logo-link" href={`${PANTRY_SITE}/`}>
|
||||
<img class="logo" src={logo} alt="Hope Food Pantry" />
|
||||
<footer class="footer">
|
||||
<img class="wave wave-secondary" src={wave} alt="" />
|
||||
<nav class="footer-nav" aria-label="Footer">
|
||||
<div>
|
||||
<a href={`${PANTRY_SITE}/`}>
|
||||
<img class="logo" src={logo} alt="Hope Food Pantry logo" />
|
||||
</a>
|
||||
<p class="equal-text">
|
||||
Hope Food Pantry is an{' '}
|
||||
@@ -134,30 +127,30 @@ export function Layout(props: {
|
||||
</p>
|
||||
</div>
|
||||
<div class="footer-cell">
|
||||
<h2>Contact Us</h2>
|
||||
<h3>Contact Us</h3>
|
||||
<p>
|
||||
<a href="tel:+17125409351">712-540-9351</a>
|
||||
<a href="tel:+17125409351">712‑540‑9351</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="mailto:hopepantry@gmail.com">hopepantry@gmail.com</a>
|
||||
</p>
|
||||
<div class="social-links">
|
||||
<a href="https://www.facebook.com/schopefoodpantry" target="_blank" rel="noopener noreferrer">
|
||||
<span class="social-flex">
|
||||
<img src={facebook} alt="" />
|
||||
<span>schopefoodpantry</span>
|
||||
</span>
|
||||
<div class="social-flex">
|
||||
<img src={facebook} alt="facebook icon" />
|
||||
<p>schopefoodpantry</p>
|
||||
</div>
|
||||
</a>
|
||||
<a href="https://www.instagram.com/hopefoodpantrysc" target="_blank" rel="noopener noreferrer">
|
||||
<span class="social-flex">
|
||||
<img src={instagram} alt="" />
|
||||
<span>hopefoodpantrysc</span>
|
||||
</span>
|
||||
<div class="social-flex">
|
||||
<img src={instagram} alt="instagram icon" />
|
||||
<p>hopefoodpantrysc</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-cell">
|
||||
<h2>Address</h2>
|
||||
<h3>Address</h3>
|
||||
<address>
|
||||
<p>
|
||||
4155 US 75 Ave
|
||||
@@ -166,41 +159,52 @@ export function Layout(props: {
|
||||
<br />
|
||||
(Rear of Property)
|
||||
</p>
|
||||
<br />
|
||||
<p>Mail to: PO Box 21</p>
|
||||
</address>
|
||||
</div>
|
||||
<div class="footer-cell">
|
||||
<h2>Navigation</h2>
|
||||
<ul class="footer-links">
|
||||
<h3>Navigation</h3>
|
||||
<ul class="footer-nav-links">
|
||||
<li>
|
||||
<a href={`${PANTRY_SITE}/`}>Home</a>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/`}>
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={`${PANTRY_SITE}/about.html`}>About</a>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/about`}>
|
||||
About
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={`${PANTRY_SITE}/faq.html`}>FAQ</a>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/faq`}>
|
||||
FAQ
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={home} aria-current={props.path === home ? 'page' : undefined}>
|
||||
<a class="main-nav-link" href={home} aria-current={volunteeringCurrent}>
|
||||
Volunteering
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={`${PANTRY_SITE}/#contact`}>Contact</a>
|
||||
<a class="main-nav-link" href={`${PANTRY_SITE}/#contact`}>
|
||||
Contact
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://donorbox.org/hope-food-pantry-1">Donate</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href={privacy} aria-current={props.path === privacy ? 'page' : undefined}>
|
||||
Privacy
|
||||
<a class="main-nav-link" href="https://donorbox.org/hope-food-pantry-1">
|
||||
Donate
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<p class="copyright-text">Hope Food Pantry, Sioux Center, Iowa</p>
|
||||
</nav>
|
||||
<p class="copyright-text">
|
||||
Hope Food Pantry © 2026 | Design & Development by{' '}
|
||||
<a href="https://cosmicallycreative.com" target="_blank" rel="noopener noreferrer">
|
||||
Cosmically Creative
|
||||
</a>
|
||||
</p>
|
||||
</footer>
|
||||
{props.turnstile ? <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer /> : null}
|
||||
<script src={appPath(props.config, '/js/enhance.js')} defer />
|
||||
@@ -597,8 +601,8 @@ function CalendarDayCell(props: { config: AppConfig; day: CalendarDay; today: st
|
||||
<span class="today-flag" aria-hidden="true">
|
||||
Today
|
||||
</span>
|
||||
) : null}
|
||||
</p>
|
||||
) : null}
|
||||
</p>
|
||||
{props.shifts.length > 0 ? (
|
||||
<details class="day-reveal" name={props.weekName} data-date={props.day.date}>
|
||||
<summary class="day-summary">
|
||||
|
||||
+16
-14
@@ -5,6 +5,7 @@ import type { Context } from 'hono';
|
||||
import type { Hono } from 'hono';
|
||||
import type { Child } from 'hono/jsx';
|
||||
import { listMoveTargets, switchSignup } from './admin/store.js';
|
||||
import { readSession } from './auth/session.js';
|
||||
import { cancelTokenMatches, issueCancelToken, issueReminderPageToken, issueSwitchToken, reminderPageTokenMatches, switchTokenMatches } from './cancel-token.js';
|
||||
import { clientAddress } from './client-ip.js';
|
||||
import { confirmationCookie, openConfirmation, sealConfirmation } from './confirm-cookie.js';
|
||||
@@ -65,7 +66,7 @@ export function registerPublicSignup(app: Hono, services: SignupServices): void
|
||||
|
||||
app.get(appPath(config, '/s/:id'), (c) => {
|
||||
const shift = loadShift(services, c.req.param('id') ?? '');
|
||||
if (!shift) return html(c, config, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
if (!shift) return html(c, services, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
return shiftResponse(c, services, shift, 200, blankForm(services, shift));
|
||||
});
|
||||
|
||||
@@ -73,14 +74,14 @@ export function registerPublicSignup(app: Hono, services: SignupServices): void
|
||||
|
||||
app.get(appPath(config, '/s/:id/confirmed'), (c) => {
|
||||
const shift = loadShift(services, c.req.param('id') ?? '');
|
||||
if (!shift) return html(c, config, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
if (!shift) return html(c, services, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
const seal = openConfirmation(config.sessionSecret, c.req.header('cookie'), epochMs(services.now()));
|
||||
const manage = seal && seal.shiftId === shift.id ? readManageSignup(services.db, seal.token, services.now()) : null;
|
||||
const matches = Boolean(manage && seal && manage.signupId === seal.signupId);
|
||||
const cancelled = matches && manage?.status === 'cancelled';
|
||||
return html(
|
||||
c,
|
||||
config,
|
||||
services,
|
||||
cancelled ? 'This signup is cancelled · Hope Volunteer' : "You're signed up · Hope Volunteer",
|
||||
<ConfirmationPage
|
||||
config={config}
|
||||
@@ -103,7 +104,7 @@ async function submitSignup(c: Context, services: SignupServices): Promise<Respo
|
||||
const { config, db } = services;
|
||||
const now = services.now();
|
||||
const shift = loadShift(services, c.req.param('id') ?? '');
|
||||
if (!shift) return html(c, config, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
if (!shift) return html(c, services, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
const ip = clientAddress(config.trustProxy, peerAddress(c, services.clientIp), c.req.header('x-forwarded-for'));
|
||||
if (!originAllowed(c, config.baseUrl)) {
|
||||
return shiftResponse(c, services, shift, 403, formFor(services, shift, EMPTY_SIGNUP, {}, null), ORIGIN);
|
||||
@@ -174,7 +175,7 @@ async function submitSignup(c: Context, services: SignupServices): Promise<Respo
|
||||
mail: mailIdentity(db, config),
|
||||
});
|
||||
if (reserved.ok) return redirectConfirmed(c, services, shift.id, reserved.manageToken ? { signupId: reserved.signupId, token: reserved.manageToken } : null);
|
||||
if (reserved.reason === 'not_found') return html(c, config, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
if (reserved.reason === 'not_found') return html(c, services, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
if (reserved.reason === 'closed') return shiftResponse(c, services, loadShift(services, String(shift.id)) ?? shift, 400, null, CLOSED);
|
||||
if (reserved.reason === 'full') return shiftResponse(c, services, loadShift(services, String(shift.id)) ?? shift, 409, null, FULL);
|
||||
if (reserved.reason === 'duplicate') {
|
||||
@@ -221,7 +222,7 @@ function shiftResponse(
|
||||
const showForm = signup !== null && !current.cancelled && !current.ended && !current.full;
|
||||
return html(
|
||||
c,
|
||||
services.config,
|
||||
services,
|
||||
`${current.role} · Hope Volunteer`,
|
||||
<ShiftPage config={services.config} shift={current} signup={showForm ? signup : null} notice={notice} />,
|
||||
status,
|
||||
@@ -306,7 +307,7 @@ function showManage(c: Context, services: SignupServices, token: string, status:
|
||||
const note = manageNote(c.req.query('notice'));
|
||||
return html(
|
||||
c,
|
||||
services.config,
|
||||
services,
|
||||
'Your signup · Hope Volunteer',
|
||||
<ManagePage
|
||||
signup={signup}
|
||||
@@ -330,9 +331,9 @@ function missingManage(c: Context, services: SignupServices) {
|
||||
const limit = recordInvalidManageToken(services.db, services.config.sessionSecret, services.now(), ip);
|
||||
if (limit.limited) {
|
||||
c.header('Retry-After', String(limit.retryAfter));
|
||||
return html(c, services.config, 'Please wait · Hope Volunteer', <WaitPage />, 429);
|
||||
return html(c, services, 'Please wait · Hope Volunteer', <WaitPage />, 429);
|
||||
}
|
||||
return html(c, services.config, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
return html(c, services, 'That page is not available · Hope Volunteer', <NotFoundPage />, 404);
|
||||
}
|
||||
|
||||
async function submitCancel(c: Context, services: SignupServices): Promise<Response> {
|
||||
@@ -362,7 +363,7 @@ async function submitSwitch(c: Context, services: SignupServices): Promise<Respo
|
||||
const token = c.req.param('token') ?? '';
|
||||
const signup = readManageSignup(services.db, token, services.now());
|
||||
if (!originAllowed(c, services.config.baseUrl)) {
|
||||
if (!signup) return html(c, services.config, 'Your signup · Hope Volunteer', <SwitchAlreadyPage />, 403);
|
||||
if (!signup) return html(c, services, 'Your signup · Hope Volunteer', <SwitchAlreadyPage />, 403);
|
||||
return showManage(c, services, token, 403, SWITCH_ORIGIN);
|
||||
}
|
||||
const body = await c.req.parseBody();
|
||||
@@ -388,7 +389,7 @@ async function submitSwitch(c: Context, services: SignupServices): Promise<Respo
|
||||
}
|
||||
const result = switchSignup(services.db, signup.signupId, destination, formToken.claims.operationId, services.now(), mailIdentity(services.db, services.config));
|
||||
if (!result.ok) return showManage(c, services, token, 400, result.error);
|
||||
if (!result.manageToken) return html(c, services.config, 'Your signup · Hope Volunteer', <SwitchAlreadyPage />);
|
||||
if (!result.manageToken) return html(c, services, 'Your signup · Hope Volunteer', <SwitchAlreadyPage />);
|
||||
c.header('Cache-Control', 'no-store');
|
||||
return c.redirect(appPath(services.config, `/m/${result.manageToken}?notice=switched`), 303);
|
||||
} catch (err) {
|
||||
@@ -404,7 +405,7 @@ function switchedAlready(c: Context, services: SignupServices, token: string, bo
|
||||
if (!formToken.ok) return missingManage(c, services);
|
||||
const shiftId = confirmedOperationShift(services.db, formToken.claims.operationId);
|
||||
if (shiftId === null) return missingManage(c, services);
|
||||
return html(c, services.config, 'Your signup · Hope Volunteer', <SwitchAlreadyPage />);
|
||||
return html(c, services, 'Your signup · Hope Volunteer', <SwitchAlreadyPage />);
|
||||
}
|
||||
|
||||
function switchForm(services: SignupServices, token: string, signup: { status: 'confirmed' | 'cancelled'; shiftId: number; eventId: number; name: string; email: string }): SwitchForm | null {
|
||||
@@ -471,15 +472,16 @@ function cancelForm(services: SignupServices, token: string, status: 'confirmed'
|
||||
|
||||
function html(
|
||||
c: Context,
|
||||
config: AppConfig,
|
||||
services: SignupServices,
|
||||
title: string,
|
||||
body: Child,
|
||||
status: 200 | 400 | 403 | 404 | 409 | 429 | 503 = 200,
|
||||
turnstile = false,
|
||||
) {
|
||||
c.header('Cache-Control', 'no-store');
|
||||
const account = readSession(services.db, c.req.header('cookie'), services.now());
|
||||
return c.html(
|
||||
<Layout config={config} title={title} path={c.req.path} turnstile={turnstile}>
|
||||
<Layout config={services.config} title={title} path={c.req.path} turnstile={turnstile} account={account ? { csrf: account.csrf } : null}>
|
||||
{body}
|
||||
</Layout>,
|
||||
status,
|
||||
|
||||
Reference in new issue
Block a user