From e2ba8f413a038ab070aac1fae83b5b2d406b5c69 Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 4 Jul 2026 13:42:56 +0200 Subject: [PATCH] refactor: extract shared entry-map partial (Phase 2) trip.html.twig and home.html.twig hand-wrote near-identical map-column markup + a MapUtils.initEntryMap() invocation. Extract both into partials/entry-map.html.twig, parameterised (map id, global, entries, gpx config, story markers). Callers now pass resolved header values. The map engine (js/map.js initEntryMap) is unchanged; emitted config is byte-equivalent to the previous inline scripts. Verified: trip-map, home-map and window.tripMap/homeMap Playwright tests pass; both pages 200. Co-Authored-By: Claude Opus 4.8 --- themes/intotheeast/templates/home.html.twig | 42 +++++----------- .../templates/partials/entry-map.html.twig | 49 +++++++++++++++++++ themes/intotheeast/templates/trip.html.twig | 41 +++++----------- 3 files changed, 73 insertions(+), 59 deletions(-) create mode 100644 themes/intotheeast/templates/partials/entry-map.html.twig diff --git a/themes/intotheeast/templates/home.html.twig b/themes/intotheeast/templates/home.html.twig index 654e038..1544a0a 100644 --- a/themes/intotheeast/templates/home.html.twig +++ b/themes/intotheeast/templates/home.html.twig @@ -60,16 +60,18 @@ {% endif %}
-
-
- -
-
+ {% include 'partials/entry-map.html.twig' with { + map_id: 'home-map', + map_global: 'homeMap', + entries: map_entries, + card_prefix: 'entry-', + story_markers: false, + gpx_urls: home_gpx_urls, + use_gpx: trip and trip.header.use_gpx is not null ? trip.header.use_gpx : true, + autoconnect: trip ? (trip.header.autoconnect ?? 'on') : 'on', + gpx_source_prefix: 'home-gpx', + journey_id: 'home-journey' + } only %} {% if all_items|length == 0 %} {% include 'partials/home-predeparture.html.twig' with { @@ -90,26 +92,6 @@ {% endif %}
-{% if map_entries|length > 0 %} - -{% endif %} - {% else %} {# ══════════════════════════════════════════════════════ BETWEEN-TRIPS MODE #} diff --git a/themes/intotheeast/templates/partials/entry-map.html.twig b/themes/intotheeast/templates/partials/entry-map.html.twig new file mode 100644 index 0000000..57a97df --- /dev/null +++ b/themes/intotheeast/templates/partials/entry-map.html.twig @@ -0,0 +1,49 @@ +{# + Entry-map partial — shared by trip.html.twig and home.html.twig (active-trip branch). + + Renders the `.home-map-col` map column plus the thin MapUtils.initEntryMap() + invocation. The map engine itself lives in js/map.js (MapUtils.initEntryMap); + this partial only supplies markup + a parameterised call. Callers register the + map assets (map.css / map.js) themselves via their own {% block map_assets %}. + + The map column always renders (home shows an empty map in pre-departure); the + init script only runs when there are entries to plot. + + Required variables (via {% include ... with {...} only %}): + map_id — string: map div id + fullscreen-btn id prefix ('trip-map' | 'home-map') + map_global — string: window global the Map is assigned to ('tripMap' | 'homeMap') + entries — array: map entries [{lat, lng, slug, title, url, type?, force_connect, ...}] + card_prefix — string: scroll-to card id prefix ('entry-') + story_markers — bool: render story entries as diamond markers (trip: true, home: false) + gpx_urls — array: GPX file URLs + use_gpx — bool: whether to draw GPX tracks + autoconnect — string: journey connect mode ('on' | 'off' | 'manual' | ...) + gpx_source_prefix — string: MapLibre GPX source id prefix ('gpx' | 'home-gpx') + journey_id — string: journey layer id ('trip-journey' | 'home-journey') +#} +
+
+ +
+
+ +{% if entries|length > 0 %} + +{% endif %} diff --git a/themes/intotheeast/templates/trip.html.twig b/themes/intotheeast/templates/trip.html.twig index 6b010fe..5d68118 100644 --- a/themes/intotheeast/templates/trip.html.twig +++ b/themes/intotheeast/templates/trip.html.twig @@ -56,16 +56,18 @@ {% endfor %}
-
-
- -
-
+ {% include 'partials/entry-map.html.twig' with { + map_id: 'trip-map', + map_global: 'tripMap', + entries: map_entries, + card_prefix: 'entry-', + story_markers: true, + gpx_urls: gpx_urls, + use_gpx: page.header.use_gpx ?? true, + autoconnect: page.header.autoconnect ?? 'on', + gpx_source_prefix: 'gpx', + journey_id: 'trip-journey' + } only %} {% include 'partials/trip-feed-col.html.twig' with { trip_page: page, @@ -80,25 +82,6 @@ } only %}
- - {% endblock %}