Improve age-restricted hyperlinks, clean up markup, and add navigation icons
This commit is contained in:
parent
c55c82633d
commit
57c2c7c649
31 changed files with 279 additions and 138 deletions
|
|
@ -17,7 +17,7 @@ async function deployLftp({ host, user, password, targetFolder, sourceFolder, as
|
|||
[
|
||||
"-c",
|
||||
[
|
||||
`open -u ${user},${password} ${host}`,
|
||||
`open -u ${user},${password.replaceAll(/([ \t.,:;?!`'"^|*+#&$\(\)\[\]{}<>\\/-])/, "\\$1")} ${host}`,
|
||||
`mirror --reverse --include-glob ${join(assetsFolder, "*")} --delete --only-missing --no-perms --verbose ${n(sourceFolder)} ${n(targetFolder)}`,
|
||||
`mirror --reverse --exclude-glob ${join(assetsFolder, "*")} --delete --no-perms --verbose ${n(sourceFolder)} ${n(targetFolder)}`,
|
||||
`bye`,
|
||||
|
|
@ -27,9 +27,9 @@ async function deployLftp({ host, user, password, targetFolder, sourceFolder, as
|
|||
stdio: "inherit",
|
||||
},
|
||||
);
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
process.on("close", (code) =>
|
||||
(code === 0) ? resolve() : reject(`lftp failed with code ${code}`),
|
||||
(code === 0) ? resolve(0) : reject(`lftp failed with code ${code}`),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,20 +66,20 @@ async function exportStory(slug: string, options: { outputDir: string }) {
|
|||
/* Spawn Astro dev server */
|
||||
console.log("Starting Astro development server...");
|
||||
const devServerProcess = spawn("./node_modules/.bin/astro", ["dev"], { stdio: 'pipe' });
|
||||
const promise = new Promise<string>((resolve, reject) => {
|
||||
const localServerRegex = /Local\s+(http\S+)/
|
||||
const lines = createInterface({ input: devServerProcess.stdout });
|
||||
lines.on("line", (line) => {
|
||||
const match = localServerRegex.exec(line);
|
||||
if (match && match[1]) {
|
||||
resolve(match[1]);
|
||||
}
|
||||
});
|
||||
lines.on("close", reject);
|
||||
});
|
||||
const astroURL = await promise;
|
||||
console.log(`Astro listening on ${astroURL}`);
|
||||
let astroURL: string | null = null;
|
||||
try {
|
||||
astroURL = await new Promise<string>((resolve, reject) => {
|
||||
const localServerRegex = /Local\s+(http:\/\/\S+)/
|
||||
const lines = createInterface({ input: devServerProcess.stdout });
|
||||
lines.on("line", (line) => {
|
||||
const match = localServerRegex.exec(line);
|
||||
if (match && match[1]) {
|
||||
resolve(match[1]);
|
||||
}
|
||||
});
|
||||
lines.on("close", reject);
|
||||
});
|
||||
console.log(`Astro listening on ${astroURL}`);
|
||||
const response = await fetchRetry(new URL(`/api/healthcheck`, astroURL), { retries: 5, retryDelay: 2000 });
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText);
|
||||
|
|
@ -106,9 +106,9 @@ async function exportStory(slug: string, options: { outputDir: string }) {
|
|||
}
|
||||
const data: { story: string, description: Record<string, string>, thumbnail: string | null } = await response.json();
|
||||
await Promise.all(
|
||||
Object.entries(data.description).map(async ([website, description]) => {
|
||||
Object.entries(data.description).map(async ([filename, description]) => {
|
||||
return await writeFile(
|
||||
join(outputDir, `description_${website}.${website === "weasyl" ? "md" : "txt"}`),
|
||||
join(outputDir, filename),
|
||||
description,
|
||||
);
|
||||
}),
|
||||
|
|
@ -124,7 +124,7 @@ async function exportStory(slug: string, options: { outputDir: string }) {
|
|||
if (!thumbnail.ok) {
|
||||
throw new Error("Failed to get thumbnail");
|
||||
}
|
||||
const thumbnailExt = thumbnail.headers.get("Content-Type")?.startsWith("image/png") ? "png" : "jpg";
|
||||
const thumbnailExt = thumbnail.headers.get("Content-Type")!.startsWith("image/png") ? "png" : "jpg";
|
||||
await writeFile(join(outputDir, `thumbnail.${thumbnailExt}`), Buffer.from(await thumbnail.arrayBuffer()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue