Skip to content

Commit fd6dfbb

Browse files
committed
Init again
1 parent 72db845 commit fd6dfbb

7 files changed

Lines changed: 399 additions & 112 deletions

File tree

‎README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ GitHub API ──► scripts/build.py ──► index.html
2020
| File | Role | Edit? |
2121
| --- | --- | --- |
2222
| `scripts/build.py` | Fetches `/orgs/<org>` + `/orgs/<org>/repos`, renders HTML. | rarely |
23+
| `scripts/make_logo.py` | Turns `pythonbackportlogo.png` into the transparent `logo.png`. | rarely |
2324
| `templates/index.template.html` | Static HTML shell with `{{projects}}`, `{{site_title}}`, `{{site_tagline}}`. | yes |
2425
| `index.html` | Generated. Do not edit by hand. | no |
26+
| `logo.png` | Generated from `pythonbackportlogo.png`. Do not edit by hand. | no |
2527
| `.github/workflows/refresh.yml` | Daily cron + on-push regeneration, auto-commits the rebuilt index. | rarely |
2628

2729
## Local
@@ -31,10 +33,20 @@ python scripts/build.py # full build against live API
3133
python scripts/build.py --check # CI guard: fail if index.html is stale
3234
python scripts/build.py --stdout # print HTML to stdout
3335
python scripts/build.py --org foo # fetch a different org
36+
python scripts/make_logo.py # regenerate logo.png from the artwork
3437
```
3538

3639
`GH_TOKEN` (or `GITHUB_TOKEN`) raises the API limit from 60/h to 5,000/h.
3740

41+
## Branding
42+
43+
`pythonbackportlogo.png` is the source artwork: a flat blue-and-yellow mark on
44+
an opaque white background. The site is dark themed, so the raw file would
45+
render as a bright white rectangle. `scripts/make_logo.py` removes the white
46+
backdrop (recovering true per-pixel alpha by un-mixing each shape against its
47+
brand colour), crops the transparent margin, and writes `logo.png`. Both the
48+
standard library and the favicon use that generated file.
49+
3850
## Classification
3951

4052
The script buckets each fetched repo into one of two sections based on
@@ -48,6 +60,14 @@ The repo that hosts this very website is auto-detected and excluded
4860
by name match (`website`, `.github`, anything equal to the org login)
4961
or by description / topics containing `website` or `github-pages`.
5062

63+
## Community link
64+
65+
GitHub Discussions is not enabled for this org — the org-level page answers
66+
`404` and the `community` repo is archived — so the community call-to-action
67+
points at the Discord invite instead. The invite is the `DISCORD_INVITE`
68+
constant in `scripts/build.py`, which means the daily refresh workflow can
69+
never silently revert it to a dead GitHub Discussions link.
70+
5171
## Automatic refresh
5272

5373
`.github/workflows/refresh.yml` runs daily at 06:13 UTC and rebuilds

‎index.html‎

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<meta name="description" content="An organization for backporting Python's new features">
77
<meta name="theme-color" content="#0d1117">
88
<title>Python Backport Developers</title>
9-
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%230d1117'/%3E%3Cpath d='M30.5 12c-9 0-15 5.5-15 12.5 0 4.4 2.4 7.7 6.4 9.7l-2 6.4c-.2.7.5 1.3 1.1.9l7.4-4.7c1 .1 1.7.2 2.6.2 9 0 15-5.5 15-12.5S39.5 12 30.5 12zm-5.6 9.6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm11.2 0c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z' fill='%23FFD43B'/%3E%3Cpath d='M44 32v2c0 1.5-.3 2.9-.9 4.2l2.3 5.4c.2.6-.4 1.1-.9.8l-5.5-2.7C36.5 42.7 33.7 43 31 43c-1 0-1.9-.1-2.8-.3l2.3-1.5c.2 0 .4.1.5.1 6.4 0 11.3-3.5 11.3-8.7 0-.2 0-.4-.1-.6h1.8zM45.6 28c-.8 0-1.5-.7-1.5-1.5s.7-1.5 1.5-1.5 1.5.7 1.5 1.5-.7 1.5-1.5 1.5z' fill='%233572A5'/%3E%3C/svg%3E">
9+
<link rel="icon" type="image/png" href="logo.png">
10+
<link rel="apple-touch-icon" href="logo.png">
1011
<link rel="preconnect" href="https://fonts.googleapis.com">
1112
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1213
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
@@ -83,12 +84,13 @@
8384
}
8485
.nav-brand:hover { color: var(--text); }
8586
.nav-brand .logo {
86-
width: 30px; height: 30px;
87-
background: var(--gradient-1);
88-
border-radius: 8px;
87+
width: 32px; height: 32px;
8988
display: grid; place-items: center;
90-
font-size: 16px;
91-
box-shadow: 0 2px 10px rgba(53, 114, 165, 0.4);
89+
}
90+
.nav-brand .logo img {
91+
width: 100%; height: 100%;
92+
object-fit: contain;
93+
display: block;
9294
}
9395
.nav-links { display: flex; gap: 4px; list-style: none; }
9496
.nav-links a {
@@ -101,6 +103,14 @@
101103
@media (max-width: 720px) { .nav-links { display: none; } }
102104
/* ===== Hero ===== */
103105
.hero { position: relative; padding: 120px 0 100px; text-align: center; }
106+
.hero-logo {
107+
width: 120px; height: 108px;
108+
object-fit: contain;
109+
display: block;
110+
margin: 0 auto 28px;
111+
filter: drop-shadow(0 8px 30px rgba(88, 166, 255, 0.25));
112+
animation: fadeUp 0.6s ease;
113+
}
104114
.hero-badge {
105115
display: inline-flex; align-items: center; gap: 8px;
106116
padding: 6px 14px;
@@ -462,7 +472,7 @@
462472
<nav class="nav">
463473
<div class="container nav-inner">
464474
<a href="#" class="nav-brand">
465-
<span class="logo">🐍</span>
475+
<span class="logo"><img src="logo.png" alt="pythonbackport logo" width="32" height="32"></span>
466476
<span>pythonbackport</span>
467477
</a>
468478
<ul class="nav-links">
@@ -476,6 +486,7 @@
476486

477487
<header class="hero">
478488
<div class="container">
489+
<img class="hero-logo" src="logo.png" alt="pythonbackport logo" width="120" height="108">
479490
<div class="hero-badge">
480491
<span class="dot"></span>
481492
<span>Open source · Backporting Python's future</span>
@@ -491,9 +502,9 @@ <h1 class="hero-title">
491502
<span>Explore our projects</span>
492503
<span>→</span>
493504
</a>
494-
<a href="https://github.com/pythonbackport" target="_blank" rel="noopener" class="btn btn-ghost">
495-
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2.1c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1.1-.7.1-.7.1-.7 1.2.1 1.9 1.3 1.9 1.3 1.1 1.9 2.9 1.4 3.6 1 .1-.8.4-1.4.8-1.7-2.7-.3-5.5-1.3-5.5-6 0-1.3.5-2.4 1.3-3.2-.1-.4-.6-1.6.1-3.3 0 0 1-.3 3.3 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.7 1.7.2 2.9.1 3.3.8.8 1.3 1.9 1.3 3.2 0 4.6-2.8 5.6-5.5 5.9.4.4.8 1.1.8 2.2v3.3c0 .3.2.7.8.6A12 12 0 0 0 12 .3"/></svg>
496-
<span>Star on GitHub</span>
505+
<a href="https://discord.gg/kThZX7bfP" target="_blank" rel="noopener" class="btn btn-ghost">
506+
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.369a19.79 19.79 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.249a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.058a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.1 13.1 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.009c.239.18.5.308.78.416a.077.077 0 0 1-.006.127 12.3 12.3 0 0 1-1.876.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.84 19.84 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.028zM8.02 15.331c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418Z"/></svg>
507+
<span>Join the Discord</span>
497508
</a>
498509
</div>
499510

@@ -505,35 +516,23 @@ <h1 class="hero-title">
505516
<span class="terminal-title">~/backport — zsh</span>
506517
</div>
507518
<div class="terminal-body">
508-
<div><span class="term-prompt">$</span> <span class="term-cmd">pip install</span> <span class="term-str">python-profiling</span></div>
509-
<div><span class="term-out">Successfully installed python-profiling-1.0.0</span></div>
510-
<div><span class="term-prompt">$</span> <span class="term-cmd">python -m profiling.sampling run</span> <span class="term-key">--flamegraph</span> app.py</div>
511-
<div><span class="term-comment"># profiling backported from Python 3.15 → works on 3.14 ✨</span></div>
512-
<div><span class="term-prompt">$</span> <span class="term-cmd">cat</span> profile.html <span class="term-out">| open</span></div>
519+
<div><span class="term-prompt">$</span> <span class="term-cmd">pip install</span> <span class="term-str">python-lazyimports</span></div>
520+
<div><span class="term-out">Successfully installed python-lazyimports-1.0.0</span></div>
521+
<div><span class="term-prompt">$</span> <span class="term-cmd">python -c</span> <span class="term-key">"from lazyimports import lazy_import"</span></div>
522+
<div><span class="term-comment"># lazy imports backported from Python 3.15 → works on 3.14 ✨</span></div>
523+
<div><span class="term-prompt">$</span> <span class="term-cmd">cat</span> README.md <span class="term-out">| less</span></div>
513524
</div>
514525
</div>
515526
</div>
516527
</header>
517528

529+
518530
<section class="stats">
519531
<div class="container">
520532
<div class="stats-grid reveal">
521-
<div>
522-
<div class="stat-num">7+</div>
523-
<div class="stat-label">Active Projects</div>
524-
</div>
525-
<div>
526-
<div class="stat-num">3.14</div>
527-
<div class="stat-label">Lowest Supported</div>
528-
</div>
529-
<div>
530-
<div class="stat-num">100%</div>
531-
<div class="stat-label">Open Source</div>
532-
</div>
533-
<div>
534-
<div class="stat-num">∞</div>
535-
<div class="stat-label">Backports &amp; Love</div>
536-
</div>
533+
<div><div class="stat-num">4</div><div class="stat-label">Projects</div></div>
534+
<div><div class="stat-num">3.15</div><div class="stat-label">Newest Backport</div></div>
535+
<div><div class="stat-num">100%</div><div class="stat-label">Open Source</div></div>
537536
</div>
538537
</div>
539538
</section>
@@ -599,8 +598,8 @@ <h2>Join the backport movement 🐍</h2>
599598
tomorrow's Python to yesterday's interpreters.
600599
</p>
601600
<div class="cta-actions">
602-
<a href="" target="_blank" rel="noopener" class="btn btn-primary">
603-
<span>Join discussions</span>
601+
<a href="https://discord.gg/kThZX7bfP" target="_blank" rel="noopener" class="btn btn-primary">
602+
<span>Join the Discord</span>
604603
</a>
605604
<a href="https://github.com/pythonbackport" target="_blank" rel="noopener" class="btn btn-ghost">
606605
<span>Follow the org</span>
@@ -617,7 +616,7 @@ <h2>Join the backport movement 🐍</h2>
617616
</div>
618617
<div class="footer-links">
619618
<a href="https://github.com/pythonbackport" target="_blank" rel="noopener">GitHub</a>
620-
619+
<a href="https://discord.gg/kThZX7bfP" target="_blank" rel="noopener">Discord</a>
621620
<a href="LICENSE">License</a>
622621
</div>
623622
</div>

‎logo.png‎

29.2 KB
Loading

‎pythonbackportlogo.png‎

111 KB
Loading

‎scripts/build.py‎

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949

5050
DEFAULT_ORG = "pythonbackport"
5151

52+
# The community hub lives on Discord. GitHub Discussions is disabled for this
53+
# org (the org-level page answers 404 and the `community` repo is archived),
54+
# so the invite is a constant rather than a URL probed at build time.
55+
DISCORD_INVITE = "https://discord.gg/kThZX7bfP"
56+
57+
5258

5359
# ---------- HTTP ------------------------------------------------------------
5460

@@ -230,6 +236,7 @@ def render_category(cat_key: str, repos: list[dict]) -> str:
230236
</section>"""
231237

232238

239+
233240
def render_marquee(repos: list[dict]) -> str:
234241
items: list[str] = []
235242
for r in repos:
@@ -268,10 +275,31 @@ def render_marquee(repos: list[dict]) -> str:
268275
</section>"""
269276

270277

278+
def _python_versions(repos: list[dict]) -> list[str]:
279+
"""Collect the CPython versions the backports target.
280+
281+
Repos tag the version they backport in their topics, either as
282+
``python315`` or ``python3.15``. Both forms are normalised to ``3.15``.
283+
"""
284+
versions: set[str] = set()
285+
for r in repos:
286+
for t in (r.get("topics") or []):
287+
if not isinstance(t, str):
288+
continue
289+
m = re.fullmatch(r"python3\.?(\d{2})", t, re.IGNORECASE)
290+
if m:
291+
versions.add(f"3.{int(m.group(1))}")
292+
return sorted(versions, key=lambda v: tuple(int(p) for p in v.split(".")))
293+
294+
271295
def render_stats(repos: list[dict]) -> str:
272296
items: list[tuple[str, str]] = []
273297
if repos:
274-
items.append((f"{len(repos)}+", "Active Projects"))
298+
items.append((f"{len(repos)}", "Projects"))
299+
versions = _python_versions(repos)
300+
if versions:
301+
items.append((versions[-1], "Newest Backport"))
302+
items.append(("100%", "Open Source"))
275303
if not items:
276304
return ""
277305
cells = "\n".join(
@@ -288,6 +316,7 @@ def render_stats(repos: list[dict]) -> str:
288316
</section>"""
289317

290318

319+
291320
# ---------- Pipeline --------------------------------------------------------
292321

293322
def build_site(org: str, token: str | None) -> tuple[dict, list[tuple[str, list[dict]]]]:
@@ -309,38 +338,6 @@ def build_site(org: str, token: str | None) -> tuple[dict, list[tuple[str, list[
309338
return org_meta, ordered
310339

311340

312-
def detect_community_url(org_login: str, categorized: list[tuple[str, list[dict]]], token: str | None) -> str | None:
313-
"""Pick the right 'community' destination.
314-
315-
Order of preference:
316-
1. org-level GitHub Discussions is actually reachable
317-
(probe by HEAD request, not by the org API field, which lags).
318-
2. a repo was bucketed into 'community' -> that repo's html_url.
319-
3. None (caller should drop the link).
320-
"""
321-
disc_url = f"https://github.com/orgs/{org_login}/discussions"
322-
try:
323-
head = urllib.request.Request(disc_url, method="HEAD", headers={
324-
"User-Agent": USER_AGENT,
325-
"Accept": "text/html",
326-
})
327-
if token:
328-
head.add_header("Authorization", f"Bearer {token}")
329-
with urllib.request.urlopen(head, timeout=15) as resp:
330-
# The GitHub discussions page returns 200 when enabled.
331-
if resp.status == 200:
332-
return disc_url
333-
except (urllib.error.HTTPError, urllib.error.URLError, TimeoutError, OSError):
334-
pass
335-
336-
for cat_key, items in categorized:
337-
if cat_key == "community" and items:
338-
url = items[0].get("html_url")
339-
if isinstance(url, str) and url:
340-
return url
341-
return None
342-
343-
344341
def first_section_anchor(categorized: list[tuple[str, list[dict]]]) -> str | None:
345342
"""Anchor of the first category section that actually renders."""
346343
for cat_key, _ in categorized:
@@ -357,15 +354,14 @@ def assemble(org_meta: dict, categorized: list[tuple[str, list[dict]]], token: s
357354

358355
title = org_meta.get("name") or org_meta.get("login") or ""
359356
tagline = org_meta.get("description") or ""
360-
org_login = org_meta.get("login") or ""
361357

362358
section_blocks = [render_category(k, items) for k, items in categorized]
363359
projects_html = "\n".join(b for b in section_blocks if b)
364360
stats_html = render_stats(all_repos)
365361
marquee_html = render_marquee(all_repos)
366362

367363
cta_href = first_section_anchor(categorized) or "#"
368-
community_url = detect_community_url(org_login, categorized, token)
364+
community_url = DISCORD_INVITE
369365

370366
tpl = tpl.replace("{{site_title}}", esc(title))
371367
tpl = tpl.replace("{{site_tagline}}", esc(tagline))
@@ -378,12 +374,11 @@ def assemble(org_meta: dict, categorized: list[tuple[str, list[dict]]], token: s
378374
if ph in tpl:
379375
tpl = tpl.replace(ph, body)
380376

381-
# If there is no community destination at all, strip the placeholder
382-
# anchors (left as empty href) by removing the whole CTA / footer
383-
# community link if its href is empty.
377+
# Safety net: if there is no community destination at all, drop the
378+
# community links rather than shipping an empty href.
384379
if not community_url:
385380
tpl = re.sub(
386-
r'<a href="" target="_blank"[^>]*>(?:<span>)?(?:Join discussions|Discussions)(?:</span>)?</a>',
381+
r'<a href="" target="_blank"[^>]*>(?:<span>)?(?:Join the Discord|Discord)(?:</span>)?</a>',
387382
"",
388383
tpl,
389384
)

0 commit comments

Comments
 (0)