mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-07 03:41:33 +00:00
Merge pull request #8483 from openstreetmap/oci-v4
osm-community-index v4
This commit is contained in:
2
dist/locales/en.min.json
vendored
2
dist/locales/en.min.json
vendored
File diff suppressed because one or more lines are too long
@@ -21,8 +21,9 @@ export function coreFileFetcher() {
|
||||
'locales': 'locales/index.min.json',
|
||||
'nsi_brands': 'https://cdn.jsdelivr.net/npm/name-suggestion-index@4/dist/brands.min.json',
|
||||
'nsi_filters': 'https://cdn.jsdelivr.net/npm/name-suggestion-index@4/dist/filters.min.json',
|
||||
'oci_features': 'https://cdn.jsdelivr.net/npm/osm-community-index@3/dist/featureCollection.min.json',
|
||||
'oci_resources': 'https://cdn.jsdelivr.net/npm/osm-community-index@3/dist/resources.min.json',
|
||||
'oci_defaults': 'https://cdn.jsdelivr.net/npm/osm-community-index@4/dist/defaults.min.json',
|
||||
'oci_features': 'https://cdn.jsdelivr.net/npm/osm-community-index@4/dist/featureCollection.min.json',
|
||||
'oci_resources': 'https://cdn.jsdelivr.net/npm/osm-community-index@4/dist/resources.min.json',
|
||||
'preset_categories': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_categories.min.json',
|
||||
'preset_defaults': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_defaults.min.json',
|
||||
'preset_fields': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/fields.min.json',
|
||||
|
||||
@@ -3,6 +3,7 @@ import { select as d3_select } from 'd3-selection';
|
||||
|
||||
import LocationConflation from '@ideditor/location-conflation';
|
||||
import whichPolygon from 'which-polygon';
|
||||
import { resolveStrings } from 'osm-community-index';
|
||||
|
||||
import { fileFetcher } from '../core/file_fetcher';
|
||||
import { t, localizer } from '../core/localizer';
|
||||
@@ -23,7 +24,11 @@ export function uiSuccess(context) {
|
||||
|
||||
function ensureOSMCommunityIndex() {
|
||||
const data = fileFetcher;
|
||||
return Promise.all([ data.get('oci_resources'), data.get('oci_features') ])
|
||||
return Promise.all([
|
||||
data.get('oci_resources'),
|
||||
data.get('oci_features'),
|
||||
data.get('oci_defaults')
|
||||
])
|
||||
.then(vals => {
|
||||
if (_oci) return _oci;
|
||||
|
||||
@@ -49,6 +54,7 @@ export function uiSuccess(context) {
|
||||
});
|
||||
|
||||
return _oci = {
|
||||
defaults: vals[2].defaults,
|
||||
features: ociFeatures,
|
||||
resources: ociResources,
|
||||
query: whichPolygon({ type: 'FeatureCollection', features: Object.values(ociFeatures) })
|
||||
@@ -163,7 +169,12 @@ export function uiSuccess(context) {
|
||||
properties.forEach(props => {
|
||||
const resourceIDs = Array.from(props.resourceIDs);
|
||||
resourceIDs.forEach(resourceID => {
|
||||
const resource = oci.resources[resourceID];
|
||||
let resource = oci.resources[resourceID];
|
||||
|
||||
// Resolve strings
|
||||
const localizer = (stringID) => t.html(`community.${stringID}`);
|
||||
resource.resolved = resolveStrings(resource, oci.defaults, localizer);
|
||||
|
||||
communities.push({
|
||||
area: props.area || Infinity,
|
||||
order: resource.order || 0,
|
||||
@@ -206,7 +217,7 @@ export function uiSuccess(context) {
|
||||
.attr('class', 'cell-icon community-icon')
|
||||
.append('a')
|
||||
.attr('target', '_blank')
|
||||
.attr('href', d => d.url)
|
||||
.attr('href', d => d.resolved.url)
|
||||
.append('svg')
|
||||
.attr('class', 'logo-small')
|
||||
.append('use')
|
||||
@@ -236,32 +247,19 @@ export function uiSuccess(context) {
|
||||
function showCommunityDetails(d) {
|
||||
let selection = d3_select(this);
|
||||
let communityID = d.id;
|
||||
let replacements = {
|
||||
url: linkify(d.url),
|
||||
signupUrl: linkify(d.signupUrl || d.url)
|
||||
};
|
||||
|
||||
selection
|
||||
.append('div')
|
||||
.attr('class', 'community-name')
|
||||
.append('a')
|
||||
.attr('target', '_blank')
|
||||
.attr('href', d.url)
|
||||
.html(t.html(`community.${d.id}.name`));
|
||||
|
||||
let descriptionHTML = t.html(`community.${d.id}.description`, replacements);
|
||||
|
||||
if (d.type === 'reddit') { // linkify subreddits #4997
|
||||
descriptionHTML = descriptionHTML
|
||||
.replace(/(\/r\/\w*\/*)/i, match => linkify(d.url, match));
|
||||
}
|
||||
.html(d.resolved.nameHTML);
|
||||
|
||||
selection
|
||||
.append('div')
|
||||
.attr('class', 'community-description')
|
||||
.html(descriptionHTML);
|
||||
.html(d.resolved.descriptionHTML);
|
||||
|
||||
if (d.extendedDescription || (d.languageCodes && d.languageCodes.length)) {
|
||||
// Create an expanding section if any of these are present..
|
||||
if (d.resolved.extendedDescriptionHTML || (d.languageCodes && d.languageCodes.length)) {
|
||||
selection
|
||||
.append('div')
|
||||
.call(uiDisclosure(context, `community-more-${d.id}`, false)
|
||||
@@ -311,11 +309,11 @@ export function uiSuccess(context) {
|
||||
.append('div')
|
||||
.attr('class', 'community-more');
|
||||
|
||||
if (d.extendedDescription) {
|
||||
if (d.resolved.extendedDescriptionHTML) {
|
||||
moreEnter
|
||||
.append('div')
|
||||
.attr('class', 'community-extended-description')
|
||||
.html(t.html(`community.${d.id}.extendedDescription`, replacements));
|
||||
.html(d.resolved.extendedDescriptionHTML);
|
||||
}
|
||||
|
||||
if (d.languageCodes && d.languageCodes.length) {
|
||||
@@ -391,12 +389,6 @@ export function uiSuccess(context) {
|
||||
return description;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function linkify(url, text) {
|
||||
text = text || url;
|
||||
return `<a target="_blank" href="${url}">${text}</a>`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"translations": "node scripts/update_locales.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ideditor/country-coder": "^4.0.0",
|
||||
"@ideditor/location-conflation": "~0.7.0",
|
||||
"@ideditor/country-coder": "^4.1.0",
|
||||
"@ideditor/location-conflation": "~0.9.0",
|
||||
"@mapbox/geojson-rewind": "^0.5.0",
|
||||
"@mapbox/sexagesimal": "1.2.0",
|
||||
"@mapbox/togeojson": "0.16.0",
|
||||
@@ -94,8 +94,8 @@
|
||||
"happen": "^0.3.1",
|
||||
"js-yaml": "^4.0.0",
|
||||
"json-stringify-pretty-compact": "^3.0.0",
|
||||
"mapillary-js": "~3.1.0",
|
||||
"mapillary_sprite_source": "^1.8.0",
|
||||
"mapillary-js": "~3.1.0",
|
||||
"minimist": "^1.2.3",
|
||||
"mocha": "^7.0.1",
|
||||
"mocha-phantomjs-core": "^2.1.0",
|
||||
@@ -103,7 +103,7 @@
|
||||
"node-fetch": "^2.6.1",
|
||||
"npm-run-all": "^4.0.0",
|
||||
"object-inspect": "1.9.0",
|
||||
"osm-community-index": "3.1.1",
|
||||
"osm-community-index": "~4.0.2",
|
||||
"phantomjs-prebuilt": "~2.1.16",
|
||||
"postcss": "^8.1.1",
|
||||
"postcss-selector-prepend": "^0.5.0",
|
||||
|
||||
Reference in New Issue
Block a user