Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-11002: News near you #823

Merged
merged 7 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
uuid: dc0590fe-78b1-402d-b0c7-686c8f32d3e5
langcode: en
status: true
dependencies:
config:
- field.field.taxonomy_term.news_neighbourhoods.field_location
- taxonomy.vocabulary.news_neighbourhoods
module:
- helfi_platform_config
- path
- text
id: taxonomy_term.news_neighbourhoods.default
targetEntityType: taxonomy_term
bundle: news_neighbourhoods
mode: default
content:
description:
type: text_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_location:
type: location
weight: 101
region: content
settings: { }
third_party_settings: { }
langcode:
type: language_select
weight: 2
region: content
settings:
include_locked: true
third_party_settings: { }
name:
type: string_textfield
weight: -5
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
path:
type: path
weight: 30
region: content
settings: { }
third_party_settings: { }
status:
type: boolean_checkbox
weight: 100
region: content
settings:
display_label: true
third_party_settings: { }
translation:
weight: 10
region: content
settings: { }
third_party_settings: { }
hidden: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
uuid: 96825838-b49d-4139-8bf9-24ba7d31b5ac
langcode: en
status: true
dependencies:
config:
- field.field.taxonomy_term.news_neighbourhoods.field_location
- taxonomy.vocabulary.news_neighbourhoods
module:
- text
id: taxonomy_term.news_neighbourhoods.default
targetEntityType: taxonomy_term
bundle: news_neighbourhoods
mode: default
content:
description:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 0
region: content
hidden:
field_location: true
langcode: true
search_api_excerpt: true
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ langcode: en
status: true
dependencies: { }
_core:
default_config_hash: 5s8g-adBsUuIIMte5BCEwSFlQjxwFJ_Gq2Do7EEwq2E
default_config_hash: 09-lIa9cl9PNPVIBXCVIR8yBfofPifSwhAsD0QVh8l8
id: helfi_news_neighbourhoods
label: 'Helfi: News neighbourhoods'
label_plural: 'Helfi: News neighbourhoods'
description: 'Retrieves news neighbourhoods taxonomy terms from Helfi'
read_only: true
generate_aliases: null
read_only: true
field_mapper_id: jsonpath
field_mapper_config:
field_mappings:
Expand All @@ -21,6 +21,8 @@ field_mapper_config:
value: '$._source.name[0]'
tid:
value: '$._source.tid[0]'
location:
value: $._source.field_location
storage_client_id: helfi_news_neighbourhoods
storage_client_config: { }
persistent_cache_max_age: 86400
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
uuid: 77736144-e2d4-4f43-9bf4-d6a5700454e9
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_location
- taxonomy.vocabulary.news_neighbourhoods
module:
- helfi_platform_config
_core:
default_config_hash: zMqD_YIcxb2SEi-zEfioqQpiVagAuP6dpQnuKTmr4LU
id: taxonomy_term.news_neighbourhoods.field_location
field_name: field_location
entity_type: taxonomy_term
bundle: news_neighbourhoods
label: Location
description: 'Neighbourhood location. Used to search nearby content.'
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: location
21 changes: 21 additions & 0 deletions conf/cmi/field.storage.taxonomy_term.field_location.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uuid: 44d5b217-5ef0-4178-8a1a-6190babb12e2
langcode: en
status: true
dependencies:
module:
- helfi_platform_config
- taxonomy
_core:
default_config_hash: J3VYlUUqe9orySkqRTkfaf3zmiABVwpRFgS2Wk-qykg
id: taxonomy_term.field_location
field_name: field_location
entity_type: taxonomy_term
type: location
settings: { }
module: helfi_platform_config
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: Sijainti
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: Plats
9 changes: 9 additions & 0 deletions conf/cmi/search_api.index.news_terms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_location
- search_api.server.default
module:
- helfi_etusivu
Expand Down Expand Up @@ -81,6 +82,14 @@ field_settings:
dependencies:
module:
- taxonomy
field_location:
label: Location
datasource_id: 'entity:taxonomy_term'
property_path: field_location
type: location
dependencies:
config:
- field.storage.taxonomy_term.field_location
datasource_settings:
'entity:taxonomy_term':
bundles:
Expand Down
108 changes: 108 additions & 0 deletions public/modules/custom/helfi_etusivu/helfi_etusivu.deploy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

/**
* @file
* Contains etusivu deploy hooks.
*/

declare(strict_types=1);

