From 6d77075e219530694d92c22d104e2a84ff29ac68 Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Thu, 4 Jun 2026 10:03:08 +1200 Subject: [PATCH] Add config option to control the map provider link --- README.md | 3 ++- app/config.json | 3 ++- app/src/client/sidebar.ts | 22 ++++++++++++---------- app/src/client/state.ts | 3 ++- app/src/gallery/builder.ts | 4 +++- app/src/shared/types.ts | 1 + 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fe249e5..f97f28b 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,8 @@ Under `ipp.showMetadata.location`: | `city` | `bool` | Show city. | | `state` | `bool` | Show state / region. | | `country` | `bool` | Show country. | -| `gps` | `bool` | Show GPS coordinates and an "Open in OpenStreetMap" link. | +| `gps` | `bool` | Show GPS coordinates. | +| `webLink` | `bool` | Show an "Open in OpenStreetMap" link below the coordinates. The link is rendered with `rel="noreferrer"` so the share URL is not leaked to the map provider when a viewer clicks it. Has no effect unless `gps` is also true. Default `true`. | Example: show description in the sidebar only (not as a caption), show full EXIF, and hide GPS coordinates while keeping city / state / country: diff --git a/app/config.json b/app/config.json index e5fda64..01bf555 100644 --- a/app/config.json +++ b/app/config.json @@ -34,7 +34,8 @@ "city": true, "state": true, "country": true, - "gps": true + "gps": true, + "webLink": true } }, "customInvalidResponse": false, diff --git a/app/src/client/sidebar.ts b/app/src/client/sidebar.ts index 5c1808e..c6d487e 100644 --- a/app/src/client/sidebar.ts +++ b/app/src/client/sidebar.ts @@ -298,16 +298,18 @@ function renderLocation (exif: GalleryExif): HTMLElement { coords.textContent = exif.latitude.toFixed(5) + ', ' + exif.longitude.toFixed(5) body.appendChild(coords) - const link = document.createElement('a') - link.className = 'ipp-sidebar-osm' - link.href = 'https://www.openstreetmap.org/?mlat=' + exif.latitude + - '&mlon=' + exif.longitude + - '#map=15/' + exif.latitude + '/' + exif.longitude - link.target = '_blank' - // noreferrer suppresses the Referer header so the share URL doesn't end up in OSM's webserver logs - link.rel = 'noopener noreferrer' - link.textContent = 'Open in OpenStreetMap' - body.appendChild(link) + if (state.metadataConfig.locationWebLink) { + const link = document.createElement('a') + link.className = 'ipp-sidebar-osm' + link.href = 'https://www.openstreetmap.org/?mlat=' + exif.latitude + + '&mlon=' + exif.longitude + + '#map=15/' + exif.latitude + '/' + exif.longitude + link.target = '_blank' + // noreferrer suppresses the Referer header so the share URL doesn't end up in the map provider's webserver logs + link.rel = 'noopener noreferrer' + link.textContent = 'Open in OpenStreetMap' + body.appendChild(link) + } } wrap.appendChild(body) diff --git a/app/src/client/state.ts b/app/src/client/state.ts index 871144a..c54911f 100644 --- a/app/src/client/state.ts +++ b/app/src/client/state.ts @@ -82,7 +82,8 @@ export const state = { metadataConfig: { descriptionInCaption: false, descriptionInSidebar: false, - sidebarHasContent: false + sidebarHasContent: false, + locationWebLink: false } as MetadataConfig, // True while our pushed history entry is live lightboxPushedHistory: false, diff --git a/app/src/gallery/builder.ts b/app/src/gallery/builder.ts index 860aaa0..f4a8bef 100644 --- a/app/src/gallery/builder.ts +++ b/app/src/gallery/builder.ts @@ -41,6 +41,7 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb const descriptionInSidebar = !!getConfigOption('ipp.showMetadata.description.sidebar', false) const exifGroupEnabled = !!getConfigOption('ipp.showMetadata.exif.enabled', false) const locationGroupEnabled = !!getConfigOption('ipp.showMetadata.location.enabled', false) + const locationWebLink = locationGroupEnabled && !!getConfigOption('ipp.showMetadata.location.webLink', true) const sidebarHasContent = descriptionInSidebar || exifGroupEnabled || locationGroupEnabled // Build structured items in parallel @@ -134,7 +135,8 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb metadataConfig: { descriptionInCaption, descriptionInSidebar, - sidebarHasContent + sidebarHasContent, + locationWebLink }, groupByDate } diff --git a/app/src/shared/types.ts b/app/src/shared/types.ts index d57c8ed..e88bd4b 100644 --- a/app/src/shared/types.ts +++ b/app/src/shared/types.ts @@ -73,6 +73,7 @@ export interface MetadataConfig { descriptionInCaption: boolean descriptionInSidebar: boolean sidebarHasContent: boolean + locationWebLink: boolean } /**