5c75f1416f
- object-fit: contain + ::before blurred background fill on all slides - dots moved inside photo-wrap, overlaid at bottom with shadow for contrast - arrows hidden on touch devices via @media (hover: none) - margin-bottom increased for breathing room below photo block - trip.html.twig brought up to parity with dailies: same structure, same PhotoSwipe init, same expand button, same dot overlay Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr
215 lines
9.8 KiB
Twig
215 lines
9.8 KiB
Twig
{% extends 'default.html.twig' %}
|
|
|
|
{% block content %}
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@5/dist/photoswipe.css">
|
|
{% set journal_entries = page.collection() %}
|
|
{% set stories_page = grav.pages.find(page.parent().route ~ '/stories') %}
|
|
{% set story_entries = stories_page ? stories_page.children.published() : [] %}
|
|
|
|
{% set all_items = [] %}
|
|
{% for e in journal_entries %}
|
|
{% set all_items = all_items|merge([{'type': 'journal', 'page': e, 'date': e.date}]) %}
|
|
{% endfor %}
|
|
{% for s in story_entries %}
|
|
{% set all_items = all_items|merge([{'type': 'story', 'page': s, 'date': s.date}]) %}
|
|
{% endfor %}
|
|
|
|
{# No sort needed: page.collection() returns journal entries date-descending per dailies.md config. Dailies has no stories, so no re-merge sort is needed. #}
|
|
|
|
{# Collect GPS entries for mini-map #}
|
|
{% set map_entries = [] %}
|
|
{% for item in all_items %}
|
|
{% if item.type == 'journal' and item.page.header.lat is not empty and item.page.header.lng is not empty %}
|
|
{% set map_entries = map_entries|merge([{
|
|
'lat': item.page.header.lat,
|
|
'lng': item.page.header.lng,
|
|
'title': item.page.title,
|
|
'slug': item.page.slug,
|
|
'url': item.page.url,
|
|
'force_connect': item.page.header.force_connect ? true : false,
|
|
'transport_mode': item.page.header.transport_mode ? item.page.header.transport_mode : null
|
|
}]) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% set trip_page = page.parent() %}
|
|
|
|
{% if map_entries|length > 0 %}
|
|
<div class="feed-map-wrap">
|
|
<div class="feed-map" id="feed-map"></div>
|
|
<a class="feed-map-link" href="{{ page.parent().url }}/map">View full map →</a>
|
|
</div>
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maplibre-gl@4/dist/maplibre-gl.css">
|
|
<script src="https://cdn.jsdelivr.net/npm/maplibre-gl@4/dist/maplibre-gl.js"></script>
|
|
<script src="{{ url('theme://js/maplibre-utils.js') }}"></script>
|
|
<script>
|
|
var FEED_ENTRIES = {{ map_entries|json_encode|raw }};
|
|
{% set _ac = trip_page.header.autoconnect ?? 'on' %}
|
|
var AUTOCONNECT = "{{ _ac == 'intelligent_gpx' ? 'on' : _ac }}";
|
|
|
|
var feedMap = new maplibregl.Map({
|
|
container: 'feed-map',
|
|
style: MapUtils.MAP_STYLE,
|
|
center: [20, 20],
|
|
zoom: 2
|
|
});
|
|
|
|
feedMap.on('load', function () {
|
|
var bounds = new maplibregl.LngLatBounds();
|
|
|
|
FEED_ENTRIES.forEach(function (entry, i) {
|
|
var isLatest = (i === FEED_ENTRIES.length - 1);
|
|
var lngLat = [parseFloat(entry.lng), parseFloat(entry.lat)];
|
|
bounds.extend(lngLat);
|
|
|
|
var el = MapUtils.createDotMarker(isLatest);
|
|
el.dataset.url = entry.url;
|
|
var popup = new maplibregl.Popup({ offset: 12, closeButton: false, closeOnClick: false, className: 'map-tip-popup' })
|
|
.setLngLat(lngLat)
|
|
.setHTML('<span class="map-tip">' + entry.title + '</span>');
|
|
el.addEventListener('mouseenter', function () { popup.addTo(feedMap); });
|
|
el.addEventListener('mouseleave', function () { popup.remove(); });
|
|
el.addEventListener('click', function () { window.location.href = entry.url; });
|
|
|
|
new maplibregl.Marker({ element: el }).setLngLat(lngLat).addTo(feedMap);
|
|
});
|
|
|
|
if (FEED_ENTRIES.length === 1) {
|
|
feedMap.jumpTo({ center: [parseFloat(FEED_ENTRIES[0].lng), parseFloat(FEED_ENTRIES[0].lat)], zoom: 10 });
|
|
} else {
|
|
feedMap.fitBounds(bounds, { padding: 60, maxZoom: 11 });
|
|
}
|
|
|
|
var segments = MapUtils.buildJourneySegments(FEED_ENTRIES, { connectMode: AUTOCONNECT });
|
|
MapUtils.addJourneySegments(feedMap, segments, 'feed-journey');
|
|
});
|
|
</script>
|
|
{% endif %}
|
|
|
|
<div class="feed">
|
|
{% if all_items|length > 0 %}
|
|
{% for item in all_items %}
|
|
{% set entry = item.page %}
|
|
|
|
{% if item.type == 'journal' %}
|
|
{% set weather_icons = {
|
|
'Sunny': '☀️', 'Partly cloudy': '⛅', 'Cloudy': '☁️',
|
|
'Foggy': '🌫️', 'Drizzle': '🌦️', 'Rain': '🌧️',
|
|
'Snow': '❄️', 'Thunderstorm': '⛈️'
|
|
} %}
|
|
<article class="journal-post" id="entry-{{ entry.slug }}" data-type="journal" data-lat="{{ entry.header.lat }}" data-lng="{{ entry.header.lng }}">
|
|
<header class="journal-post-header">
|
|
<h2 class="journal-post-title">{{ entry.title }}</h2>
|
|
<p class="journal-post-meta">
|
|
<a class="journal-post-permalink" href="{{ entry.url }}">
|
|
<time datetime="{{ entry.date|date('Y-m-d') }}">{{ entry.date|date('d M Y')|upper }}</time>
|
|
</a>
|
|
{% if entry.header.location_city or entry.header.location_country %}
|
|
<span class="journal-post-location">
|
|
· 📍
|
|
{%- set _loc = [] -%}
|
|
{%- if entry.header.location_city -%}{%- set _loc = _loc|merge([entry.header.location_city]) -%}{%- endif -%}
|
|
{%- if entry.header.location_country -%}{%- set _loc = _loc|merge([entry.header.location_country]) -%}{%- endif -%}
|
|
{{ _loc|join(', ') }}
|
|
</span>
|
|
{% endif %}
|
|
{% if entry.header.weather_desc %}
|
|
<span class="journal-post-weather">· {{ weather_icons[entry.header.weather_desc] ?? '' }} {{ entry.header.weather_desc }}</span>
|
|
{% endif %}
|
|
</p>
|
|
</header>
|
|
|
|
{% set images = entry.media.images %}
|
|
{% if images|length > 0 %}
|
|
<div class="journal-photo-wrap">
|
|
<div class="journal-photo-strip pswp-gallery" id="gallery-{{ entry.slug }}">
|
|
{% for img in images %}
|
|
<a class="journal-photo-slide"
|
|
href="{{ img.url }}"
|
|
data-pswp-width="{{ img.width }}"
|
|
data-pswp-height="{{ img.height }}"
|
|
style="--thumb: url('{{ img.cropResize(900, 675).url }}')"
|
|
target="_blank">
|
|
<img src="{{ img.cropResize(900, 675).url }}" alt="{{ entry.title }}" loading="lazy">
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
{% if images|length > 1 %}
|
|
<div class="journal-photo-dots" aria-hidden="true">
|
|
{% for img in images %}
|
|
<span class="journal-photo-dot{% if loop.first %} is-active{% endif %}"></span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
<button class="journal-photo-expand" aria-label="View full size">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/></svg>
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="journal-post-body">{{ entry.content|raw }}</div>
|
|
</article>
|
|
{% else %}
|
|
{% set hero = null %}
|
|
{% if entry.header.hero_image and entry.media[entry.header.hero_image] is defined %}
|
|
{% set hero = entry.media[entry.header.hero_image] %}
|
|
{% elseif entry.media.images|length > 0 %}
|
|
{% set hero = entry.media.images|first %}
|
|
{% endif %}
|
|
<a class="entry-card entry-card--story" id="entry-{{ entry.slug }}" data-type="story" href="{{ entry.url }}">
|
|
{% if hero %}
|
|
<div class="entry-card-photo entry-card-photo--story">
|
|
<img src="{{ hero.cropResize(720, 405).url }}" alt="{{ entry.title }}" loading="lazy">
|
|
</div>
|
|
{% endif %}
|
|
<div class="entry-card-body">
|
|
<span class="story-badge">✦ Story</span>
|
|
<h2 class="entry-title">{{ entry.title }}</h2>
|
|
</div>
|
|
</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% else %}
|
|
<p class="feed-empty">No entries yet. The journey is about to begin.</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<script type="module">
|
|
import PhotoSwipeLightbox from 'https://cdn.jsdelivr.net/npm/photoswipe@5/dist/photoswipe-lightbox.esm.min.js';
|
|
|
|
const lightbox = new PhotoSwipeLightbox({
|
|
gallery: '.pswp-gallery',
|
|
children: 'a.journal-photo-slide',
|
|
pswpModule: () => import('https://cdn.jsdelivr.net/npm/photoswipe@5/dist/photoswipe.esm.min.js')
|
|
});
|
|
lightbox.init();
|
|
|
|
/* Per-strip: dot sync + expand button → tap the visible slide to trigger pswp */
|
|
document.querySelectorAll('.journal-photo-wrap').forEach(function (wrap) {
|
|
var strip = wrap.querySelector('.journal-photo-strip');
|
|
var slides = Array.from(strip.querySelectorAll('a.journal-photo-slide'));
|
|
var expandBtn = wrap.querySelector('.journal-photo-expand');
|
|
var article = wrap.closest('article');
|
|
var dots = article ? Array.from(article.querySelectorAll('.journal-photo-dot')) : [];
|
|
var visibleIdx = 0;
|
|
|
|
var io = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (e) {
|
|
if (!e.isIntersecting) return;
|
|
visibleIdx = slides.indexOf(e.target);
|
|
dots.forEach(function (d) { d.classList.remove('is-active'); });
|
|
if (dots[visibleIdx]) dots[visibleIdx].classList.add('is-active');
|
|
});
|
|
}, { root: strip, threshold: 0.5 });
|
|
slides.forEach(function (s) { io.observe(s); });
|
|
|
|
if (expandBtn && slides.length) {
|
|
expandBtn.addEventListener('click', function () {
|
|
slides[visibleIdx].dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|