From dc8fc396f1a1d16619a008b3f07b74c5843feba9 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Wed, 30 Sep 2026 22:33:29 +0700 Subject: [PATCH] ci(pages): moving notice on the old GitHub Pages address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit poli0981.github.io/youtube-generator still serves v0.38 to old bookmarks, and the data people saved there can't follow to ytgenerator.stream on its own (browser storage belongs to a site). A single static page replaces it: - reads the ytdescgen-* stores this browser saved on the old address and downloads them as a backup file in the new format (Settings › Restore reads it: migrations, the preview and Undo apply as for any backup); - points to ytgenerator.stream, in English or Vietnamese; - noindex, canonical to the new site, and a 404 copy for old deep links. pages-migration.yml deploys it by hand (workflow_dispatch, pinned actions, job-scoped permissions). The page, the workflow and the github-pages environment go on 2026-11-29. A regression test feeds the page's exact output through the restore. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pages-migration.yml | 38 ++++++ migration-page/404.html | 55 ++++++++ migration-page/app.js | 173 ++++++++++++++++++++++++++ migration-page/index.html | 55 ++++++++ migration-page/style.css | 122 ++++++++++++++++++ tests/utils/migration-page.test.ts | 109 ++++++++++++++++ 6 files changed, 552 insertions(+) create mode 100644 .github/workflows/pages-migration.yml create mode 100644 migration-page/404.html create mode 100644 migration-page/app.js create mode 100644 migration-page/index.html create mode 100644 migration-page/style.css create mode 100644 tests/utils/migration-page.test.ts diff --git a/.github/workflows/pages-migration.yml b/.github/workflows/pages-migration.yml new file mode 100644 index 0000000..32e7783 --- /dev/null +++ b/.github/workflows/pages-migration.yml @@ -0,0 +1,38 @@ +name: Pages migration notice + +# The app moved to https://ytgenerator.stream. What used to be the GitHub +# Pages site (poli0981.github.io/youtube-generator) is replaced by a single +# static page that hands visitors the data their browser saved there — as a +# backup file the new site restores — and points them to the new address. +# +# Run by hand once; the page is removed on 2026-11-29 together with this +# workflow and the github-pages environment (tracked in an issue). +on: + workflow_dispatch: + +permissions: {} + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 + - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 + with: + path: migration-page + - id: deployment + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/migration-page/404.html b/migration-page/404.html new file mode 100644 index 0000000..0bd216a --- /dev/null +++ b/migration-page/404.html @@ -0,0 +1,55 @@ + + + + + + + + YTDescGen has moved to ytgenerator.stream + + + + + + +
+

YTDescGen

+

YTDescGen has moved to ytgenerator.stream

+

+ The app now lives at its own address. Everything you saved on this old address — profiles, + presets, templates, history, settings — stays in this browser, so bring it along in two + steps. +

+ +
    +
  1. + Download your data +

    Looking for saved data…

    + +
  2. +
  3. + Restore it on the new site +

    + Open Settings › Backup & restore, choose Restore and pick the file — or drop it + there. You'll see what's new before anything changes. +

    + + Open ytgenerator.stream + +
  4. +
+ +

+ This page stays until 29 November 2026. The desktop and Android apps aren't affected. +

+

+ +

