From b6dfa76c894233d61ada73de5b59901797e3b268 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Mon, 9 Apr 2018 11:09:31 +0200 Subject: [PATCH] detail page: add permalink, equivalent to https://github.com/openstreetmap/Nominatim/pull/1003 --- src/assets/css/details.css | 6 ++++++ src/handlebar_helpers.js | 17 ++++++++++++++--- src/templates/detailspage.hbs | 4 ++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/assets/css/details.css b/src/assets/css/details.css index 5f6bef6..903ebff 100755 --- a/src/assets/css/details.css +++ b/src/assets/css/details.css @@ -2,6 +2,12 @@ margin: 10px 0; padding-left: 8px; } + +#details-page h1 small a { + font-size: 0.5em; + white-space: nowrap; +} + #details-page h2 { font-size: 2em; padding-left: 8px; diff --git a/src/handlebar_helpers.js b/src/handlebar_helpers.js index 8970578..b40b11a 100644 --- a/src/handlebar_helpers.js +++ b/src/handlebar_helpers.js @@ -47,11 +47,22 @@ Handlebars.registerHelper({ if (!aFeature) return ''; if (!aFeature.place_id) return ''; - sTitle = 'details >'; - var sTitle = Handlebars.escapeExpression(sTitle); + sTitle = Handlebars.escapeExpression(sTitle || 'details >'); return new Handlebars.SafeString( - '' + (sTitle ? sTitle : aFeature.place_id ) + '' + '' + sTitle + '' + ); + }, + detailsPermaLink: function(aFeature, sTitle) { + if (!aFeature) return ''; + + var sOSMType = formatOSMType(aFeature.osm_type, false); + if (!sOSMType) return ''; + + sTitle = Handlebars.escapeExpression(sTitle || sOSMType + ' ' + aFeature.osm_id); + + return new Handlebars.SafeString( + '' + sTitle + '' ); }, coverageType: function(aPlace) { diff --git a/src/templates/detailspage.hbs b/src/templates/detailspage.hbs index a725cd5..8328f1c 100644 --- a/src/templates/detailspage.hbs +++ b/src/templates/detailspage.hbs @@ -13,7 +13,7 @@ {{this.rank_address}} {{formatAdminLevel this.admin_level}} {{formatDistance this.distance}} - {{detailsLink this}} + {{detailsLink this null}} {{/inline}} @@ -38,7 +38,7 @@
-

{{aPlace.localname}}

+

{{aPlace.localname}} {{detailsPermaLink aPlace 'link to this page'}}

{{formatMapIcon aPlace.icon}} -- 2.39.5