forgor lol

This commit is contained in:
laura 2025-11-13 01:49:35 -03:00
parent 869f3dfbe3
commit 862b11b9ef
Signed by: w
GPG key ID: BCD2117C99E69817
34 changed files with 516 additions and 179 deletions

View file

@ -1,13 +1,13 @@
#!/usr/bin/env -S deno run --allow-read --allow-write
/**
* Copyright (c) 2025 favewa
* Copyright (c) 2025 miwa
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { walk } from "https://deno.land/std/fs/walk.ts";
const copyrightHeader = `/**
* Copyright (c) 2025 favewa
* Copyright (c) 2025 miwa
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
`;

66
scripts/generate-rss.ts Executable file
View file

@ -0,0 +1,66 @@
/**
* Copyright (c) 2025 miwa
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#!/usr/bin/env -S deno run --allow-net --allow-write
/**
* Copyright (c) 2025 miwa
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { getPosts, type Report } from "../utils/atproto.ts";
function escapeXml(unsafe: string): string {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
}
function stripHtml(html: string): string {
return html
.replace(/<[^>]+>/g, " ")
.replace(/\s+/g, " ")
.trim();
}
function generateRSSItem(report: Report): string {
const link = `https://acpi.at/reports/${report.rkey}`;
const description = report.excerpt ||
stripHtml(report.content).substring(0, 200);
return [
` <item>`,
` <title>${escapeXml(report.title)}</title>`,
` <link>${link}</link>`,
` <guid>${link}</guid>`,
` <pubDate>${report.date.toUTCString()}</pubDate>`,
` <description>${escapeXml(description)}</description>`,
` </item>`,
].join("\n");
}
async function generateRSS() {
const reports = await getPosts();
const items = reports.map(generateRSSItem);
const xml = [
`<?xml version="1.0" encoding="UTF-8"?>`,
`<rss version="2.0">`,
` <channel>`,
` <title>$reports - acpi.at</title>`,
` <link>https://acpi.at/reports</link>`,
` <description>thoughts, ramblings, and occasional coherence</description>`,
items.join("\n"),
` </channel>`,
`</rss>`,
].join("\n");
await Deno.writeTextFile("./static/rss.xml", xml);
console.log("done");
}
if (import.meta.main) {
await generateRSS();
}