+
+ + diff --git a/migration-page/app.js b/migration-page/app.js new file mode 100644 index 0000000..78eb8b1 --- /dev/null +++ b/migration-page/app.js @@ -0,0 +1,173 @@ +// YTDescGen moved from poli0981.github.io/youtube-generator to +// ytgenerator.stream. Browser storage belongs to a site, so data saved on the +// old address can't follow on its own: this page reads it and hands it over +// as a backup file (the format the new site's Settings › Restore reads). +(function () { + "use strict"; + + // Store key, where a list section keeps its items, and the backup section. + var STORES = [ + { key: "ytdescgen-profiles", section: "profiles", list: "profiles" }, + { key: "ytdescgen-presets", section: "presets", list: "presets" }, + { key: "ytdescgen-templates", section: "templates", list: "templates" }, + { key: "ytdescgen-history", section: "history", list: "entries" }, + { key: "ytdescgen-settings", section: "settings", list: null }, + { key: "ytdescgen-editor-draft", section: "draft", list: null }, + ]; + + var TEXT = { + en: { + title: "YTDescGen has moved to ytgenerator.stream", + lead: "The app now lives at its own address. Everything you saved on this old address — profiles, presets, templates, history, settings — stays in this browser, so bring it along in two steps.", + step1: "Download your data", + searching: "Looking for saved data…", + found: "Found: {list}.", + none: "Nothing was saved in this browser — you can go straight to the new site.", + unavailable: + "This browser won't let the page read its storage (private mode?). Open the page in the browser you used before.", + download: "Download my data", + step2: "Restore it on the new site", + step2Hint: + "Open Settings › Backup & restore, choose Restore and pick the file — or drop it there. You'll see what's new before anything changes.", + open: "Open ytgenerator.stream", + notice: + "This page stays until 29 November 2026. The desktop and Android apps aren't affected.", + switch: "Tiếng Việt", + profiles: "Profiles ({n})", + presets: "Game presets ({n})", + templates: "Templates ({n})", + history: "History ({n})", + settings: "Settings", + draft: "Editor draft", + }, + vi: { + title: "YTDescGen đã chuyển sang ytgenerator.stream", + lead: "Ứng dụng giờ có địa chỉ riêng. Mọi thứ bạn đã lưu ở địa chỉ cũ này — hồ sơ, preset, template, lịch sử, cài đặt — vẫn nằm trong trình duyệt này, hãy mang theo bằng hai bước.", + step1: "Tải dữ liệu của bạn", + searching: "Đang tìm dữ liệu đã lưu…", + found: "Tìm thấy: {list}.", + none: "Trình duyệt này chưa lưu gì — bạn có thể sang thẳng trang mới.", + unavailable: + "Trình duyệt không cho trang đọc bộ nhớ (chế độ ẩn danh?). Hãy mở trang bằng trình duyệt bạn đã dùng trước đây.", + download: "Tải dữ liệu của tôi", + step2: "Khôi phục trên trang mới", + step2Hint: + "Mở Cài đặt › Sao lưu & khôi phục, chọn Khôi phục rồi chọn tệp — hoặc thả tệp vào đó. Bạn sẽ xem trước những gì mới trước khi có thay đổi nào.", + open: "Mở ytgenerator.stream", + notice: + "Trang này tồn tại đến ngày 29/11/2026. Ứng dụng desktop và Android không bị ảnh hưởng.", + switch: "English", + profiles: "Hồ sơ ({n})", + presets: "Preset game ({n})", + templates: "Template ({n})", + history: "Lịch sử ({n})", + settings: "Cài đặt", + draft: "Bản nháp editor", + }, + }; + + var lang = /^vi\b/i.test(navigator.language || "") ? "vi" : "en"; + var found = null; // { data, parts } once read + var readFailed = false; + + function format(template, values) { + return template.replace(/\{(\w+)\}/g, function (_, name) { + return String(values[name]); + }); + } + + function readStores() { + var data = {}; + var parts = []; + STORES.forEach(function (store) { + var raw = localStorage.getItem(store.key); + if (!raw) return; + var saved; + try { + saved = JSON.parse(raw); + } catch (e) { + return; + } + // Zustand's saved shape: { state, version }. + var state = saved && saved.state ? saved.state : saved; + var version = saved && typeof saved.version === "number" ? saved.version : 0; + if (!state || typeof state !== "object") return; + if (store.list) { + var items = state[store.list]; + if (!Array.isArray(items) || items.length === 0) return; + data[store.section] = { version: version, items: items }; + parts.push({ section: store.section, n: items.length }); + } else { + data[store.section] = { version: version, value: state }; + parts.push({ section: store.section, n: 1 }); + } + }); + return { data: data, parts: parts }; + } + + function render() { + var text = TEXT[lang]; + document.documentElement.lang = lang; + document.title = text.title; + Array.prototype.forEach.call(document.querySelectorAll("[data-i18n]"), function (el) { + var key = el.getAttribute("data-i18n"); + if (text[key] && key !== "searching") el.textContent = text[key]; + }); + var status = document.getElementById("found"); + var button = document.getElementById("download"); + if (readFailed) { + status.textContent = text.unavailable; + button.disabled = true; + } else if (!found || found.parts.length === 0) { + status.textContent = text.none; + button.disabled = true; + } else { + var list = found.parts.map(function (part) { + return format(text[part.section], { n: part.n }); + }); + status.textContent = format(text.found, { list: list.join(", ") }); + button.disabled = false; + } + } + + function download() { + if (!found) return; + var now = new Date(); + var envelope = { + _app: "ytdescgen", + _format: 2, + _type: "backup", + _schemaVersion: 1, + _appVersion: "0.38.0", + _exportedAt: now.toISOString(), + _source: "poli0981.github.io/youtube-generator", + data: found.data, + }; + var blob = new Blob([JSON.stringify(envelope, null, 2)], { type: "application/json" }); + var url = URL.createObjectURL(blob); + var link = document.createElement("a"); + var day = now.toISOString().slice(0, 10); + link.href = url; + link.download = "ytdescgen-legacy-backup-" + day + ".json"; + document.body.appendChild(link); + link.click(); + link.remove(); + setTimeout(function () { + URL.revokeObjectURL(url); + }, 1000); + } + + document.addEventListener("DOMContentLoaded", function () { + try { + found = readStores(); + } catch (e) { + readFailed = true; + } + document.getElementById("download").addEventListener("click", download); + document.getElementById("language").addEventListener("click", function () { + lang = lang === "vi" ? "en" : "vi"; + render(); + }); + render(); + }); +})(); diff --git a/migration-page/index.html b/migration-page/index.html new file mode 100644 index 0000000..0bd216a --- /dev/null +++ b/migration-page/index.html @@ -0,0 +1,55 @@ + + + + + + + + YTDescGen has moved to ytgenerator.stream + + + + + + +
+

