Skip to content

Commit dc19c99

Browse files
Refresh PythonIDE branding across the link site and share cards
1 parent 2bc9cbe commit dc19c99

10 files changed

Lines changed: 65 additions & 31 deletions

File tree

‎404.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<html lang="zh-CN">
33
<head>
44
<meta charset="utf-8">
5+
<link rel="icon" href="/assets/brand-mark.svg" type="image/svg+xml">
56
<meta name="viewport" content="width=device-width, initial-scale=1">
67
<meta name="theme-color" content="#f7f7f8">
78
<meta property="og:site_name" content="Python IDE">
89
<meta property="og:title" content="Python IDE 社区作品">
910
<meta property="og:description" content="在 Python IDE 中查看、运行和导入社区作品。">
10-
<meta property="og:image" content="https://link.pythonide.xin/assets/app-icon.png">
11+
<meta property="og:image" content="https://link.pythonide.xin/assets/app-icon.png?v=2">
1112
<script>
1213
(function () {
1314
var path = location.pathname + location.search + location.hash;

‎ai-oauth/callback/index.html‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="zh-CN">
33
<head>
44
<meta charset="utf-8">
5+
<link rel="icon" href="/assets/brand-mark.svg" type="image/svg+xml">
56
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
67
<meta name="referrer" content="no-referrer">
78
<meta name="robots" content="noindex, nofollow">
@@ -149,11 +150,7 @@
149150
<body data-state="returning">
150151
<header class="site-header">
151152
<div class="brand" aria-label="PythonIDE">
152-
<svg class="brand-mark" viewBox="60 100 904 824" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
153-
<circle cx="826" cy="512" r="116" fill="#E8AA24"/><circle cx="669" cy="240" r="116" fill="#1F5F95"/>
154-
<circle cx="355" cy="240" r="116" fill="#1F5F95"/><circle cx="198" cy="512" r="116" fill="#1F5F95"/>
155-
<circle cx="355" cy="784" r="116" fill="#1F5F95"/><circle cx="669" cy="784" r="116" fill="#1F5F95"/>
156-
</svg>
153+
<img class="brand-mark" src="/assets/brand-mark.svg" width="28" height="28" alt="">
157154
<span>PythonIDE</span>
158155
</div>
159156
</header>

‎assets/app-icon.png‎

76 KB
Loading

‎assets/brand-mark.svg‎

Lines changed: 35 additions & 7 deletions
Loading

‎assets/share-page.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const SITE_ORIGIN = 'https://link.pythonide.xin';
77
const DEFAULT_TITLE = 'Python IDE 社区作品';
88
const DEFAULT_DESCRIPTION = '在 Python IDE 中查看、运行和导入社区作品。';
9-
const DEFAULT_SHARE_IMAGE = `${SITE_ORIGIN}/assets/app-icon.png`;
9+
const DEFAULT_SHARE_IMAGE = `${SITE_ORIGIN}/assets/app-icon.png?v=2`;
1010

1111
const CATEGORY_LABELS = {
1212
python: 'Python',

‎edge/default-brand-icon.js‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎edge/runtime-tests/github-oauth-workerd.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { Miniflare, convertV4MiniflareOptions } = require(process.env.PYTHONIDE_M
1111
const runtime = (options) => new Miniflare(convertV4MiniflareOptions(options));
1212
const root = process.env.PYTHONIDE_WORKERD_SOURCE_ROOT
1313
|| fileURLToPath(new URL('../', import.meta.url));
14-
const modules = ['worker.js', 'github-oauth.js', 'github-oauth-rate-limit.js']
14+
const modules = ['worker.js', 'github-oauth.js', 'github-oauth-rate-limit.js', 'default-brand-icon.js']
1515
.map((name) => ({ type: 'ESModule', path: path.join(root, name) }));
1616
const origin = 'https://link.pythonide.xin';
1717
const headers = { 'Content-Type': 'application/json', 'CF-Connecting-IP': '192.0.2.25' };

‎edge/worker.js‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { handleGitHubOAuth } from './github-oauth.js';
2+
import { BRAND_ICON_PIXELS, BRAND_ICON_REVISION, BRAND_ICON_SIZE } from './default-brand-icon.js';
23

34
const COMMUNITY_API_BASE = 'https://community-api.pythonide.xin/v2/community';
45
const SITE_ORIGIN = 'https://link.pythonide.xin';
56
const DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/Python-IDE/pythonide-link/main/index.html';
6-
const DEFAULT_IMAGE = `${SITE_ORIGIN}/assets/app-icon.png`;
7+
const DEFAULT_IMAGE = `${SITE_ORIGIN}/assets/app-icon.png?v=${BRAND_ICON_REVISION}`;
8+
const brandPixels = Uint8Array.from(atob(BRAND_ICON_PIXELS), (character) => character.charCodeAt(0));
79
const DEFAULT_TITLE = 'Python IDE 社区作品';
810
const DEFAULT_DESCRIPTION = '在 Python IDE 中查看、运行和导入社区作品。';
911
const AASA_DOCUMENT = {
@@ -180,7 +182,7 @@ function shareRevision(script, scriptId = '') {
180182
script?.revision || script?.updatedAt || script?.content_hash || script?.updated_at
181183
|| script?.approved_at || script?.version || scriptId || 'preview',
182184
);
183-
return stableHash(source).toString(36);
185+
return stableHash(`${source}:${BRAND_ICON_REVISION}`).toString(36);
184186
}
185187

186188
function socialPayload(script, scriptId, origin = SITE_ORIGIN) {
@@ -445,10 +447,18 @@ function stableHash(value) {
445447
}
446448

447449
function drawBrand(target) {
448-
const blue = '#1f5f95';
449-
const yellow = '#e8aa24';
450-
const points = [[86,61],[108,61],[119,80],[108,99],[86,99],[75,80]];
451-
points.forEach(([x, y], index) => fillCircle(target, x, y, 8, index === 2 ? yellow : blue));
450+
for (let row = 0; row < BRAND_ICON_SIZE; row += 1) {
451+
for (let column = 0; column < BRAND_ICON_SIZE; column += 1) {
452+
const source = (row * BRAND_ICON_SIZE + column) * 4;
453+
const destination = ((row + 48) * target.width + column + 68) * 4;
454+
const remaining = 1 - brandPixels[source + 3] / 255;
455+
for (let channel = 0; channel < 3; channel += 1) {
456+
target.pixels[destination + channel] = Math.min(255, Math.round(
457+
brandPixels[source + channel] + target.pixels[destination + channel] * remaining,
458+
));
459+
}
460+
}
461+
}
452462
drawText(target, 'PYTHON IDE', 145, 62, 4, '#0d0d0d', 12);
453463
}
454464

‎index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<meta property="og:title" content="Python IDE 社区作品">
1313
<meta property="og:description" content="在 Python IDE 中查看、运行和导入社区作品。">
1414
<meta property="og:url" content="https://link.pythonide.xin/">
15-
<meta property="og:image" content="https://link.pythonide.xin/assets/app-icon.png">
15+
<meta property="og:image" content="https://link.pythonide.xin/assets/app-icon.png?v=2">
1616
<meta property="og:image:width" content="1024">
1717
<meta property="og:image:height" content="1024">
1818
<meta name="twitter:card" content="summary">
1919
<meta name="twitter:title" content="Python IDE 社区作品">
2020
<meta name="twitter:description" content="在 Python IDE 中查看、运行和导入社区作品。">
21-
<meta name="twitter:image" content="https://link.pythonide.xin/assets/app-icon.png">
21+
<meta name="twitter:image" content="https://link.pythonide.xin/assets/app-icon.png?v=2">
2222
<link rel="canonical" href="https://link.pythonide.xin/">
2323
<!-- edge:meta-end -->
2424
<link rel="icon" href="/assets/brand-mark.svg" type="image/svg+xml">

‎mcp-oauth/callback/index.html‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="zh-CN">
33
<head>
44
<meta charset="utf-8">
5+
<link rel="icon" href="/assets/brand-mark.svg" type="image/svg+xml">
56
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
67
<meta name="referrer" content="no-referrer">
78
<meta name="robots" content="noindex, nofollow">
@@ -373,14 +374,7 @@
373374
<body data-state="returning">
374375
<header class="site-header">
375376
<div class="brand" aria-label="PythonIDE">
376-
<svg class="brand-mark" viewBox="60 100 904 824" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
377-
<circle cx="826" cy="512" r="116" fill="#E8AA24"/>
378-
<circle cx="669" cy="240" r="116" fill="#1F5F95"/>
379-
<circle cx="355" cy="240" r="116" fill="#1F5F95"/>
380-
<circle cx="198" cy="512" r="116" fill="#1F5F95"/>
381-
<circle cx="355" cy="784" r="116" fill="#1F5F95"/>
382-
<circle cx="669" cy="784" r="116" fill="#1F5F95"/>
383-
</svg>
377+
<img class="brand-mark" src="/assets/brand-mark.svg" width="28" height="28" alt="">
384378
<span>PythonIDE</span>
385379
</div>
386380
</header>

0 commit comments

Comments
 (0)