cohost/static/ftct/gen.ts
mehbark 48279a7da4 that's pretty much all for ftct
gonna just pch the css don't feel like inline
2023-08-21 23:17:59 -04:00

74 lines
2.2 KiB
TypeScript

import { answer, Riddle, riddles } from "../../html/find-the-code-together.tsx";
const render_riddle = ({ riddle, id }: { riddle: string; id: number }) => (
`${
id == 0
? "The answer to this riddle is 10 digits (0-9)."
: "All riddles (sans one) have a one letter answer (a-z)."
}
This is riddle #${id} ${id == 0 ? "(nice job finding this one!)" : ""}
${riddle}`
);
const encoder = new TextEncoder();
async function write_riddle(riddle: Riddle, id: number) {
const file = await Deno.open(`/home/mbk/Aims/cohost/static/ftct/${id}.txt`, {
write: true,
create: true,
});
file.write(encoder.encode(render_riddle({ ...riddle, id })));
file.close();
}
riddles.map(write_riddle);
const winners: string[] = [];
const file = await Deno.open(
`/home/mbk/Aims/cohost/static/ftct/${answer}.html`,
{
write: true,
create: true,
},
);
file.write(encoder.encode(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>you did it!!!!</title>
<style>
body {
margin: 0 auto;
width: min(500px, 100vw);
}
</style>
</head>
<body>
<h1>Congratulations!!!!</h1>
<p>You (plural, I hope) have done well to find this.
<p>I have prepared two rewards for everyone who has found this, alone or working together
<ol>
<li>if you'd like, you can join <a href="https://pyrope.net/mcai">my discord
server i created to say "man, computers are incredible" every day</a>, and post
proof that you helped find the code (or at least interesting fake proof) in the
#ftct channel (you should get access to it pretty quickly), and
your name will be added to the list below
<li>you get to be the first ones to see my cohost git repository! here it is: <a
href="https://git.pyrope.net/mbk/cohost">https://git.pyrope.net/mbk/cohost</a> i
know this is sort of lame, but there's over 2300 lines of typescript JSX, a lot
of comments showing my thought processes, and a (decent) git history for you to
look through so i'll hope you'll enjoy it. you probably like cohost, right?
</ol>
winners:
<ul>
<!-- i'm doing the winners by hand so don't try to be clever -->
${winners.map((w) => `<li>${w}`).join("\n")}
</body>
</html>
`));