-
Notifications
You must be signed in to change notification settings - Fork 8
Improve community discovery and add a bilingual network overview #91
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
Open
n30nex
wants to merge
3
commits into
main
Choose a base branch
from
codex/community-browser-feedback-20260906
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "description": "Approximate search reference points, not radio locations or coverage boundaries. Existing community coordinates take precedence. Regional references use the published canada-regions.json seed coordinates; broad communities may have several references.", | ||
| "communities": { | ||
| "bc-mesh": ["mvrd", "crd"], | ||
| "salish-mesh": ["mvrd", "crd"], | ||
| "alberta-meshcore-networks": ["cal", "edm", "leth"], | ||
| "airdrie-meshcore-network": [], | ||
| "calgary-area-meshcore": ["cal"], | ||
| "calgary-meshcore-network": [], | ||
| "edmonton-meshcore-network": [], | ||
| "yegmesh-ca": [], | ||
| "yqlmesh": [], | ||
| "southern-alberta": ["leth"], | ||
| "yyc-meshcore-discord": ["cal"], | ||
| "stoonmesh": ["stoon"], | ||
| "yqrmesh": ["regina"], | ||
| "greater-ottawa-mesh-enthusiasts": ["ott", "gatout"], | ||
| "gta-lora-meshes": ["tor"], | ||
| "quinte-mesh-network": ["has", "pec"], | ||
| "charlevoix-yml": [{"label": "La Malbaie", "lat": 47.652419, "lon": -70.14951, "source": "https://geolocator.api.geo.ca/?q=La%20Malbaie&lang=en&keys=geonames"}], | ||
| "mesh-quebec": ["mtl", "capnat", "saglac"], | ||
| "montreal-mesh": ["mtl"], | ||
| "reseau-mesh-capitale-yqb": ["capnat"], | ||
| "reseau-mesh-saguenay-lac-saint-jean-ytf": ["saglac"], | ||
| "reseau-libre": ["mtl"], | ||
| "southern-new-brunswick": ["york", "sj", "westm"], | ||
| "lunenburg-county-mesh": ["lun"] | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| (function () { | ||
| "use strict"; | ||
| var MAX_AGE = 5 * 60 * 1000; | ||
| var CACHE_KEY = "meshcore-canada:network-totals:v1"; | ||
| var pending = null; | ||
| var cache = null; | ||
|
|
||
| function count(value) { | ||
| if (!Number.isSafeInteger(value) || value < 0) throw new Error("Invalid network count"); | ||
| return value; | ||
| } | ||
|
|
||
| function parseStats(overview, types) { | ||
| if (!overview || !Array.isArray(types) || types.length > 16) throw new Error("Invalid network statistics"); | ||
| var result = { repeaters: 0, companions: 0, rooms: 0, sensors: 0, other: 0, total: 0, | ||
| observers: count(overview.activeObservers), areas: count(overview.activeIatas), packets: count(overview.totalPackets), | ||
| hours: count(overview.windowHours) }; | ||
| if (result.hours < 1 || result.hours > 168) throw new Error("Invalid reporting window"); | ||
| var seen = new Set(); | ||
| types.forEach(function (item) { | ||
| var type = count(item.nodeType); | ||
| if (seen.has(type)) throw new Error("Duplicate device type"); | ||
| seen.add(type); | ||
| var field = ({ 1: "companions", 2: "repeaters", 3: "rooms", 4: "sensors" })[type] || "other"; | ||
| result[field] += count(item.count); | ||
| result.total += item.count; | ||
| }); | ||
| count(result.total); | ||
| return result; | ||
| } | ||
|
|
||
| function readCache() { | ||
| try { | ||
| var saved = cache || JSON.parse(sessionStorage.getItem(CACHE_KEY)); | ||
| if (!saved || !Number.isFinite(saved.at) || saved.at > Date.now() || Date.now() - saved.at >= MAX_AGE) return null; | ||
| ["repeaters", "companions", "rooms", "sensors", "other", "total", "observers", "areas", "packets", "hours"].forEach(function (key) { count(saved.stats[key]); }); | ||
| if (saved.stats.hours < 1 || saved.stats.hours > 168) return null; | ||
| return saved; | ||
| } catch (_) { return null; } | ||
| } | ||
|
|
||
| async function loadStats() { | ||
| var saved = readCache(); | ||
| if (saved) return saved; | ||
| if (pending) return pending; | ||
| pending = (async function () { | ||
| var controller = new AbortController(); | ||
| var timer = window.setTimeout(function () { controller.abort(); }, 8000); | ||
| try { | ||
| var responses = await Promise.all(["overview", "node-types"].map(async function (path) { | ||
| var response = await fetch("https://dev.meshcore.ca/api/v1/stats/" + path, { signal: controller.signal, credentials: "omit" }); | ||
| if (!response.ok) throw new Error("Network statistics unavailable"); | ||
| return response.json(); | ||
| })); | ||
| cache = { at: Date.now(), stats: parseStats(responses[0], responses[1]) }; | ||
| try { sessionStorage.setItem(CACHE_KEY, JSON.stringify(cache)); } catch (_) { /* Counts work without storage. */ } | ||
| return cache; | ||
| } finally { window.clearTimeout(timer); controller.abort(); } | ||
| })().finally(function () { pending = null; }); | ||
| return pending; | ||
| } | ||
|
|
||
| function initialize() { | ||
| var root = document.querySelector("[data-network-summary]"); | ||
| if (!root || root.dataset.networkReady) return; | ||
| root.dataset.networkReady = "true"; | ||
| var french = document.documentElement.lang.startsWith("fr"); | ||
| var locale = french ? "fr-CA" : "en-CA"; | ||
| var numbers = new Intl.NumberFormat(locale); | ||
| var compact = new Intl.NumberFormat(locale, { notation: "compact", maximumFractionDigits: 1 }); | ||
| var summary = root.querySelector("summary"); | ||
| var total = root.querySelector("[data-network-total]"); | ||
| var updated = root.querySelector("[data-network-updated]"); | ||
| async function refresh() { | ||
| if (document.visibilityState === "hidden") return; | ||
| try { | ||
| var data = await loadStats(); | ||
| total.textContent = compact.format(data.stats.total); | ||
| summary.setAttribute("aria-label", (french ? "Statistiques du réseau : " : "Network statistics: ") + numbers.format(data.stats.total) + (french ? " appareils connus" : " known devices")); | ||
| root.querySelectorAll("[data-network-count]").forEach(function (element) { | ||
| element.textContent = numbers.format(data.stats[element.dataset.networkCount]); | ||
| }); | ||
| root.querySelectorAll("[data-network-other]").forEach(function (element) { element.hidden = !data.stats.other; }); | ||
| root.querySelector("[data-network-period]").textContent = french ? "Dernières " + data.stats.hours + " h" : "Last " + data.stats.hours + " hours"; | ||
| updated.textContent = (french ? "Mis à jour à " : "Updated ") + new Date(data.at).toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" }); | ||
| root.dataset.networkState = "ready"; | ||
| } catch (_) { | ||
| total.textContent = "—"; | ||
| summary.setAttribute("aria-label", french ? "Statistiques du réseau indisponibles" : "Network statistics unavailable"); | ||
| root.querySelectorAll("[data-network-count]").forEach(function (element) { element.textContent = "—"; }); | ||
| root.querySelectorAll("[data-network-other]").forEach(function (element) { element.hidden = true; }); | ||
| updated.textContent = french ? "Totaux indisponibles pour le moment." : "Network totals are temporarily unavailable."; | ||
| root.dataset.networkState = "unavailable"; | ||
| } | ||
| } | ||
| document.addEventListener("pointerdown", function (event) { if (!root.contains(event.target)) root.open = false; }); | ||
| root.addEventListener("focusout", function (event) { if (event.relatedTarget && !root.contains(event.relatedTarget)) root.open = false; }); | ||
| root.addEventListener("keydown", function (event) { if (event.key === "Escape" && root.open) { root.open = false; summary.focus(); } }); | ||
| document.addEventListener("visibilitychange", refresh); | ||
| window.setInterval(refresh, MAX_AGE); | ||
| refresh(); | ||
| } | ||
|
|
||
| globalThis.MeshCoreNetworkStatus = { parseStats: parseStats }; | ||
| if (typeof document === "undefined") return; | ||
| if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", initialize, { once: true }); | ||
| else initialize(); | ||
| })(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| .mc-home-hero { | ||
| position: relative; isolation: isolate; overflow: hidden; | ||
| min-height: 11rem; padding: 1.5rem; margin: 1rem 0 2rem; | ||
| border: 1px solid var(--mc-color-border); border-radius: var(--mc-radius-md); | ||
| background: linear-gradient(115deg, var(--mc-color-surface), var(--mc-color-surface-raised)); | ||
| } | ||
| .mc-home-hero > .mc-home-hero__art { | ||
| position: absolute; z-index: -1; top: 0; right: 0; height: 100%; width: 68%; | ||
| object-fit: contain; pointer-events: none; opacity: 0.9; | ||
| mask-image: linear-gradient(to right, transparent, #000 28%); | ||
| } | ||
| .mc-home-hero__art img { width: 100%; height: 100%; object-fit: contain; } | ||
| .mc-home-hero > p { position: relative; max-width: 38ch; margin: 0; } | ||
| .mc-home-hero .mc-home-hero__credit { margin-top: 1rem; font-size: 0.7rem; color: var(--mc-color-text-muted); } | ||
| .mc-preset-note { font-size: 0.85rem; color: var(--mc-color-text-muted); } | ||
| @media (max-width: 45em) { | ||
| .mc-home-hero { padding: 1.25rem; min-height: 10rem; } | ||
| .mc-home-hero > .mc-home-hero__art { width: 100%; opacity: 0.25; mask-image: none; } | ||
| .mc-home-hero > p { max-width: none; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| .mc-network { position: relative; flex: 0 0 auto; margin-inline: 0.3rem; } | ||
| .mc-network > summary { | ||
| display: flex; align-items: center; gap: 0.35rem; min-height: 2.75rem; | ||
| padding: 0.25rem 0.35rem; border-radius: var(--mc-radius-sm); | ||
| color: #fff; cursor: pointer; list-style: none; font-size: 0.75rem; | ||
| } | ||
| .mc-network > summary::-webkit-details-marker { display: none; } | ||
| .mc-network > summary:hover, .mc-network[open] > summary { background: rgb(255 255 255 / 8%); } | ||
| .mc-network__icon { display: flex; } | ||
| .mc-network__icon svg { width: 1.1rem; height: 1.1rem; fill: currentColor; } | ||
| .mc-network__total { display: inline-block; min-width: 3.2rem; text-align: end; font-variant-numeric: tabular-nums; } | ||
| .mc-network__panel { | ||
| position: absolute; top: calc(100% + 0.25rem); right: 0; z-index: 5; | ||
| width: 19rem; max-width: calc(100vw - 1.5rem); padding: 1rem; | ||
| color: var(--mc-color-text); background: var(--mc-color-surface); | ||
| border: 1px solid var(--mc-color-border); border-radius: var(--mc-radius-md); | ||
| box-shadow: var(--mc-shadow-2); font-size: 0.85rem; line-height: 1.5; | ||
| } | ||
| .mc-network__panel p { margin: 0 0 0.6rem; } | ||
| .mc-network__panel dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; margin: 0 0 0.9rem; } | ||
| .mc-network__panel dt { color: var(--mc-color-text-muted); } | ||
| .mc-network__panel dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 650; } | ||
| .mc-network__panel .mc-network__period { border-top: 1px solid var(--mc-color-border); padding-top: 0.6rem; font-weight: 650; } | ||
| .mc-network__panel .mc-network__updated { color: var(--mc-color-text-muted); font-size: 0.75rem; } | ||
| .mc-network__panel a { color: var(--mc-color-action); text-decoration: underline; } | ||
| .mc-network [hidden] { display: none !important; } | ||
| @media (max-width: 72em) { .mc-network__label { display: none; } } | ||
| @media (max-width: 45em) { | ||
| .mc-network { margin-inline: 0; } | ||
| .mc-network__total { display: none; } | ||
| .mc-network > summary { min-width: 2rem; justify-content: center; padding: 0.25rem; } | ||
| .mc-network__panel { position: fixed; top: 3.5rem; right: 0.75rem; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the page remains visible after a fresh request, this interval starts before
refresh()finishes, while the cache timestamp is recorded afterward. The first five-minute tick therefore sees an entry just underMAX_AGEand reuses it, and the next fetch does not occur until the ten-minute tick, leaving the header totals and update timestamp stale for nearly twice the intended cache lifetime. Schedule the next refresh relative todata.ator otherwise ensure the first post-expiry tick fetches new data.Useful? React with 👍 / 👎.