mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
places: a description the community shared is credited to the TREK community
A community description laid over OSM details or an index row showed up as OpenStreetMap under ODbL, or as the place's own website. It now has a source of its own, community, credited as TREK Community under CC BY 4.0, like the service publishes it.
This commit is contained in:
@@ -36,7 +36,11 @@ export function withCommunityValues(
|
||||
out.opening_periods = hours.opening_periods;
|
||||
}
|
||||
}
|
||||
if (values.description?.text) out.summary = values.description.text;
|
||||
if (values.description?.text) {
|
||||
out.summary = values.description.text;
|
||||
// The details panel credits it to the community, not to OpenStreetMap.
|
||||
out.summary_source = 'community';
|
||||
}
|
||||
if (typeof values.community.version === 'number') out.community_version = values.community.version;
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -705,10 +705,14 @@ export class PlaceEnrichmentService {
|
||||
if (!this.maps.trekPlacesEnabled()) return null;
|
||||
try {
|
||||
const got = (
|
||||
(await trekPlacesById(placeId.slice(5))) as { description?: { text?: string; sourceUrl?: string } } | null
|
||||
(await trekPlacesById(placeId.slice(5))) as {
|
||||
description?: { text?: string; sourceUrl?: string; source?: string };
|
||||
} | null
|
||||
)?.description;
|
||||
const text = typeof got?.text === 'string' ? got.text.trim() : '';
|
||||
if (!text) return null;
|
||||
// A description installations shared and review published, laid over the index row.
|
||||
if (got?.source === 'community') return { text, source: 'community', sourceUrl: null, license: 'CC BY 4.0' };
|
||||
// Through the same allow-list a place's website goes through: this
|
||||
// becomes an href on the client, and the value comes from whatever the
|
||||
// configured index answered with. Anything but http(s) loses the link and
|
||||
@@ -739,6 +743,9 @@ export class PlaceEnrichmentService {
|
||||
// OpenStreetMap first: it costs nothing, it is already fetched, and a
|
||||
// description someone wrote into the map data beats a generated blurb.
|
||||
const osmSummary = typeof details?.summary === 'string' ? details.summary.trim() : '';
|
||||
if (osmSummary && details?.summary_source === 'community') {
|
||||
return { text: osmSummary, source: 'community', sourceUrl: null, license: 'CC BY 4.0' };
|
||||
}
|
||||
if (osmSummary && details?.source === 'openstreetmap') {
|
||||
return {
|
||||
text: osmSummary,
|
||||
|
||||
Reference in New Issue
Block a user