diff --git a/README.md b/README.md index 0ed7487..8c3725f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ The GPX analyser, reborn. A self-hosted web app for analysing GPX tracks and bagging Alpine peaks. - **Accounts** - anyone can sign up; activities and climbed peaks are per user. + The home page is a public community overview: every member's tracks on one + worldmap plus a recent-activity feed. Uploading and peak bagging need an + account. - **Upload** GPX files (drag & drop, multiple at once) - distance, ascent, moving time and an elevation profile are computed on the spot. - **Activities** - every track on a map with stats and an interactive diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 4e97c81..435eb99 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,17 +1,21 @@ import { error, redirect, type Handle } from '@sveltejs/kit'; import { validateSession } from '$lib/server/auth'; -const PUBLIC_PATHS = new Set(['/login', '/signup']); +const AUTH_PATHS = new Set(['/login', '/signup']); + +function isPublic(path: string): boolean { + return path === '/' || AUTH_PATHS.has(path) || /^\/activities\/\d+$/.test(path); +} export const handle: Handle = async ({ event, resolve }) => { event.locals.user = validateSession(event.cookies.get('session')); const path = event.url.pathname; - if (!event.locals.user && !PUBLIC_PATHS.has(path)) { + if (!event.locals.user && !isPublic(path)) { if (path.startsWith('/api/')) error(401, 'Not signed in'); redirect(303, '/login'); } - if (event.locals.user && PUBLIC_PATHS.has(path)) { + if (event.locals.user && AUTH_PATHS.has(path)) { redirect(303, '/'); } diff --git a/src/lib/components/ActivityItem.svelte b/src/lib/components/ActivityItem.svelte index 311219f..9c55b8c 100644 --- a/src/lib/components/ActivityItem.svelte +++ b/src/lib/components/ActivityItem.svelte @@ -13,6 +13,7 @@ moving_s: number | null; duration_s: number | null; elev_gain_m: number; + username?: string; }; } = $props(); @@ -23,6 +24,10 @@ {activity.type}