diff --git a/README.md b/README.md index 0c753594e4b6c043ac543f75c0e3c5bae4f38c9f..b2e490b7aba7fe0d231ca95568d399d7a4057508 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,6 @@ Install dependencies: ## Testing -1. Run `pnpm build && node out.js test/test_transcripts test/out` +1. Run `pnpm build && node out.js test/test_transcripts test/out -O test/test_old.json` - If you only want to test a single file, you also use `test/single_transcript` as input 2. Open any file in test/out in your browser diff --git a/src/index.ts b/src/index.ts index 9b2e581affd02e0caec3ada02c6b541d8e74f091..0d61303ddf6a9ded2303b5297a2797f023154359 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,7 @@ async function main() { ) .argument("<outputDir>", "path to output the rendered html to") .option("-A, --output-ast", "Also save the AST as a file", false) + .option("-O, --old-json [path]", "JSON file to take data about extra transcripts from") .option("-B, --base-url [url]", "Basic URL for the RSS feed") .action(run); await program.parseAsync(process.argv); @@ -53,18 +54,19 @@ async function run(inputDir: string, outputDir: string, options: CliOptions) { // (4) Generate index page let oldTranscripts: FinishedTranscriptMeta[] = []; - try { - // These are generated in the Sitzungen repo - const res = await fetch("https://fsr.oh14.de/protokolle/old.json"); - oldTranscripts = (await res.json()).map(t => ({ - // Fallback for some options: - spec_version: -1, // PDFs - no_link: false, - ...t, - })); - console.log(oldTranscripts); - } catch (e) { - console.error("Failed to get old transcripts", e); + if (options.oldJson) { + try { + // These are generated in the Sitzungen repo + const res = await fs.readFile(options.oldJson, { encoding: 'utf8' }) + oldTranscripts = JSON.parse(res).map(t => ({ + // Fallback for some options: + spec_version: -1, // PDFs + no_link: false, + ...t, + })); + } catch (e) { + console.error("Failed to get old transcripts", e); + } } const allTranscripts = [