/**
* UHF-9741: Set location for neighbourhoods.
*/
function helfi_etusivu_deploy_0001_news_neighbourhoods() : void {
$neighbourhoods = [
'Alppiharju' => [60.187933, 24.944132],
'Eira' => [60.155249, 24.938121],
'Etu-Töölö' => [60.173279, 24.923774],
'Haaga' => [60.221837, 24.896392],
'Hakaniemi' => [60.180465, 24.951613],
'Hermanni' => [60.195101, 24.966697],
'Hernesaari' => [60.149268, 24.924342],
'Herttoniemi' => [60.193202, 25.036063],
'Honkasuo' => [60.256156, 24.845279],
'Itäkeskus ja Vartiokylä' => [60.214989, 25.089473],
'Jätkäsaari' => [60.156744, 24.913439],
'Kaarela' => [60.251193, 24.881449],
'Kaartinkaupunki' => [60.165227, 24.948996],
'Kaivopuisto' => [60.155933, 24.955835],
'Kalasatama' => [60.185294, 24.980741],
'Kallio' => [60.184327, 24.949712],
'Kamppi' => [60.167335, 24.931190],
'Kannelmäki' => [60.241693, 24.885368],
'Karhusaari' => [60.250323, 25.220108],
'Katajanokka' => [60.166662, 24.969216],
'Keskusta' => [60.169519, 24.952272],
'Kluuvi' => [60.172580, 24.941144],
'Koivusaari' => [60.163196, 24.856204],
'Konala' => [60.236852, 24.845177],
'Koskela' => [60.218253, 24.966418],
'Kruununhaka' => [60.172352, 24.956470],
'Kruunuvuorenranta' => [60.166554, 25.022126],
'Kulosaari' => [60.185983, 25.008457],
'Kumpula' => [60.209094, 24.964821],
'Kuninkaantammi' => [60.261009, 24.890437],
'Käpylä' => [60.214154, 24.950797],
'Laajasalo' => [60.171870, 25.043385],
'Laakso' => [60.192795, 24.916465],
'Lauttasaari' => [60.158291, 24.874188],
'Länsisatama' => [60.159699, 24.924461],
'Malmi' => [60.250980, 25.010506],
'Malminkartano' => [60.247517, 24.862129],
'Meilahti' => [60.191904, 24.898236],
'Mellunkylä' => [60.233563, 25.102157],
'Munkkiniemi' => [60.198247, 24.875977],
'Mustikkamaa-Korkeasaari' => [60.180563, 24.990058],
'Myllypuro' => [60.223721, 25.067943],
'Oulunkylä' => [60.229094, 24.963609],
'Pakila' => [60.244177, 24.948121],
'Pasila' => [60.203116, 24.926870],
'Pitäjänmäki' => [60.222972, 24.862067],
'Pukinmäki' => [60.245141, 24.988965],
'Punavuori' => [60.161450, 24.937520],
'Ruoholahti' => [60.163818, 24.908564],
'Ruskeasuo' => [60.202629, 24.905525],
'Salmenkallio' => [60.263065, 25.192160],
'Santahamina' => [60.147226, 25.051203],
'Suomenlinna' => [60.145609, 24.986295],
'Suurmetsä' => [60.265570, 25.079241],
'Suutarila' => [60.280899, 25.010958],
'Sörnäinen' => [60.186503, 24.968059],
'Taka-Töölö' => [60.184170, 24.923262],
'Talosaari' => [60.242051, 25.197464],
'Tammisalo' => [60.191309, 25.063848],
'Tapaninkylä' => [60.262263, 25.011138],
'Toukola' => [60.206072, 24.972955],
'Tuomarinkylä' => [60.256383, 24.966787],
'Ulkosaaret' => [60.089292, 24.926002],
'Ullanlinna' => [60.158457, 24.948937],
'Ultuna' => [60.278678, 25.195271],
'Vallila' => [60.194432, 24.956953],
'Vanhakaupunki' => [60.216221, 24.981143],
'Vartiokylä' => [60.217183, 25.095837],
'Vartiosaari' => [60.184930, 25.078028],
'Viikki' => [60.224815, 25.020019],
'Villinki' => [60.158338, 25.114887],
'Vuosaari' => [60.209362, 25.147469],
'Östersundom' => [60.251257, 25.182209],
];

$storage = \Drupal::entityTypeManager()
->getStorage('taxonomy_term');

foreach ($neighbourhoods as $name => $location) {
$terms = $storage->loadByProperties(['name' => $name, 'vid' => 'news_neighbourhoods']);
if (!$terms) {
continue;
}

[$latitude, $longitude] = $location;
$term = reset($terms);
$term->set('field_location', [
'latitude' => $latitude,
'longitude' => $longitude,
]);
$term->save();
}

}
1 change: 1 addition & 0 deletions public/modules/custom/helfi_etusivu/helfi_etusivu.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ dependencies:
- helfi_annif:helfi_annif
- simple_sitemap:simple_sitemap
- helfi_react_search:helfi_react_search
- helfi_platform_config:helfi_paragraphs_news_list
'interface translation project': helfi_etusivu
'interface translation server pattern': modules/custom/helfi_etusivu/translations/%language.po
2 changes: 2 additions & 0 deletions public/modules/custom/helfi_etusivu/helfi_etusivu.module
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ function helfi_etusivu_theme() : array {
'coordinates' => NULL,
'title' => NULL,
'service_groups' => NULL,
'nearby_neighbourhoods' => NULL,
'news_archive_url' => NULL,
],
'template' => 'helsinki-near-you-results-page',
],
Expand Down
Loading
Loading