From 690ef33a0067226e30a2d549fc91e4cd93d09bdf Mon Sep 17 00:00:00 2001 From: Robin van der Linde Date: Wed, 13 Nov 2024 19:55:11 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20icons=20for=20StreetComplete?= =?UTF-8?q?=20Overlays=20(hard-coded)=20(#296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/api/getStreetCompleteDetails.ts | 43 ++++++++++++++++++++++ src/routes/[lang]/projects/+page.server.ts | 1 + 2 files changed, 44 insertions(+) diff --git a/src/lib/api/getStreetCompleteDetails.ts b/src/lib/api/getStreetCompleteDetails.ts index 19298d2..74deb70 100644 --- a/src/lib/api/getStreetCompleteDetails.ts +++ b/src/lib/api/getStreetCompleteDetails.ts @@ -110,6 +110,12 @@ export async function updateStreetCompleteCache() { * @returns {Promise} A icon url */ export async function getStreetCompleteImage(quest: string): Promise { + // Check if the quest name ends in Overlay, if so use the overlay function + // Currently these are not included in the quest list, so we have our own function for this + if (quest.endsWith('Overlay')) { + return getStreetCompleteOverlayImage(quest); + } + return ( await prisma.streetCompleteQuest.findFirst({ where: { @@ -118,3 +124,40 @@ export async function getStreetCompleteImage(quest: string): Promise} A icon url + */ +export async function getStreetCompleteOverlayImage(overlay: string): Promise { + // Currently these are not included in the quest list, so we have our own mapping for some of them + const overlayMapping = { + WayLitOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/lantern.svg', + SurfaceOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/street_surface.svg', + SidewalkOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/sidewalk.svg', + CyclewayOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/bicycleway.svg', + StreetParkingOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/parking_lane.svg', + AddressOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/housenumber.svg', + PlacesOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/shop.svg', + ThingsOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/dot.svg', + BuildingsOverlay: + 'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/building.svg' + }; + + // Check if the overlay is in the mapping + if (overlay in overlayMapping) { + return Promise.resolve(overlayMapping[overlay]); + } + + // If not return null + return Promise.resolve(null); +} diff --git a/src/routes/[lang]/projects/+page.server.ts b/src/routes/[lang]/projects/+page.server.ts index 34cb44c..c41056c 100644 --- a/src/routes/[lang]/projects/+page.server.ts +++ b/src/routes/[lang]/projects/+page.server.ts @@ -73,6 +73,7 @@ export const load: PageServerLoad<{ repos: GithubRepo[] }> = async () => { if (response.status != 200) { console.log(`[projects/+page.server.ts]: Status: ${response.status}`); + console.debug(`[projects/+page.server.ts]: Response: ${await response.text()}`); throw 'Faulty response'; }