website: the Discord member count next to the star count
The nav has advertised the repo's stars since the GitLab move but said nothing about the community, which is by now the larger number of the two. Both links now carry their count: GitLab ★ 185, Discord 1,084. Discord hands an invite's guild counts to anyone who appends ?with_counts=1 — no bot token, no server widget to switch on, and the API reflects the caller's Origin, so the browser may read it. The count is fetched exactly like the repo counts: once per tab, cached in sessionStorage, and failing soft — a blocked or revoked request leaves the link reading "Discord", the way it read before. The numbers panel on the home page gains a sixth cell for it and loses the "repo" in its caption, since the counts are no longer all from the repo. Six cells divide evenly where five left a hole, so the row that used to span the full width at the narrow breakpoint goes away: six, then three, then two.
This commit is contained in:
1 parent
523cfc9df7
commit
75fb168a03
7 files changed
+60
-30
No files matched your search
+4
-4
@@ -19,7 +19,7 @@
|
||||
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
|
||||
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
|
||||
<link rel="apple-touch-icon" href="icon-180.png">
|
||||
<link rel="stylesheet" href="styles.css?v=12">
|
||||
<link rel="stylesheet" href="styles.css?v=13">
|
||||
<script>document.documentElement.className += ' js'</script>
|
||||
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
|
||||
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
|
||||
@@ -39,7 +39,7 @@
|
||||
<a class="ql site" href="/api.html">API</a>
|
||||
<a class="ql site" href="/about.html">About</a>
|
||||
<a class="ql" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
<a class="cta" href="/#download">Download</a>
|
||||
</div>
|
||||
<button class="nav-toggle" id="navtoggle" aria-expanded="false" aria-controls="sitemenu" aria-label="Menu">
|
||||
@@ -59,7 +59,7 @@
|
||||
<a class="nl" href="/api.html">API</a>
|
||||
<a class="nl" href="/about.html">About</a>
|
||||
<a class="nl" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,6 +163,6 @@
|
||||
</div>
|
||||
</div></footer>
|
||||
|
||||
<script src="site.js?v=12" defer></script>
|
||||
<script src="site.js?v=13" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
+4
-4
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
|
||||
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
|
||||
<link rel="apple-touch-icon" href="icon-180.png">
|
||||
<link rel="stylesheet" href="styles.css?v=12">
|
||||
<link rel="stylesheet" href="styles.css?v=13">
|
||||
<script>document.documentElement.className += ' js'</script>
|
||||
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
|
||||
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
|
||||
@@ -162,7 +162,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon
|
||||
<a class="ql site" href="/api.html">API</a>
|
||||
<a class="ql site" href="/about.html">About</a>
|
||||
<a class="ql" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
<a class="cta" href="/#download">Download</a>
|
||||
</div>
|
||||
<button class="nav-toggle" id="navtoggle" aria-expanded="false" aria-controls="sitemenu" aria-label="Menu">
|
||||
@@ -182,7 +182,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon
|
||||
<a class="nl" href="/api.html">API</a>
|
||||
<a class="nl" href="/about.html">About</a>
|
||||
<a class="nl" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2205,7 +2205,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon
|
||||
</div>
|
||||
</div></footer>
|
||||
|
||||
<script src="site.js?v=12" defer></script>
|
||||
<script src="site.js?v=13" defer></script>
|
||||
<script>
|
||||
/* Jumping to an anchor inside a collapsed card opens the card — and re-aligns, since
|
||||
the browser scrolled to where the target was while it was still collapsed. */
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@
|
||||
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
|
||||
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
|
||||
<link rel="apple-touch-icon" href="icon-180.png">
|
||||
<link rel="stylesheet" href="styles.css?v=12">
|
||||
<link rel="stylesheet" href="styles.css?v=13">
|
||||
<script>document.documentElement.className += ' js'</script>
|
||||
<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). -->
|
||||
<script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>
|
||||
@@ -42,7 +42,7 @@
|
||||
<a class="ql site" href="/api.html">API</a>
|
||||
<a class="ql site" href="/about.html">About</a>
|
||||
<a class="ql" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
<a class="cta" href="/#download">Download</a>
|
||||
</div>
|
||||
<button class="nav-toggle" id="navtoggle" aria-expanded="false" aria-controls="sitemenu" aria-label="Menu">
|
||||
@@ -62,7 +62,7 @@
|
||||
<a class="nl" href="/api.html">API</a>
|
||||
<a class="nl" href="/about.html">About</a>
|
||||
<a class="nl" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -878,6 +878,6 @@ Leg Day,Leg Press,2026-08-21,200,1</code></pre>
|
||||
</div>
|
||||
</div></footer>
|
||||
|
||||
<script src="site.js?v=12" defer></script>
|
||||
<script src="site.js?v=13" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
+6
-5
@@ -19,7 +19,7 @@
|
||||
<link rel="icon" type="image/png" sizes="512x512" href="icon-512.png">
|
||||
<link rel="icon" type="image/png" sizes="180x180" href="icon-180.png">
|
||||
<link rel="apple-touch-icon" href="icon-180.png">
|
||||
<link rel="stylesheet" href="styles.css?v=12">
|
||||
<link rel="stylesheet" href="styles.css?v=13">
|
||||
<!-- Marks that JS is alive before first paint, so the scroll-reveal styles never
|
||||
hide content from a browser that will not run them. -->
|
||||
<script>
|
||||
@@ -90,7 +90,7 @@ try {
|
||||
<a class="ql site" href="/api.html">API</a>
|
||||
<a class="ql site" href="/about.html">About</a>
|
||||
<a class="ql" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="ql" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
<a class="cta" href="/#download">Download</a>
|
||||
</div>
|
||||
<button class="nav-toggle" id="navtoggle" aria-expanded="false" aria-controls="sitemenu" aria-label="Menu">
|
||||
@@ -110,7 +110,7 @@ try {
|
||||
<a class="nl" href="/api.html">API</a>
|
||||
<a class="nl" href="/about.html">About</a>
|
||||
<a class="nl" href="https://gitlab.com/DuarteSantos8/opengym" rel="noopener">GitLab <span data-gh="stars"></span></a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord</a>
|
||||
<a class="nl" href="https://discord.gg/e62jY6fwVb" rel="noopener">Discord <span data-dc="members"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -429,12 +429,13 @@ try {
|
||||
<div class="specs rv">
|
||||
<div class="spec-head">
|
||||
<span>openGym in numbers</span>
|
||||
<span class="live">repo counts are live</span>
|
||||
<span class="live">counts are live</span>
|
||||
</div>
|
||||
<div class="spec-cells">
|
||||
<div><b data-gh="stars-n">–</b><span>stars</span></div>
|
||||
<div><b data-gh="forks-n">–</b><span>forks</span></div>
|
||||
<div><b data-gh="issues-n">–</b><span>open issues</span></div>
|
||||
<div><b data-dc="members-n">–</b><span>on Discord</span></div>
|
||||
<div><b>1,324</b><span>exercises</span></div>
|
||||
<div><b>13</b><span>languages</span></div>
|
||||
</div>
|
||||
@@ -504,6 +505,6 @@ try {
|
||||
</div>
|
||||
</div></footer>
|
||||
|
||||
<script src="site.js?v=12" defer></script>
|
||||
<script src="site.js?v=13" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,12 @@
|
||||
|
||||
const GL_PROJECT = 'https://gitlab.com/api/v4/projects/DuarteSantos8%2Fopengym'
|
||||
|
||||
// Discord publishes an invite's guild counts to anyone who asks for the invite with
|
||||
// ?with_counts=1 — no bot token, no widget to enable, and the API reflects the caller's
|
||||
// Origin, so the browser is allowed to read it. The code is the permanent invite in the
|
||||
// nav; if that invite is ever revoked this returns 404 and the count simply stays blank.
|
||||
const DC_INVITE = 'https://discord.com/api/v10/invites/e62jY6fwVb?with_counts=1'
|
||||
|
||||
/* ------------------------------------------------------- one panel controller
|
||||
The navigation sheet and the contents drawer are the same object with different
|
||||
contents: one opener, one close button, Escape, a tap outside, focus held inside
|
||||
@@ -256,6 +262,31 @@ function panel({ opener, panelEl, flag, closeBtn }) {
|
||||
} catch (e) { /* offline / rate-limited — leave placeholders */ }
|
||||
})()
|
||||
|
||||
/* --------------------------------------------------- Discord members (nav + specs)
|
||||
Same shape as the repo counts above, and just as optional: the placeholder next to
|
||||
the Discord link is empty, so a blocked or rate-limited request leaves the link
|
||||
reading exactly as it did before anyone counted anything. */
|
||||
;(async () => {
|
||||
const set = (id, v) => document.querySelectorAll('[data-dc="' + id + '"]').forEach(el => { el.textContent = v })
|
||||
try {
|
||||
let n = null
|
||||
const cached = sessionStorage.getItem('discord_members')
|
||||
if (cached) n = JSON.parse(cached)
|
||||
else {
|
||||
const r = await fetch(DC_INVITE)
|
||||
if (!r.ok) return
|
||||
const j = await r.json()
|
||||
n = j.approximate_member_count
|
||||
if (typeof n !== 'number') return
|
||||
sessionStorage.setItem('discord_members', JSON.stringify(n))
|
||||
}
|
||||
// Grouped like the other four-figure numbers on the page (1,324 exercises).
|
||||
const fmt = n.toLocaleString('en-US')
|
||||
set('members', fmt)
|
||||
set('members-n', fmt)
|
||||
} catch (e) { /* offline / blocked — the link keeps its plain label */ }
|
||||
})()
|
||||
|
||||
/* -------------------------------------------------------------- about timeline
|
||||
Built from the published GitLab releases, so the page updates itself with every
|
||||
release. The static entries marked data-fallback stay in place when the API is
|
||||
|
||||
+7
-9
@@ -159,8 +159,8 @@ nav {
|
||||
transition: color .2s var(--ease);
|
||||
}
|
||||
.nav-quick .ql:hover { color: var(--fg); text-decoration: none; }
|
||||
.nav-quick .ql [data-gh] { font-variant-numeric: tabular-nums; color: var(--fg-3); }
|
||||
.nav-quick .ql:hover [data-gh] { color: var(--fg-2); }
|
||||
.nav-quick .ql [data-gh], .nav-quick .ql [data-dc] { font-variant-numeric: tabular-nums; color: var(--fg-3); }
|
||||
.nav-quick .ql:hover [data-gh], .nav-quick .ql:hover [data-dc] { color: var(--fg-2); }
|
||||
.nav-quick .cta {
|
||||
color: var(--acc-ink); background: var(--acc); font-weight: 600; font-size: 14px;
|
||||
padding: 7px 15px; border-radius: 999px;
|
||||
@@ -228,7 +228,7 @@ body.menu-open .navsheet {
|
||||
.navsheet .nl:last-of-type { border-bottom: 0; }
|
||||
.navsheet .nl:hover { text-decoration: none; background: rgba(255, 255, 255, .05); }
|
||||
.navsheet .nl[aria-current="page"] { color: var(--acc); }
|
||||
.navsheet .nl [data-gh] { color: var(--fg-3); font-size: 14px; font-variant-numeric: tabular-nums; }
|
||||
.navsheet .nl [data-gh], .navsheet .nl [data-dc] { color: var(--fg-3); font-size: 14px; font-variant-numeric: tabular-nums; }
|
||||
/* No second Download button in here: the bar keeps its own at every width, a
|
||||
finger-width above, and two identical green calls to action is one too many. */
|
||||
|
||||
@@ -586,7 +586,7 @@ section { padding: var(--sec) 0 0; }
|
||||
/* The 1px gap is the divider: the panel background shows through between cells, so
|
||||
the rules land correctly however many columns the grid resolves to. */
|
||||
.spec-cells {
|
||||
display: grid; grid-template-columns: repeat(5, 1fr);
|
||||
display: grid; grid-template-columns: repeat(6, 1fr);
|
||||
gap: 1px; background: var(--hair-soft);
|
||||
}
|
||||
.spec-cells > div {
|
||||
@@ -598,11 +598,9 @@ section { padding: var(--sec) 0 0; }
|
||||
letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.1;
|
||||
}
|
||||
.spec-cells span { color: var(--fg-3); font-size: 13.5px; }
|
||||
@media (max-width: 760px) {
|
||||
.spec-cells { grid-template-columns: repeat(2, 1fr); }
|
||||
/* Five cells over two columns leaves a hole; the last one takes the whole row. */
|
||||
.spec-cells > div:last-child { grid-column: 1 / -1; }
|
||||
}
|
||||
/* Six across is too thin to read before the layout is wide; three, then two. */
|
||||
@media (max-width: 1000px) { .spec-cells { grid-template-columns: repeat(3, 1fr); } }
|
||||
@media (max-width: 620px) { .spec-cells { grid-template-columns: repeat(2, 1fr); } }
|
||||
|
||||
/* ------------------------------------------------------------- the link quad
|
||||
Four places openGym lives, as one block of four. Each pad is the whole link, so
|
||||
|
||||
Reference in new issue
Block a user