YTDescGen

+

YTDescGen has moved to ytgenerator.stream

+

+ The app now lives at its own address. Everything you saved on this old address — profiles, + presets, templates, history, settings — stays in this browser, so bring it along in two + steps. +

+ +
    +
  1. + Download your data +

    Looking for saved data…

    + +
  2. +
  3. + Restore it on the new site +

    + Open Settings › Backup & restore, choose Restore and pick the file — or drop it + there. You'll see what's new before anything changes. +

    + + Open ytgenerator.stream + +
  4. +
+ +

+ This page stays until 29 November 2026. The desktop and Android apps aren't affected. +

+

+ +

+
+ + diff --git a/migration-page/style.css b/migration-page/style.css new file mode 100644 index 0000000..10394d6 --- /dev/null +++ b/migration-page/style.css @@ -0,0 +1,122 @@ +:root { + color-scheme: dark light; + --bg: #0b0b12; + --surface: #151522; + --border: #2a2a3d; + --text: #ececf4; + --muted: #a0a0b8; + --accent: #7c6cf6; + --accent-text: #ffffff; +} + +@media (prefers-color-scheme: light) { + :root { + --bg: #f5f5fa; + --surface: #ffffff; + --border: #dcdce8; + --text: #16161f; + --muted: #5c5c70; + --accent: #5b4de0; + } +} + +* { + box-sizing: border-box; +} + +body { + margin: 0; + min-height: 100dvh; + display: grid; + place-items: center; + padding: 24px 16px; + background: var(--bg); + color: var(--text); + font: + 15px/1.6 system-ui, + -apple-system, + "Segoe UI", + Roboto, + sans-serif; +} + +.card { + width: 100%; + max-width: 34rem; + padding: 28px; + border: 1px solid var(--border); + border-radius: 20px; + background: var(--surface); +} + +.brand { + margin: 0 0 8px; + color: var(--accent); + font-weight: 700; + letter-spacing: 0.02em; +} + +h1 { + margin: 0 0 12px; + font-size: 1.45rem; + line-height: 1.3; +} + +.steps { + margin: 20px 0; + padding-left: 1.2rem; +} + +.steps li { + margin-bottom: 18px; +} + +.steps p { + margin: 4px 0 10px; +} + +.muted { + color: var(--muted); +} + +.small { + font-size: 0.85rem; +} + +button, +.button { + display: inline-block; + padding: 9px 16px; + border: 1px solid var(--border); + border-radius: 10px; + background: transparent; + color: var(--text); + font: inherit; + font-weight: 600; + text-decoration: none; + cursor: pointer; +} + +button:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +.primary, +#download:not(:disabled) { + border-color: var(--accent); + background: var(--accent); + color: var(--accent-text); +} + +.link { + padding: 0; + border: 0; + color: var(--accent); + font-weight: 500; +} + +:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} diff --git a/tests/utils/migration-page.test.ts b/tests/utils/migration-page.test.ts new file mode 100644 index 0000000..17882fb --- /dev/null +++ b/tests/utils/migration-page.test.ts @@ -0,0 +1,109 @@ +import { describe, expect, it } from "vitest"; +import fs from "fs"; +import path from "path"; +import { readBackupText } from "@utils/backup/detect"; +import { sanitizeSections } from "@utils/backup/sanitize"; +import { initialSettings } from "@store/settings-heal"; + +/** + * The page left on poli0981.github.io/youtube-generator hands users their + * old data as a backup file. This is the file it writes for a typical + * v0.38 browser (zustand's `{ state, version }` per store), byte for byte. + */ +const FROM_MIGRATION_PAGE = JSON.stringify({ + _app: "ytdescgen", + _format: 2, + _type: "backup", + _schemaVersion: 1, + _appVersion: "0.38.0", + _exportedAt: "2026-09-30T15:32:31.505Z", + _source: "poli0981.github.io/youtube-generator", + data: { + profiles: { + version: 2, + items: [ + { + id: "old-1", + name: "Old main", + channelName: "Skullmute", + social: {}, + rig: { gpu: "nvidia|rtx_40|RTX 4070" }, + resolution: "1080p", + fps: "60", + graphicsPreset: "Ultra", + thirdPartyAdText: "", + createdAt: "2026-05-01T00:00:00.000Z", + updatedAt: "2026-05-01T00:00:00.000Z", + }, + ], + }, + history: { + version: 2, + items: [ + { + id: "h1", + gameName: "Hades", + videoType: "part", + language: "en", + genres: ["action"], + title: "Hades Part 1", + description: "d", + tags: "t", + createdAt: "2026-05-02T00:00:00.000Z", + }, + { + id: "h2", + gameName: "Hades", + videoType: "part", + language: "en", + genres: ["action"], + title: "Hades Part 1", + description: "d2", + tags: "t", + createdAt: "2026-05-03T00:00:00.000Z", + }, + ], + }, + settings: { version: 12, value: { theme: "light", appLanguage: "vi", legalConsentVersion: 1 } }, + }, +}); + +describe("GitHub Pages migration page", () => { + it("writes a file the restore reads, migrating the old data", () => { + const result = readBackupText(FROM_MIGRATION_PAGE); + if (!result.ok || result.file.kind !== "data") throw new Error("not restorable"); + const clean = sanitizeSections(result.file.sections, { + ...initialSettings, + legalConsentVersion: 2, + }); + expect(clean.profiles?.[0]).toMatchObject({ + name: "Old main", + rig: { gpu: "gpu:nvidia-rtx-4070" }, + graphicsPreset: "ultra", + }); + // v0.38 history piled up one entry per Output visit; v3 keeps one per video. + expect(clean.history).toHaveLength(1); + expect(clean.settings).toMatchObject({ + theme: "light", + appLanguage: "vi", + legalConsentVersion: 2, + }); + }); + + it("reads every store the app saved, under the keys the app used", () => { + const script = fs.readFileSync( + path.resolve(import.meta.dirname, "../../migration-page/app.js"), + "utf8", + ); + for (const key of [ + "ytdescgen-profiles", + "ytdescgen-presets", + "ytdescgen-templates", + "ytdescgen-history", + "ytdescgen-settings", + "ytdescgen-editor-draft", + ]) { + expect(script).toContain(`"${key}"`); + } + }); +});