Skip to content
Draft
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
88 changes: 88 additions & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Website

on:
pull_request:
paths:
- 'website/**'
- 'scripts/build-website.sh'
- 'tests/browser/engine.mjs'
- 'docs/guides/assets/dota2-short-film-canvas.jpg'
- 'docs/guides/assets/dota2-short-film.mp4'
- '.github/workflows/website.yml'
push:
branches: [main]
paths:
- 'website/**'
- 'scripts/build-website.sh'
- 'tests/browser/engine.mjs'
- 'docs/guides/assets/dota2-short-film-canvas.jpg'
- 'docs/guides/assets/dota2-short-film.mp4'
- '.github/workflows/website.yml'
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: website-${{ github.ref }}
cancel-in-progress: false

jobs:
refresh-downloads:
if: github.event_name == 'release' && github.repository == 'ThinkFlowLab/OpenDirector' && !github.event.release.prerelease
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Start the Pages build on main
env:
GH_TOKEN: ${{ github.token }}
run: gh api --method POST "repos/$GITHUB_REPOSITORY/actions/workflows/website.yml/dispatches" -f ref=main

build:
if: github.event_name != 'release'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.ref == 'refs/heads/main' && 'main' || github.sha }}
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version-file: .nvmrc
- run: node --test website/installers.test.mjs
- name: Build the website with published downloads
env:
GITHUB_TOKEN: ${{ github.token }}
run: bash scripts/build-website.sh "$RUNNER_TEMP/pages/OpenDirector"
- name: Check the built site in Chromium
run: |
npm install --prefix "$RUNNER_TEMP/browser" --no-save --no-package-lock playwright-core@1.58.2
export PLAYWRIGHT_MODULE="$RUNNER_TEMP/browser/node_modules/playwright-core/index.mjs"
node "$RUNNER_TEMP/browser/node_modules/playwright-core/cli.js" install --with-deps --only-shell chromium
python3 -m http.server 8780 --bind 127.0.0.1 --directory "$RUNNER_TEMP/pages" &
server=$!
trap 'kill "$server"' EXIT
curl -fsS --retry 5 --retry-connrefused http://127.0.0.1:8780/OpenDirector/ -o /dev/null
node website/site.test.mjs
- if: github.repository == 'ThinkFlowLab/OpenDirector' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ${{ runner.temp }}/pages/OpenDirector

deploy:
if: github.repository == 'ThinkFlowLab/OpenDirector' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This directory is the entry point for the repository's shared documentation. The
| [Issue #87 Windows handoff](development/issue-87-windows-handoff.md) ([中文](development/issue-87-windows-handoff.zh-CN.md)) | Native ACL repair and final text acceptance | The shared checkpoint or native validation scope changes |
| [Development lessons](development/lessons.md) | Risks identified from recent fixes | New evidence emerges or a lesson no longer applies |
| [CI failure patterns](development/ci-failures.md) | Known timing-sensitive CI failures and how to tell flakes from regressions | A pattern is fixed, newly observed, or the watchlist changes |
| [Public website](../website/README.md) | Local preview, installer links, and GitHub Pages deployment | Website deployment or installer publishing changes |
| [Release tags and daily cuts](development/release.md) | Public SemVer tags and the daily patch cut | The tag scheme, daily cut gate, or version-field set changes |
| [UI performance design](development/ui-performance.md) | Interaction design principles, latency budgets, and measurement | A UI performance principle, target, or measurement method changes |
| [macOS installation validation](development/macos-install-validation.md) | Installation and usage scenarios verified on Apple Silicon | The corresponding acceptance checks are repeated |
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions scripts/build-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

output=${1:?Usage: bash scripts/build-website.sh OUTPUT_DIRECTORY}
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)

