From 705e00f8527e8a800030699eec457edc447c5006 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Sat, 11 Apr 2026 14:39:19 +0200 Subject: [PATCH] adding community tab --- site/src/components/CommunityView.svelte | 348 +++++++++++++++++++++++ site/src/layouts/Base.astro | 8 +- site/src/pages/about/ca/index.astro | 30 +- site/src/pages/about/es/index.astro | 30 +- site/src/pages/about/index.astro | 30 +- site/src/pages/about/it/index.astro | 30 +- site/src/pages/community/index.astro | 7 + 7 files changed, 443 insertions(+), 40 deletions(-) create mode 100644 site/src/components/CommunityView.svelte create mode 100644 site/src/pages/community/index.astro diff --git a/site/src/components/CommunityView.svelte b/site/src/components/CommunityView.svelte new file mode 100644 index 0000000..1fffc4d --- /dev/null +++ b/site/src/components/CommunityView.svelte @@ -0,0 +1,348 @@ + + +
+ +
+

Community

+

What everyone's been up to — together.

+
+ + {#if loading} +

Loading…

+ {:else if error} +

{error}

+ {:else} + + +
+ {#each PERIODS as p} + + {/each} +
+ + + {#if totals.users > 0} +
+ {#each [ + { label: 'Activities', value: totals.count.toLocaleString() }, + { label: 'Distance', value: formatDistance(totals.distance_m) }, + { label: 'Elevation', value: `${Math.round(totals.elevation_m / 1000).toLocaleString()} km↑` }, + { label: 'Time', value: formatDuration(totals.duration_s) }, + ] as item} +
+
{item.value}
+
{item.label}
+
+ {/each} +
+ {/if} + + + {#if totals.users === 0} +

No public activities in this period yet.

+ {:else} +
+ + + {#if rowsCount.length} +
+

Out there

+

Who kept showing up

+ {#each rowsCount as u, i} +
+
+ {MEDAL[i]} + {u.display_name} +
+ {u.count} {u.count === 1 ? 'activity' : 'activities'} +
+ {/each} +
+ {/if} + + + {#if rowsDistance.length} +
+

Going far

+

Who covered the most ground

+ {#each rowsDistance as u, i} +
+
+ {MEDAL[i]} + {u.display_name} +
+ {formatDistance(u.distance_m)} +
+ {/each} +
+ {/if} + + + {#if rowsElevation.length} +
+

Reaching new heights

+

Who climbed the most

+ {#each rowsElevation as u, i} +
+
+ {MEDAL[i]} + {u.display_name} +
+ {Math.round(u.elevation_m).toLocaleString()} m +
+ {/each} +
+ {/if} + + + {#if rowsDuration.length} +
+

Hours on the move

+

Who invested the most time

+ {#each rowsDuration as u, i} +
+
+ {MEDAL[i]} + {u.display_name} +
+ {formatDuration(u.duration_s)} +
+ {/each} +
+ {/if} + + + {#if rowsSports.length} +
+

Explorer

+

Who tried the most sports

+ {#each rowsSports as u, i} +
+
+ {MEDAL[i]} + {u.display_name} +
+ + {#each u.sports as s}{sportIcon(s)}{/each} + +
+ {/each} +
+ {/if} + + + {#if rowsStreak.length} +
+

Never stopped

+

Longest streak of consecutive days (all time)

+ {#each rowsStreak as u, i} +
+
+ {MEDAL[i]} + {u.display_name} +
+ {u.streak} days +
+ {/each} +
+ {/if} + +
+ {/if} + {/if} +
diff --git a/site/src/layouts/Base.astro b/site/src/layouts/Base.astro index b20cd7f..d224300 100644 --- a/site/src/layouts/Base.astro +++ b/site/src/layouts/Base.astro @@ -176,6 +176,9 @@ try { Stats Athlete + {!singleHandle && ( + Community + )} {mobileApp && ( Record )} @@ -183,7 +186,6 @@ try { Convert )} About - )} @@ -423,11 +425,9 @@ try { el.href = baseUrl + 'u/' + user.handle + '/' + el.getAttribute('data-user-path'); }); - // Show logout button and feedback link + // Show logout button const logoutEl = document.getElementById('nav-logout'); if (logoutEl) logoutEl.style.display = ''; - const feedbackEl = document.getElementById('nav-feedback'); - if (feedbackEl) feedbackEl.style.display = ''; // Pre-populate the "keep original" checkbox from the instance default const chk = document.getElementById('upload-keep-original'); diff --git a/site/src/pages/about/ca/index.astro b/site/src/pages/about/ca/index.astro index a4f928e..742644f 100644 --- a/site/src/pages/about/ca/index.astro +++ b/site/src/pages/about/ca/index.astro @@ -23,15 +23,25 @@ const labels = {

Seguiment d'activitats de codi obert i allotjament propi

- - ☕ Dona suport a Ko-fi - +
+ + ☕ Dona suport a Ko-fi + + +
@@ -146,6 +156,8 @@ const labels = { try { const me = await fetch('/api/me', { credentials: 'include' }); if (!me.ok) return; + const feedbackBtn = document.getElementById('feedback-btn'); + if (feedbackBtn) feedbackBtn.style.display = ''; } catch { return; } let data; try { diff --git a/site/src/pages/about/es/index.astro b/site/src/pages/about/es/index.astro index 610b38a..01bb4b7 100644 --- a/site/src/pages/about/es/index.astro +++ b/site/src/pages/about/es/index.astro @@ -23,15 +23,25 @@ const labels = {

Seguimiento de actividades open-source y autoalojado

- - ☕ Apoya en Ko-fi - +
+ + ☕ Apoya en Ko-fi + + +
@@ -145,6 +155,8 @@ const labels = { try { const me = await fetch('/api/me', { credentials: 'include' }); if (!me.ok) return; + const feedbackBtn = document.getElementById('feedback-btn'); + if (feedbackBtn) feedbackBtn.style.display = ''; } catch { return; } let data; try { diff --git a/site/src/pages/about/index.astro b/site/src/pages/about/index.astro index 5340971..2b43f9d 100644 --- a/site/src/pages/about/index.astro +++ b/site/src/pages/about/index.astro @@ -24,15 +24,25 @@ const labels = {

Open-source, self-hosted activity tracking

- - ☕ Support on Ko-fi - +
+ + ☕ Support on Ko-fi + + +
@@ -142,6 +152,8 @@ const labels = { try { const me = await fetch('/api/me', { credentials: 'include' }); if (!me.ok) return; // not logged in — hide community section + const feedbackBtn = document.getElementById('feedback-btn'); + if (feedbackBtn) feedbackBtn.style.display = ''; } catch { return; } let data; try { diff --git a/site/src/pages/about/it/index.astro b/site/src/pages/about/it/index.astro index eae5ce4..1dce80f 100644 --- a/site/src/pages/about/it/index.astro +++ b/site/src/pages/about/it/index.astro @@ -23,15 +23,25 @@ const labels = {

Tracciamento attività open-source e self-hosted

- - ☕ Supporta su Ko-fi - +
+ + ☕ Supporta su Ko-fi + + +
@@ -145,6 +155,8 @@ const labels = { try { const me = await fetch('/api/me', { credentials: 'include' }); if (!me.ok) return; + const feedbackBtn = document.getElementById('feedback-btn'); + if (feedbackBtn) feedbackBtn.style.display = ''; } catch { return; } let data; try { diff --git a/site/src/pages/community/index.astro b/site/src/pages/community/index.astro new file mode 100644 index 0000000..c7a2d72 --- /dev/null +++ b/site/src/pages/community/index.astro @@ -0,0 +1,7 @@ +--- +import Base from '../../layouts/Base.astro'; +import CommunityView from '../../components/CommunityView.svelte'; +--- + + +