From a1bdd2c866ec1755f495a9691deefbfd4a763d8b Mon Sep 17 00:00:00 2001 From: Polen Date: Wed, 8 Apr 2026 10:06:48 -0400 Subject: [PATCH 01/10] ignore binary --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d6ae58d..80d2672 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /result *.db .direnv/ +./prixgugaz From de945f3226a22164f58e512306e810166a70fee9 Mon Sep 17 00:00:00 2001 From: Polen Date: Wed, 8 Apr 2026 10:07:19 -0400 Subject: [PATCH 02/10] typo --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 80d2672..5a64b4c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /result *.db .direnv/ -./prixgugaz +/prixdugaz From 8e5435220e1b306737f665136180a4357b09fb78 Mon Sep 17 00:00:00 2001 From: Polen Date: Wed, 8 Apr 2026 10:41:09 -0400 Subject: [PATCH 03/10] github link --- go.mod | 2 +- static/style.css | 11 +++++++++++ templates/layout.html | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 351c584..d47486e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/polen/prixdugaz +module github.com/Polensky/prixdugaz go 1.25.0 diff --git a/static/style.css b/static/style.css index d70adbd..0e92119 100644 --- a/static/style.css +++ b/static/style.css @@ -47,6 +47,17 @@ html, body { height: 100%; margin: 0; padding: 0; } color: var(--primary-foreground); } #topnav nav a svg { flex-shrink: 0; } +.github-link { + margin-left: auto; + display: flex; align-items: center; + color: var(--muted-foreground); + padding: 5px 6px; border-radius: 6px; + transition: background 0.12s, color 0.12s; +} +.github-link:hover { + background: var(--muted); + color: var(--foreground); +} /* ── App shell ───────────────────────────────────────── */ #app { diff --git a/templates/layout.html b/templates/layout.html index 540d47e..17eb12a 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -51,6 +51,11 @@ Statistiques + + + + + From f56325de5fc26bcea05478ca9898338ad2f9a342 Mon Sep 17 00:00:00 2001 From: Polen Date: Wed, 8 Apr 2026 10:51:03 -0400 Subject: [PATCH 04/10] locate me --- static/map.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/static/map.js b/static/map.js index 5b175d8..820ae2a 100644 --- a/static/map.js +++ b/static/map.js @@ -18,6 +18,7 @@ // ── Map setup (deferred to init section below) ───────────── let map; let clusterGroup; + let locateMarker = null; // ── Colour helpers ───────────────────────────────────────── function priceColor(price, min, max) { @@ -284,6 +285,41 @@ // Create map and cluster group now that the DOM is ready. map = L.map('map', { zoomControl: false }).setView([46.8, -71.2], 7); L.control.zoom({ position: 'topright' }).addTo(map); + + // ── Locate-me control ────────────────────────────────── + var LocateControl = L.Control.extend({ + options: { position: 'bottomright' }, + onAdd: function () { + var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control'); + var btn = L.DomUtil.create('a', '', container); + btn.href = '#'; + btn.title = 'Ma position'; + btn.setAttribute('role', 'button'); + btn.setAttribute('aria-label', 'Ma position'); + btn.innerHTML = ''; + L.DomEvent.on(btn, 'click', function (e) { + L.DomEvent.preventDefault(e); + if (!navigator.geolocation) return; + navigator.geolocation.getCurrentPosition(function (pos) { + var latlng = [pos.coords.latitude, pos.coords.longitude]; + map.setView(latlng, 14); + if (locateMarker) { + locateMarker.setLatLng(latlng); + } else { + locateMarker = L.circleMarker(latlng, { + radius: 10, + color: '#fff', + weight: 3, + fillColor: '#2563eb', + fillOpacity: 1, + }).addTo(map); + } + }); + }); + return container; + }, + }); + new LocateControl().addTo(map); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap | Données: Régie de l\'énergie du Québec', maxZoom: 18, From 0ef15af42015adaad23c4f345666b06d20f3585f Mon Sep 17 00:00:00 2001 From: Polen Date: Wed, 8 Apr 2026 11:25:14 -0400 Subject: [PATCH 05/10] localisation --- static/map.js | 62 +++++++++++++++++++--------------------------- static/style.css | 53 +++++++++++++++++++++++++++++++++------ templates/map.html | 5 +++- 3 files changed, 76 insertions(+), 44 deletions(-) diff --git a/static/map.js b/static/map.js index 820ae2a..f640371 100644 --- a/static/map.js +++ b/static/map.js @@ -255,6 +255,29 @@ rebuildMarkers(); }); + // ── Locate-me button ─────────────────────────────────── + var locateBtn = document.getElementById('locate-btn'); + if (locateBtn) { + locateBtn.addEventListener('click', function () { + if (!navigator.geolocation) return; + navigator.geolocation.getCurrentPosition(function (pos) { + var latlng = [pos.coords.latitude, pos.coords.longitude]; + map.setView(latlng, 14); + if (locateMarker) { + locateMarker.setLatLng(latlng); + } else { + var dotIcon = L.divIcon({ + html: '
', + className: '', + iconSize: [20, 20], + iconAnchor: [10, 10], + }); + locateMarker = L.marker(latlng, { icon: dotIcon, pane: 'locatePane' }).addTo(map); + } + }); + }); + } + // ── Mobile filter panel toggle ───────────────────────── var filterToggle = document.getElementById('filter-toggle'); var sliderPanel = document.getElementById('slider-panel'); @@ -284,44 +307,11 @@ try { // Create map and cluster group now that the DOM is ready. map = L.map('map', { zoomControl: false }).setView([46.8, -71.2], 7); + map.createPane('locatePane').style.zIndex = 650; L.control.zoom({ position: 'topright' }).addTo(map); - - // ── Locate-me control ────────────────────────────────── - var LocateControl = L.Control.extend({ - options: { position: 'bottomright' }, - onAdd: function () { - var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control'); - var btn = L.DomUtil.create('a', '', container); - btn.href = '#'; - btn.title = 'Ma position'; - btn.setAttribute('role', 'button'); - btn.setAttribute('aria-label', 'Ma position'); - btn.innerHTML = ''; - L.DomEvent.on(btn, 'click', function (e) { - L.DomEvent.preventDefault(e); - if (!navigator.geolocation) return; - navigator.geolocation.getCurrentPosition(function (pos) { - var latlng = [pos.coords.latitude, pos.coords.longitude]; - map.setView(latlng, 14); - if (locateMarker) { - locateMarker.setLatLng(latlng); - } else { - locateMarker = L.circleMarker(latlng, { - radius: 10, - color: '#fff', - weight: 3, - fillColor: '#2563eb', - fillOpacity: 1, - }).addTo(map); - } - }); - }); - return container; - }, - }); - new LocateControl().addTo(map); + var lastUpdatedText = (document.getElementById('last-updated') || {}).textContent || ''; L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap | Données: Régie de l\'énergie du Québec', + attribution: '© OpenStreetMap | Données: Régie de l\'énergie du Québec' + (lastUpdatedText ? ' | ' + lastUpdatedText : ''), maxZoom: 18, }).addTo(map); diff --git a/static/style.css b/static/style.css index 0e92119..5ac2a89 100644 --- a/static/style.css +++ b/static/style.css @@ -128,15 +128,54 @@ html, body { height: 100%; margin: 0; padding: 0; } font-size: 10px; color: var(--muted-foreground); } -#last-updated { - position: absolute; bottom: 24px; right: 8px; - padding: 5px 10px; - z-index: 1000; font-size: 11px; - color: var(--muted-foreground); -} - .pin-icon { filter: drop-shadow(0 1px 3px rgba(0,0,0,0.35)); } +#locate-btn { + position: absolute; bottom: 34px; right: 8px; + display: flex; + align-items: center; + justify-content: center; + width: 30px; + height: 30px; + padding: 0; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--card); + color: var(--card-foreground); + box-shadow: 0 2px 8px rgba(0,0,0,0.15); + cursor: pointer; + z-index: 1000; +} +#locate-btn:hover { background: var(--muted); } + +/* Locate-me blue dot + pulse ring */ +.locate-dot { + position: relative; + width: 20px; + height: 20px; +} +.locate-dot-inner { + position: absolute; + inset: 4px; + border-radius: 50%; + background: #2563eb; + border: 2.5px solid #fff; + box-shadow: 0 1px 4px rgba(0,0,0,0.4); + z-index: 1; +} +.locate-dot-pulse { + position: absolute; + inset: 0; + border-radius: 50%; + background: #2563eb; + opacity: 0.35; + animation: locate-pulse 1.8s ease-out infinite; +} +@keyframes locate-pulse { + 0% { transform: scale(0.6); opacity: 0.5; } + 100% { transform: scale(2.2); opacity: 0; } +} + .cluster-info-tip { position: relative; display: inline-flex; diff --git a/templates/map.html b/templates/map.html index 66636dd..bcd1521 100644 --- a/templates/map.html +++ b/templates/map.html @@ -66,7 +66,10 @@
-
{{.LastUpdated}}
+ +