node --check "$root/website/site.mjs"
node --check "$root/website/ambient.mjs"
mkdir -p "$output"
node "$root/website/build.mjs" "$output/index.html"
cp "$root"/website/{site.css,showcase.css,ambient.mjs,site.mjs,logo.png} "$output/"
cp "$root/docs/guides/assets/dota2-short-film-canvas.jpg" "$output/canvas.jpg"
mkdir -p "$output/film"
cp "$root"/website/film/*.jpg "$output/film/"
cp "$root/website/film/office-preview.mp4" "$output/film/"
cp "$root/docs/guides/assets/dota2-short-film.mp4" "$output/film/we-can-still-win.mp4"
55 changes: 55 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# OpenDirector website

[中文](#中文)

## Preview

Run these commands from the repository root. The build reads public GitHub Releases and needs network access. Run `npm ci` first if Vite is missing.

```sh
preview=$(mktemp -d)
bash scripts/build-website.sh "$preview/dist/OpenDirector"
node_modules/.bin/vite preview "$preview" --host 127.0.0.1 --port 8780 --strictPort
```

Open <http://127.0.0.1:8780/OpenDirector/>. Vite supports the byte-range requests the player uses to jump to a shot.

## Set up GitHub Pages

1. In `ThinkFlowLab/OpenDirector`, a repository maintainer or admin opens **Settings > Pages**. Under **Build and deployment**, set **Source** to **GitHub Actions**. The repository supplies the [Website workflow](../.github/workflows/website.yml) and its deployment permissions. It uses GitHub's built-in token.
2. Merge the website changes into `main`. The Website workflow builds the site and runs its Chromium checks. When they pass, the workflow deploys to the `github-pages` environment. Pull requests run the checks only. To deploy the current `main` manually, open **Actions > Website > Run workflow**, select `main`, and click **Run workflow**.
3. Open the URL in the successful `deploy` job. The default address is <https://thinkflowlab.github.io/OpenDirector/>. Switch languages and check that each download points to the expected Release asset. To roll back a site change, revert it on `main`.

## Publish a desktop release

1. Follow the [release guide](../docs/development/release.md). Check that Release checks and the latest nightly `gate-parity` passed. After the version-bump PR merges, push a new `vMAJOR.MINOR.PATCH` tag on that merge commit to the official repository. The tag must match the version in `apps/desktop/package.json`.
2. The [Desktop release workflow](../.github/workflows/desktop-release.yml) creates or reuses a draft for that tag. macOS and Windows each build and test their installer, then attach it and its `.sha256` file to the draft. For a release that ships both platforms, expect an Apple Silicon DMG, a Windows x64 EXE, and two checksum files.
3. Complete the [desktop acceptance checks](../docs/development/desktop.md#delivery-boundary) for each platform you plan to publish. In **Releases**, open the draft, verify its assets, review the English release notes, and click **Publish release**. Retry failed packaging jobs while the release is still a draft.
4. Publishing the release triggers a Website build on `main`. For each platform, the build selects the highest official version with an uploaded installer for that architecture. The download URL, version label and release notes come from that release. If you add an installer after publication, run **Actions > Website > Run workflow** on `main` to refresh the site.

A Windows-only release updates the Windows download. Mac users keep the latest available Mac package. Until a platform has an official installer, its download points to the [tested desktop preview](https://github.com/FayeSpica/OpenDirector/releases/tag/v0.1.4-desktop-test.23) and carries a test-build label. If the GitHub API request fails, the build stops and the previous deployment stays online.

OpenDirector includes the version in each installer filename. GitHub's `releases/latest/download/<filename>` looks for that exact file in the repository's latest release. Resolving the assets at build time keeps both downloads usable even when they come from different tags. Updating an installed desktop app is tracked in [#367](https://github.com/ThinkFlowLab/OpenDirector/issues/367).

## 中文

### 本地预览

在仓库根目录运行上面的命令。构建时需要联网读取公开的 GitHub Releases。如果缺少 Vite,先运行 `npm ci`。打开 <http://127.0.0.1:8780/OpenDirector/>。Vite 支持分段读取视频,可以直接跳到所选镜头。

### 首次配置 GitHub Pages

1. 具有 Maintain 或 Admin 权限的维护者打开官方仓库 `ThinkFlowLab/OpenDirector` 的 **Settings > Pages**,在 **Build and deployment** 中将 **Source** 设为 **GitHub Actions**。仓库提供了 [Website 工作流](../.github/workflows/website.yml),其中已声明部署权限,使用 GitHub 内置令牌。
2. 将网站改动合入 `main`。Website 会构建网站并运行 Chromium 检查,通过后部署到 `github-pages` 环境。PR 只运行检查。需要手动部署时,打开 **Actions > Website > Run workflow**,选择 `main`,点击 **Run workflow**。
3. 打开成功的 `deploy` 任务给出的网址,默认地址是 <https://thinkflowlab.github.io/OpenDirector/>。切换语言,确认两个平台的下载链接指向预期的 Release 附件。如需回退网站,在 `main` 撤销对应改动。

### 发布桌面版

1. 按[版本发布指南](../docs/development/release.md)确认 Release checks 和最近一次 nightly 的 `gate-parity` 均已通过。版本号 PR 合入 `main` 后,在该合入提交上打新的 `vMAJOR.MINOR.PATCH` 标签并推到官方仓库。标签中的版本号须与 `apps/desktop/package.json` 一致。
2. [Desktop release 工作流](../.github/workflows/desktop-release.yml)会为该标签创建或复用 Release 草稿。macOS 和 Windows 各自打包,通过本机安装和启动检查后,把安装包和对应的 `.sha256` 文件上传到同一份草稿。两个平台都发布时,草稿应包含 Apple Silicon DMG、Windows x64 EXE 和两份校验文件。
3. 维护者在各发布平台完成[桌面版验收](../docs/development/desktop.zh-CN.md),再到 **Releases** 打开草稿,核对附件和英文发布说明,点击 **Publish release**。如果打包任务失败,在草稿状态下重跑。
4. 公开 Release 后,Website 会在 `main` 上重新构建。对每个平台,构建脚本选取包含对应架构安装包的最高正式版本,并从该 Release 读取下载地址、版本号和发布说明。如果在公开后补传了安装包,到 **Actions > Website > Run workflow** 选择 `main` 刷新网站即可。

如果本次只发 Windows 包,Windows 下载会更新,Mac 用户仍能下载已有的最新 Mac 包。某个平台首次发布正式安装包前,网站提供[已验证的桌面测试版](https://github.com/FayeSpica/OpenDirector/releases/tag/v0.1.4-desktop-test.23),并标明「测试版」。如果请求 GitHub API 失败,本次构建停止,线上继续使用上一次成功部署的页面。

OpenDirector 的安装包文件名含版本号。GitHub 的 `releases/latest/download/<文件名>` 只在仓库最新 Release 中查找该文件。构建时按平台查找附件,即使两个安装包来自不同标签,也能给出各自的下载地址。已安装桌面应用的升级由 [#367](https://github.com/ThinkFlowLab/OpenDirector/issues/367) 跟进。
116 changes: 116 additions & 0 deletions website/ambient.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const vertexSource = `
attribute vec2 position;
varying vec2 uv;
void main() {
uv = vec2(position.x, -position.y) * .5 + .5;
gl_Position = vec4(position, 0., 1.);
}`;

const fragmentSource = `
precision highp float;
varying vec2 uv;
uniform float phase;

float glow(vec2 p, vec2 center, vec2 radius) {
vec2 d = (p - center) / radius;
return exp(-dot(d, d));
}

float grain(vec2 p) {
return fract(52.9829189 * fract(dot(p, vec2(.06711056, .00583715))));
}

float diffusion(vec2 p) {
vec2 cell = floor(p);
vec2 t = smoothstep(vec2(0.), vec2(1.), fract(p));
return mix(mix(grain(cell), grain(cell + vec2(1., 0.)), t.x),
mix(grain(cell + vec2(0., 1.)), grain(cell + 1.), t.x), t.y);
}

void main() {
vec2 p = uv;
vec2 drift = vec2(cos(phase), sin(phase));
p.y += .11 * sin(5.8 * uv.x - 1.2 + .32 * sin(phase))
+ .045 * sin(11. * uv.x + 2. * uv.y + .7 * cos(phase))
+ .075 * (diffusion(uv * vec2(9., 4.) + .5 * drift) - .5);
p.x += .036 * sin(6. * uv.y + phase);
vec3 light = vec3(.042, .069, .12);
light += glow(p, vec2(.54, .17), vec2(.76, .42)) * vec3(.059, .124, .226);
light += glow(p, vec2(.80, .22), vec2(.43, .32)) * vec3(.072, .081, .125);
light += glow(p, vec2(.78, -.025), vec2(.37, .135)) * vec3(.28, .28, .285);
light += glow(p, vec2(.045, .19), vec2(.27, .19)) * vec3(.105, .057, .129);
light += glow(p, vec2(.018, .15), vec2(.21, .065)) * vec3(.071, .049, .045);
light += glow(p, vec2(.96, .49), vec2(.40, .24)) * vec3(.051, .063, .092);
light += (grain(gl_FragCoord.xy) - .5) / 255.;
gl_FragColor = vec4(light, 1.);
}`;

function paintAmbientLight(canvas) {
const gl = canvas.getContext("webgl", {
alpha: false, antialias: false, depth: false, stencil: false, powerPreference: "low-power",
});
if (!gl) return;

const program = gl.createProgram();
for (const [type, source] of [[gl.VERTEX_SHADER, vertexSource], [gl.FRAGMENT_SHADER, fragmentSource]]) {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
gl.attachShader(program, shader);
gl.deleteShader(shader);
}
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
gl.useProgram(program);
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
const position = gl.getAttribLocation(program, "position");
gl.enableVertexAttribArray(position);
gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);
const phase = gl.getUniformLocation(program, "phase");
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)");
let visible = false;
let timer;
let elapsed = 0;
let previousTime;

function draw() {
const now = performance.now();
if (previousTime !== undefined) elapsed += now - previousTime;
previousTime = now;
gl.uniform1f(phase, (elapsed / 16000) % (2 * Math.PI));
gl.drawArrays(gl.TRIANGLES, 0, 3);
}

function refresh() {
clearInterval(timer);
previousTime = undefined;
if (!visible || document.hidden || gl.isContextLost()) return;
// The soft gradients can use a smaller buffer than the displayed canvas.
const width = Math.max(1, Math.min(640, Math.ceil(canvas.clientWidth / 3)));
const height = Math.max(1, Math.min(460, Math.ceil(canvas.clientHeight / 3)));
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
gl.viewport(0, 0, width, height);
}
draw();
canvas.classList.add("painted");
if (!reducedMotion.matches) timer = setInterval(draw, 1000 / 24);
}

new IntersectionObserver(([entry]) => {
visible = entry.isIntersecting;
refresh();
}).observe(canvas);
new ResizeObserver(refresh).observe(canvas);
reducedMotion.addEventListener("change", refresh);
document.addEventListener("visibilitychange", refresh);
canvas.addEventListener("webglcontextlost", () => {
clearInterval(timer);
canvas.classList.remove("painted");
});
}

paintAmbientLight(document.querySelector(".hero-light canvas"));
41 changes: 41 additions & 0 deletions website/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { readFile, writeFile } from "node:fs/promises";
import { resolveInstallers } from "./installers.mjs";

function escapeHtml(value) {
return value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;");
}

export function renderDownloadPage(template, installers) {
const options = [];
const notes = new Map();
for (const [system, label, format] of [["mac", "macOS (Apple silicon)", "DMG"], ["windows", "Windows (x64)", "EXE"]]) {
const name = `<span data-text="${system}">${label}</span>`;
const installer = installers[system];
if (!installer) {
options.push(`<li><span>${name}<small data-text="unavailable">Installer unavailable</small></span></li>`);
continue;
}
const test = installer.test ? ' · <span data-text="testBuild">Test build</span>' : "";
options.push(`<li><a data-system="${system}" href="${escapeHtml(installer.url)}">${name}<small>${escapeHtml(installer.version)} · ${format}${test}</small></a></li>`);
notes.set(installer.notes, system);
}

const releaseNotes = [];
for (const [url, system] of notes) {
const platform = system === "mac" ? "macOS" : "Windows";
const label = notes.size === 1 ? "Release notes" : `${platform} release notes`;
const key = notes.size === 1 ? "notes" : `${system}Notes`;
releaseNotes.push(`<a data-text="${key}" href="${escapeHtml(url)}">${label}</a>`);
}
return template
.replace("{{primary-hidden}}", notes.size ? "hidden" : "")
.replace("{{menu-hidden}}", notes.size ? "" : "hidden")
.replace("{{desktop-options}}", () => options.join("\n"))
.replace("{{desktop-notes}}", () => releaseNotes.join("\n"));
}

if (import.meta.main) {
const template = await readFile(new URL("index.html", import.meta.url), "utf8");
const installers = await resolveInstallers();
await writeFile(process.argv[2], renderDownloadPage(template, installers));
}
Binary file added website/film/office-preview.mp4
Binary file not shown.
Binary file added website/film/poster.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/film/shot-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/film/shot-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/film/shot-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/film/shot-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/film/shot-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/film/shot-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading