Restore the missing external congrats page

This commit is contained in:
Damien Elmes 2025-01-24 16:19:55 +11:00
parent bc48eb4595
commit 774d57cdc8
3 changed files with 31 additions and 11 deletions

View file

@ -184,11 +184,16 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
let group = format!("ts:{name}"); let group = format!("ts:{name}");
let deps = inputs![deps, glob!(format!("ts/{name}/**"))]; let deps = inputs![deps, glob!(format!("ts/{name}/**"))];
let extra_exts = if html { &["css", "html"][..] } else { &["css"] }; let extra_exts = if html { &["css", "html"][..] } else { &["css"] };
let entrypoint = if html {
format!("ts/routes/{name}/index.ts")
} else {
format!("ts/{name}/index.ts")
};
build.add_action( build.add_action(
&group, &group,
EsbuildScript { EsbuildScript {
script: inputs!["ts/bundle_svelte.mjs"], script: inputs!["ts/bundle_svelte.mjs"],
entrypoint: inputs![format!("ts/{name}/index.ts")], entrypoint: inputs![entrypoint],
output_stem: &format!("ts/{name}/{name}"), output_stem: &format!("ts/{name}/{name}"),
deps: deps.clone(), deps: deps.clone(),
extra_exts, extra_exts,
@ -212,6 +217,16 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
":sveltekit", ":sveltekit",
], ],
)?; )?;
build_page(
"congrats",
true,
inputs![
//
":ts:lib",
":ts:components",
":sass",
],
)?;
Ok(()) Ok(())
} }

View file

@ -1,5 +1,5 @@
@use "../lib/sass/root-vars"; @use "../../lib/sass/root-vars";
@import "../lib/sass/base"; @import "../../lib/sass/base";
@import "bootstrap/scss/containers"; @import "bootstrap/scss/containers";

View file

@ -1,29 +1,34 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
//
// This old non-Sveltekit entrypoint has been preserved for AnkiWeb compatibility,
// and can't yet be removed. AnkiWeb loads the generated .js file into an existing
// page, and mounts into a div with 'id=congrats'. Unlike the desktop, it does not
// auto-refresh (to reduce the load on AnkiWeb).
import "./congrats-base.scss"; import "./congrats-base.scss";
import { congratsInfo } from "@generated/backend"; import { congratsInfo } from "@generated/backend";
import { ModuleName, setupI18n } from "@tslib/i18n"; import { ModuleName, setupI18n } from "@tslib/i18n";
import { checkNightMode } from "@tslib/nightmode"; import { checkNightMode } from "@tslib/nightmode";
import { mount } from "svelte";
import CongratsPage from "./CongratsPage.svelte"; import CongratsPage from "./CongratsPage.svelte";
const i18n = setupI18n({ modules: [ModuleName.SCHEDULING] }); const i18n = setupI18n({ modules: [ModuleName.SCHEDULING] });
export async function setupCongrats(): Promise<CongratsPage> { export async function setupCongrats(): Promise<void> {
checkNightMode(); checkNightMode();
await i18n; await i18n;
const customMountPoint = document.getElementById("congrats"); const customMountPoint = document.getElementById("congrats");
const info = await congratsInfo({}); const info = await congratsInfo({});
const page = new CongratsPage({ const props = { info, refreshPeriodically: false };
// use #congrats if it exists, otherwise entire body mount(
target: customMountPoint ?? document.body, CongratsPage, // use #congrats if it exists, otherwise entire body
props: { info, refreshPeriodically: !customMountPoint }, { target: customMountPoint ?? document.body, props },
}); );
return;
return page;
} }
setupCongrats(); setupCongrats();