From 6c10cb628e31b76fea53eeb7fd35c7477801de72 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Fri, 6 Feb 2026 23:54:50 +0000 Subject: [PATCH] Fix linter warnings --- scripts/parse-maps.js | 4 +- src/hooks.server.ts | 32 +- src/lib/components/mapIcons/Bridge.svelte | 43 +- src/lib/components/mapIcons/Junction.svelte | 4 +- src/routes/+page.svelte | 531 +++++++++++--------- src/routes/+page.ts | 24 +- src/routes/map/[slug]/+page.svelte | 187 +++---- static/mapFiles/yaml/0002.yaml | 3 + 8 files changed, 447 insertions(+), 381 deletions(-) diff --git a/scripts/parse-maps.js b/scripts/parse-maps.js index eea8161..31539ee 100644 --- a/scripts/parse-maps.js +++ b/scripts/parse-maps.js @@ -23,11 +23,11 @@ fs.readdirSync(inputDir).forEach((file) => { routeStart: content.routeStart || null, routeEnd: content.routeEnd || null, created: content.created || null, - checked: content.checked || null, + checked: content.checked || null }); } }); fs.writeFileSync(indexFile, JSON.stringify(mapList)); -console.log(`Generated ${mapList.length} map files and index.`) +console.log(`Generated ${mapList.length} map files and index.`); diff --git a/src/hooks.server.ts b/src/hooks.server.ts index d6da546..3d59ff6 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,20 +1,20 @@ -import { type HandleFetch } from "@sveltejs/kit"; +import { type HandleFetch } from '@sveltejs/kit'; export const handleFetch: HandleFetch = async ({ request, fetch }) => { - if (request.url.startsWith('https://maps.owlboard.info')) { - const newUrl = request.url.replace('https://maps.owlboard.info', 'http://localhost:3000'); - - const headers = new Headers(request.headers); - headers.set('host', 'maps.owlboard.info'); + if (request.url.startsWith('https://maps.owlboard.info')) { + const newUrl = request.url.replace('https://maps.owlboard.info', 'http://localhost:3000'); - request = new Request(newUrl, { - method: request.method, - headers: headers, - body: request.body, - // @ts-ignore - 'duplex' is needed for node fetch with bodies - duplex: 'half' - }); - } + const headers = new Headers(request.headers); + headers.set('host', 'maps.owlboard.info'); - return fetch(request); -} \ No newline at end of file + request = new Request(newUrl, { + method: request.method, + headers: headers, + body: request.body, + // @ts-expect-error - 'duplex' is needed for node fetch with bodies + duplex: 'half' + }); + } + + return fetch(request); +}; diff --git a/src/lib/components/mapIcons/Bridge.svelte b/src/lib/components/mapIcons/Bridge.svelte index a20b0ff..fcc3d9e 100644 --- a/src/lib/components/mapIcons/Bridge.svelte +++ b/src/lib/components/mapIcons/Bridge.svelte @@ -4,7 +4,15 @@ export let feature: { position: 'over' | 'under'; - category: 'rail' |'stream'| 'foot' | 'aroad' | 'minorRoad' | 'motorway' | 'waterway' | 'pipeline'; + category: + | 'rail' + | 'stream' + | 'foot' + | 'aroad' + | 'minorRoad' + | 'motorway' + | 'waterway' + | 'pipeline'; roadName?: string; }; export let activeElec: ElecType; @@ -98,11 +106,10 @@ {#if isOver} + + - - - - + {#if s.type === 'road'} {/if} - - - - - + + + + + {:else} - - - + {#if s.type === 'road'} - + - + diff --git a/src/lib/components/mapIcons/Junction.svelte b/src/lib/components/mapIcons/Junction.svelte index ee528f3..b748354 100644 --- a/src/lib/components/mapIcons/Junction.svelte +++ b/src/lib/components/mapIcons/Junction.svelte @@ -18,7 +18,7 @@ }; const getPath = (side: 'left' | 'right') => { - const yStart = visualUp ? 64 : 0; + const yStart = visualUp ? 64 : 8; const yEnd = visualUp ? 8 : 56; const xEnd = side === 'right' ? 56 : 8; return `M 32 ${yStart} Q 32 32 ${xEnd} ${yEnd}`; @@ -34,7 +34,7 @@ - {#each paths as d} + {#each paths as d (d)} {/each} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 3a3af60..16ef995 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,283 +1,332 @@ \ No newline at end of file + .card-body { + display: flex; + align-items: center; + } + } + + .external-card { + border-left: 4px solid #6366f1; + background: linear-gradient(to right, #ffffff, #f5f3ff); + } + + .system-tag { + background: #eef2ff !important; + color: #4338ca !important; + } + + .status-badge.external { + background: #6366f1; + color: white; + } + + .description { + margin: 0.25rem 0 0 0; + font-size: 0.9rem; + color: #64748b; + font-weight: 500; + } + + .external-card:hover { + border-color: #4338ca; + background: #f5f3ff; + } + diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 2816f68..c86edd5 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -1,17 +1,17 @@ -import type { PageLoad } from "./$types"; +import type { PageLoad } from './$types'; export const load: PageLoad = async ({ fetch }) => { - const response = await fetch('map-index.json'); + const response = await fetch('map-index.json'); - if (!response.ok) { - return { maps: [] }; - } + if (!response.ok) { + return { maps: [] }; + } - const maps = await response.json(); + const maps = await response.json(); - return { - maps: maps.sort((a: any, b: any) => { - return Number(a.routeId) - Number(b.routeId); - }) - }; -}; \ No newline at end of file + return { + maps: maps.sort((a: any, b: any) => { + return Number(a.routeId) - Number(b.routeId); + }) + }; +}; diff --git a/src/routes/map/[slug]/+page.svelte b/src/routes/map/[slug]/+page.svelte index c2dc869..7534de4 100644 --- a/src/routes/map/[slug]/+page.svelte +++ b/src/routes/map/[slug]/+page.svelte @@ -2,6 +2,7 @@ import RouteRow from '$lib/components/RouteRow.svelte'; import RouteEndLink from '$lib/components/mapIcons/RouteEndLink.svelte'; import { slide } from 'svelte/transition'; + import { base } from '$app/paths'; // data.route contains: routeStart, routeEnd, routeId, elecStart, elecEnd, routeDetail[] export let data; @@ -58,31 +59,31 @@
-
- +
+
+
+ {#if data?.route} +

+ {reversed ? data.route.routeEnd : data.route.routeStart} +

+ + to {reversed ? data.route.routeStart : data.route.routeEnd} + + {/if} +
+
+ +
+ + +
+ {#if showFilters}
(showFilters = false)}>
@@ -106,7 +107,7 @@
- {#each Object.keys(visibleTypes) as type} + {#each Object.keys(visibleTypes) as type (type)}