Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/bub/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions evaluation/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions tests/e2e/test_homepage_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@
from collections.abc import Iterator
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from importlib import import_module
from pathlib import Path
from threading import Thread

import pytest

REQUIRED = os.environ.get("POWERCONTEXT_TEST_HOMEPAGE_BROWSER") == "1"
if REQUIRED:
from playwright import sync_api as playwright
else:
playwright = pytest.importorskip("playwright.sync_api")
playwright = import_module("playwright.sync_api") if REQUIRED else pytest.importorskip("playwright.sync_api")


@pytest.fixture(scope="module")
Expand Down
4 changes: 4 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ next-env.d.ts
*.tsbuildinfo

content/blog
public/contributor-art/social/
public/contributor-art/*.svg
public/contributor-art/avatars/
public/contributor-art/lucide-LICENSE.txt
3 changes: 2 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "pnpm test && pnpm check:links && next build --webpack && tsx scripts/redirect-docs.ts && pnpm verify:export",
"check:links": "pnpm test:links && pnpm generate && tsx scripts/validate-links.ts",
"test:links": "tsx --test tests/link-validation.test.ts",
"generate": "tsx scripts/generate-content.ts && tsx scripts/generate-blog.ts",
"generate": "tsx scripts/generate-content.ts && tsx scripts/generate-blog.ts && tsx scripts/generate-contributor-art.ts && tsx scripts/generate-contributor-images.tsx",
"preview": "serve out",
"test": "node --import tsx --test tests/*.test.ts",
"types:check": "next typegen && tsc --noEmit",
Expand Down Expand Up @@ -42,6 +42,7 @@
"oxlint": "1.80.0",
"postcss": "8.5.23",
"serve": "14.2.6",
"sharp": "0.35.5",
"shiki": "4.4.0",
"tailwindcss": "4.3.3",
"tsx": "4.23.1",
Expand Down
3 changes: 3 additions & 0 deletions website/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/scripts/contributor-art/braces.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions website/scripts/generate-contributor-art.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2026 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import * as lucide from 'lucide-react';
import type { LucideIcon } from 'lucide-react';
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import sharp from 'sharp';
import { readPeople } from '../src/data/contributors/snapshot';

const people = readPeople();

const tools: Record<string, string> = {
join: 'M87 23 C104 20 98 40 100 49 Q100 56 109 60 Q99 65 100 72 C104 87 103 96 90 96',
inspect: 'M81 64 L97 78 M84 47 C86 69 49 77 44 52 C39 27 80 20 84 47Z M51 46 Q53 38 61 37',
write: 'M64 73 L88 32 Q91 28 96 33 L100 37 L76 76 L62 81Z M85 38 L96 45',
type: 'M39 60 L46 54 L39 49 M73 64 L83 63',
wire: 'M70 50 L78 49 L78 44 L91 44 L92 62 L79 62 L79 57 L70 57 M92 53 Q114 52 108 72',
print: 'M53 39 L82 30 Q87 31 88 40 L57 49Z M86 35 L93 33 L98 46 L88 55 L92 65',
measure: 'M68 65 L87 43 M76 43 L88 40 L90 51',
file: 'M47 53 L43 34 L74 25 L84 54 M53 40 L68 36',
};
const eyes = [
'M-8 0l2 -1 M5 -1l2 -1',
'M-9 0q2 -4 5 -2 M5 -2q2 -4 5 -2',
'M-9 -2l3 1 M5 -3l2 -1',
'M-9 -1l1 1 M5 -3q3 -2 5 0',
];
const mouths = ['M-3 7q4 4 9 -2', 'M-3 6q5 6 10 -2', 'M-1 7q4 1 6 -2'];
const folder = 'public/contributor-art';

async function illustration(person: (typeof people)[number]) {
if (person.motif === 'braces') return readFile('scripts/contributor-art/braces.svg', 'utf8');
const name = person.motif
.split('-')
.map((word) => word[0].toUpperCase() + word.slice(1))
.join('');
const icon = lucide[name as keyof typeof lucide] as LucideIcon | undefined;
if (!icon || !tools[person.gesture ?? '']) throw new Error('Unknown illustration for ' + person.login);
const shape = renderToStaticMarkup(createElement(icon)).replace(/^<svg[^>]*>|<\/svg>$/g, '');
const serial = Number(person.serial);
const stroke = (d: string, width: number) =>
`<path d="${d}" stroke="#fff5de" stroke-width="${width + 4}"/><path d="${d}" stroke="${person.ink}" stroke-width="${width}"/>`;
return `<svg viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg"><g transform="rotate(${((serial * 7) % 17) - 8} 64 64)" fill="none" stroke-linecap="round" stroke-linejoin="round">
<g transform="translate(24 21) scale(3.25)" stroke="#fff5de" stroke-width="2.05">${shape}</g><g transform="translate(24 21) scale(3.25)" stroke="${person.ink}" stroke-width=".88">${shape}</g>
<g transform="translate(65 88)">${stroke(eyes[serial % 4] + ' ' + mouths[serial % 3], 1.9)}</g><g transform="translate(51 54) scale(.5)"><g class="ink-action">${stroke(tools[person.gesture!], 3.5)}</g></g>
<path d="M100 23 q0 5 5 5 q-5 0 -5 5 q0 -5 -5 -5 q5 0 5 -5" stroke="${person.accent}" stroke-width="1.7"/></g>
<style>@media(prefers-reduced-motion:no-preference){.ink-action{transform-box:fill-box;transform-origin:center;animation:work 3s ease-in-out infinite}}@keyframes work{50%{transform:translate(-3px,2px) rotate(-4deg)}}</style></svg>`;
}

async function fetchAvatar(id: number) {
const url = `https://avatars.githubusercontent.com/u/${id}?s=144`;
for (let attempt = 1; ; attempt++) {
try {
const response = await fetch(url, { signal: AbortSignal.timeout(20000) });
if (!response.ok) throw new Error(`GitHub avatar ${id}: HTTP ${response.status}`);
return await sharp(Buffer.from(await response.arrayBuffer()))
.resize(144, 144)
.webp({ quality: 84 })
.toBuffer();
} catch (error) {
if (attempt === 3) throw error;
await new Promise((resolve) => setTimeout(resolve, 500 * attempt));
}
}
}

async function generate(person: (typeof people)[number]) {
await writeFile(path.join(folder, person.motif + '.svg'), await illustration(person));
if (!person.avatarId) return;
const output = path.join(folder, 'avatars', person.serial + '.webp');
// Reuse a verified identity's cached thumbnail across local builds.
const cache = path.join('.generated', 'contributor-avatars', person.avatarId + '.webp');
let thumbnail: Buffer;
try {
thumbnail = await readFile(cache);
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
thumbnail = await fetchAvatar(person.avatarId);
await writeFile(cache, thumbnail);
}
await writeFile(output, thumbnail);
}

await mkdir(path.join(folder, 'avatars'), { recursive: true });
await copyFile('node_modules/lucide-react/LICENSE', path.join(folder, 'lucide-LICENSE.txt'));
await mkdir('.generated/contributor-avatars', { recursive: true });
for (let start = 0; start < people.length; start += 8) {
await Promise.all(people.slice(start, start + 8).map(generate));
}
47 changes: 47 additions & 0 deletions website/scripts/generate-contributor-images.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2026 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { mkdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { renderToStaticMarkup } from 'react-dom/server';
import sharp from 'sharp';
import { CardFace } from '../src/components/contributors/card-face';
import { contributors } from '../src/lib/contributors';
import { basePath } from '../src/lib/urls';

const folder = path.resolve('public/contributor-art/social');

const embedded = new Map<string, string>();
for (const lang of ['en', 'zh'] as const) {
await mkdir(path.join(folder, lang), { recursive: true });
for (const person of contributors) {
let svg = renderToStaticMarkup(<CardFace person={person} lang={lang} />);
for (const [, href] of svg.matchAll(/\bhref="([^"]+)"/g)) {
if (!embedded.has(href)) {
const asset = path.join('public', href.slice(basePath.length));
const mime = asset.endsWith('.svg')
? 'image/svg+xml'
: asset.endsWith('.webp')
? 'image/webp'
: 'image/png';
embedded.set(href, `data:${mime};base64,${(await readFile(asset)).toString('base64')}`);
}
svg = svg.replaceAll(`href="${href}"`, `href="${embedded.get(href)}"`);
}
const cover = await sharp(Buffer.from(svg)).webp({ quality: 82 }).toBuffer();
await writeFile(path.join(folder, lang, person.serial + '.webp'), cover);
}
}
15 changes: 15 additions & 0 deletions website/scripts/verify-static-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { access, readdir, readFile, stat } from 'node:fs/promises';
import path from 'node:path';
import { contributors } from '../src/lib/contributors';
import { getHomeContent } from '../src/lib/home-content';
import { absoluteSiteUrl, basePath, withBasePath } from '../src/lib/urls';

Expand Down Expand Up @@ -75,6 +76,20 @@ const exportedDocuments = new Map(
htmlFiles.map(async (file) => [routeFromOutputFile(file), await readFile(file, 'utf8')] as const),
),
);
for (const locale of locales) {
for (const { login, serial } of contributors) {
const route = `/${locale}/contributor/${login}`;
const markup = renderedMarkup(exportedDocuments.get(route) ?? '');
const imagePath = `/contributor-art/social/${locale}/${serial}.webp`;
await access(path.join(outputDirectory, imagePath));
if (!markup.includes(`property="og:image" content="${absoluteSiteUrl(imagePath)}"`)) {
throw new Error(`Missing localized share image metadata: ${route}`);
}
if (!markup.includes('id="history"') || !markup.includes(`<h1>${login}</h1>`)) {
throw new Error(`Contributor profile missing from static HTML: ${route}`);
}
}
}
const requiredRoutes = ['/', '/en', '/zh', '/en/docs', '/zh/docs', '/api', '/en/modules', '/zh/modules'];
const missingRequiredRoutes = requiredRoutes.filter((route) => !exportedDocuments.has(route));
const missingRfcRoutes = [...rfcRoutes].filter((route) => !exportedDocuments.has(route));
Expand Down
99 changes: 99 additions & 0 deletions website/src/app/(localized)/[lang]/contributor/[login]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2026 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import Link from 'next/link';
import { notFound } from 'next/navigation';
import { HomeLayout } from 'fumadocs-ui/layouts/home';
import { SiteFooter } from '@/components/site-footer';
import { Card } from '@/components/contributors/card';
import styles from '@/components/contributors/contributors.module.css';
import { evidenceLabel, evidenceUrl, profilePath } from '@/lib/contributor-types';
import { contributors, getContributor } from '@/lib/contributors';
import { isLanguage } from '@/lib/i18n';
import { pageMetadata } from '@/lib/metadata';
import { baseOptions } from '@/lib/site';

type Props = { params: Promise<{ lang: string; login: string }> };
export function generateStaticParams() {
return contributors.map(({ login }) => ({ login }));
}
export async function generateMetadata({ params }: Props) {
const { lang, login } = await params;
const profile = getContributor(login);
if (!isLanguage(lang) || !profile) notFound();
const p = profile.summary;
return pageMetadata({
lang,
path: profilePath(lang, p.login),
title: `${p.login} · ${p.nickname[lang]}`,
description: `${p.role} · No. ${p.serial} · ${p.nickname[lang]}`,
translations: { en: profilePath('en', p.login), zh: profilePath('zh', p.login) },
image: { url: `/contributor-art/social/${lang}/${p.serial}.webp`, alt: p.login },
});
}
export default async function Page({ params }: Props) {
const { lang, login } = await params;
const profile = getContributor(login);
if (!isLanguage(lang) || !profile) notFound();
const { summary: p, history } = profile;
const counts = { issue: 0, pull: 0, commit: 0 };
for (const record of history) counts[record.kind]++;
const zh = lang === 'zh';
return (
<HomeLayout {...baseOptions(lang)}>
<main className={styles.profile}>
<Link className={styles.backlink} href={`/${lang}/contributor/`}>
← {zh ? '全部贡献者' : 'All contributors'}
</Link>
<div className={styles.cardBlock}>
<Card person={p} lang={lang} share />
</div>
<div className={styles.profileHead}>
<div>
<h1>{p.login}</h1>
<small>No. {p.serial}</small>
</div>
{p.github && <a href={'https://github.com/' + encodeURIComponent(p.login)}>GitHub</a>}
</div>
<p>
{p.nickname[lang]} · {zh ? '首次贡献' : 'Since'} {p.since}
</p>
<h2 id="history">{zh ? '贡献记录' : 'Contributions'}</h2>
<p>
{[
counts.issue && `${counts.issue} Issues`,
counts.pull && `${counts.pull} PRs`,
counts.commit && `${counts.commit} Commits`,
]
.filter(Boolean)
.join(' · ')}
</p>
<ol className={styles.history}>
{history.map((r) => (
<li key={r.id}>
<a href={evidenceUrl(r)}>
<code>{evidenceLabel(r)}</code>
<span>{r.title}</span>
<time dateTime={r.date}>{r.date.slice(0, 10)}</time>
</a>
</li>
))}
</ol>
</main>
<SiteFooter lang={lang} />
</HomeLayout>
);
}
Loading