Feature fixes: admin nav, hero event, schedule block, SEO, site settings, Google sign-in, QR tool #12
6 changed files with 55 additions and 56 deletions
|
|
@ -57,7 +57,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
|
|||
- `navConfig.ts` is the single source of truth for navigation, routes, and actions (header, footer, pages).
|
||||
- `api.ts` is the shared caching client used by frontend data hooks.
|
||||
- `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content.
|
||||
- Logos: org logos in `public/org-logos/` (served at `/org-logos/`); event logos are uploads (`/uploads/`, a bare filename resolves there). The site's own NGU logos are bundled from `src/assets/logos/`. Image paths resolve through `src/lib/media.ts`. The `<Logo>` component hides itself on load error.
|
||||
- Images: every record image (logos, photos, backgrounds, block images) is an upload. A bare filename resolves to `/uploads/<file>` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. The `<Logo>` component hides itself on load error.
|
||||
|
||||
## Rules and gotchas
|
||||
- **Role checks must use ladder comparisons, never equality.** Roles rank viewer → editor → admin → superadmin. Use the minimum-rank helpers from `src/lib/roles.ts` (`canWrite`, `canDelete`, `isSuper`, `atLeast`). Where a local variable shadows the name, import with an alias, e.g. `canWrite as roleCanWrite`. `role === "admin"` silently excludes higher roles and has caused repeated bugs.
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
/admin noindex
|
||||
|
||||
Image paths resolve like src/lib/media.ts does: a bare filename
|
||||
lives in that record kind's public/ directory, anything starting
|
||||
with / or a scheme is used as it is. Keep DIRS in step with it.
|
||||
is in the uploads directory, anything starting with / or a scheme
|
||||
is used as it is.
|
||||
An SVG isn't used as a preview image (the big sites won't show
|
||||
one), so it falls back to the site default.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
|
@ -45,16 +45,9 @@ export const SITE_CONFIG = path.resolve(process.env.SITE_CONFIG ?? path.join(her
|
|||
|
||||
const DESCRIPTION_CHARS = 160;
|
||||
|
||||
/* Where a bare filename lives, per kind. Mirrors src/lib/media.ts. */
|
||||
const DIRS = {
|
||||
person: "/people",
|
||||
eventLogo: "/uploads",
|
||||
eventBackground: "/event-backgrounds",
|
||||
organization: "/org-logos",
|
||||
team: "/team-logos",
|
||||
award: "/award-logos",
|
||||
blog: "/blog",
|
||||
};
|
||||
/* Where a bare filename lives: record images are uploads, whatever
|
||||
kind they are. Mirrors src/lib/media.ts. */
|
||||
const UPLOADS = "/uploads";
|
||||
|
||||
/* ── site.json, reread when it changes ─────────────────────── */
|
||||
|
||||
|
|
@ -94,9 +87,9 @@ const first = (...values) => values.find((v) => v != null && String(v).trim() !=
|
|||
|
||||
function imageUrl(site, file, kind) {
|
||||
if (!file || /\.svg(\?|#|$)/i.test(file)) return null;
|
||||
// A bare filename is in that kind's directory, or at the site's
|
||||
// root for the site's own default (kind null).
|
||||
const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${DIRS[kind]}/${file}` : `/${file}`;
|
||||
// A record's bare filename is an upload; the site's own default
|
||||
// image (kind null) is a path from the site's root.
|
||||
const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${UPLOADS}/${file}` : `/${file}`;
|
||||
return /^https?:/.test(pathOrUrl) ? pathOrUrl : `${origin(site)}${pathOrUrl}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1305,7 +1305,7 @@ const frontPage = {
|
|||
full: true,
|
||||
help:
|
||||
"A YouTube, Vimeo or Facebook link, or a video file: a filename in " +
|
||||
"/front-page/ or a link ending in .mp4 or .webm",
|
||||
"the uploads folder, or a link ending in .mp4 or .webm",
|
||||
},
|
||||
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
so the visitor presses play.
|
||||
|
||||
A featured video can also be a file rather than a link: a
|
||||
filename in public/front-page/, a /path, or an https URL ending
|
||||
filename in the uploads directory, a /path, or an https URL ending
|
||||
in a video extension. videoSource() says which, so the hero can
|
||||
hand a file to <video> and a link to an <iframe>.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
|
|
|||
|
|
@ -1,18 +1,25 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
MEDIA PATHS
|
||||
|
||||
Every image field in the API is a bare filename — "where the
|
||||
images live is the component's business", as history.js puts it.
|
||||
This is that business, in one file, so moving a directory is one
|
||||
edit rather than a grep.
|
||||
Every image field in the API is a filename or a path, and where a
|
||||
bare filename lives is decided here, in one file.
|
||||
|
||||
⚠ Only two of these directories are confirmed by the admin help
|
||||
text: people/. Event logos are uploads. The other three are a guess at
|
||||
your convention. Check public/ and fix them here — nothing else
|
||||
references the paths.
|
||||
One rule: record images are uploads. A value from the media
|
||||
library is already '/uploads/<file>'; a bare filename is a file
|
||||
copied into the uploads directory by hand (fall-retreat-logo.svg
|
||||
was), so it resolves to /uploads/<file> too. That covers logos,
|
||||
photos, backgrounds, hero slides, block images: everything an
|
||||
editor picks.
|
||||
|
||||
The site's own chosen assets (the NGU logos in the nav, footer
|
||||
and admin) are the exception: they're bundled from
|
||||
src/assets/logos and imported where they're used, not resolved
|
||||
here.
|
||||
|
||||
A value that already looks like a path or a URL is returned
|
||||
untouched, so a hand-written entry can point anywhere.
|
||||
server/src/pageMeta.js resolves images for link previews by the
|
||||
same rule; keep the two in step.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
const ABSOLUTE = /^(https?:|\/|data:)/
|
||||
|
|
@ -29,43 +36,42 @@ function inDir(dir: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export const personPhoto = inDir('/people') // confirmed
|
||||
// Event logos are uploads. A bare filename is one copied into the
|
||||
// uploads directory by hand (fall-retreat-logo.svg was); anything
|
||||
// uploaded through the admin is already /uploads/…
|
||||
export const eventLogo = inDir('/uploads')
|
||||
export const eventBackground = inDir('/event-backgrounds')
|
||||
export const orgLogo = inDir('/org-logos') // ⚠ guess
|
||||
export const teamLogo = inDir('/team-logos') // ⚠ guess
|
||||
export const awardLogo = inDir('/award-logos') // ⚠ guess
|
||||
export const UPLOADS = '/uploads'
|
||||
|
||||
/* front_page_slides.media — the home page hero's photos. New with
|
||||
the Front page editor, which names the directory in its help. */
|
||||
export const heroPhoto = inDir('/front-page')
|
||||
const inUploads = inDir(UPLOADS)
|
||||
|
||||
/* front_page.video_url when it names a file rather than a link:
|
||||
same directory as the photos. */
|
||||
export const heroVideo = inDir('/front-page')
|
||||
/* One helper per field, all the same rule, so a caller says what the
|
||||
image is and a future exception is one line here. */
|
||||
export const personPhoto = inUploads
|
||||
export const eventLogo = inUploads
|
||||
export const eventBackground = inUploads
|
||||
export const orgLogo = inUploads
|
||||
export const teamLogo = inUploads
|
||||
export const awardLogo = inUploads
|
||||
|
||||
/* content_blocks.media, which can be an image on any owner's page,
|
||||
so it can't share a per-entity directory. */
|
||||
export const blockMedia = inDir('/media') // ⚠ guess
|
||||
/* front_page_slides.media, the hero's photos. */
|
||||
export const heroPhoto = inUploads
|
||||
|
||||
/* featured_cards.image, a card's own picture. Normally an upload
|
||||
('/uploads/…'); a bare filename looks here. */
|
||||
export const featuredImage = inDir('/featured')
|
||||
/* front_page.video_url when it names a file rather than a link.
|
||||
Videos can't be uploaded through the media library, so a file is
|
||||
one copied into the uploads directory by hand. */
|
||||
export const heroVideo = inUploads
|
||||
|
||||
/* blog_posts.cover_image and guest_photo. Normally uploads. */
|
||||
export const blogImage = inDir('/blog')
|
||||
/* content_blocks.media and content_block_items.media. */
|
||||
export const blockMedia = inUploads
|
||||
|
||||
/* featured_cards.image. */
|
||||
export const featuredImage = inUploads
|
||||
|
||||
/* blog_posts.cover_image and guest_photo. */
|
||||
export const blogImage = inUploads
|
||||
|
||||
/* ── By record kind ────────────────────────────────────────────
|
||||
The timeline sends `logo: { file, kind }` rather than a path,
|
||||
because v_timeline COALESCEs across five tables and only the
|
||||
ref_kind says which one the filename came from.
|
||||
|
||||
⚠ Three of these directories are the guesses above. Your current
|
||||
timelineRefs.ts already has the real ones — timeline logos render
|
||||
today — so copy them into the map above and delete this note.
|
||||
ref_kind says which one the filename came from. Featured cards
|
||||
send the same shape. Every kind resolves to the uploads directory
|
||||
today; the map is what lets one kind differ later.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
const BY_KIND: Record<string, (file?: string | null) => string | null> = {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } fro
|
|||
const DEFAULT_ORG_LOGO = null;
|
||||
|
||||
/* An <img> that removes itself if the file 404s. `src` is already
|
||||
resolved by media.ts: an event logo from the uploads directory, an
|
||||
organization's from org-logos, anything with a path or URL as is. */
|
||||
resolved by media.ts: a bare filename from the uploads directory,
|
||||
anything with a path or URL as it is. */
|
||||
function Logo({ src, alt = "", className }) {
|
||||
const [failed, setFailed] = useState(false);
|
||||
if (!src || failed) return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue