3import { extname, join } from "jsr:@std/path@0.225.2";
4
5export function serveGithubRepo(params: {
6 owner: string;
7 repo: string;
1export default async function (req: Request): Promise<Response> {
2 const html = `<!DOCTYPE html>
3<html>
12 float w = 400;
13
14 // Function to calculate the vertex positions
15 float[] a(float x, float y) {
16 float k = mouseX - x;
1export default async function (req: Request): Promise<Response> {
2 const html = `<!DOCTYPE html>
3<html>
13 float w = 400;
14
15 // Function to calculate the vertex positions
16 float[] a(float x, float y) {
17 float k = w * noise(t) - x;
31 for (float y = 0; y < w; y += s) {
32 for (float x = 0; x < w; x += s) {
33 // Set the stroke color based on sine functions
34 stroke(
35 128 + 128 * sin(x * 0.01 + t),
1export default async function (req: Request): Promise<Response> {
2 const html = `<!DOCTYPE html>
3<html>
13 float w = 400;
14
15 // Function to calculate the vertex positions
16 float[] a(float x, float y) {
17 float k = w * noise(t) - x;
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
11const MAX_SELECTIONS = 2;
12
13function labelPredicate(label) {
14 return label === "Father" || label === "Mother" || /^Parent/.test(label);
15}
16
17async function* crawlWikipedia(
18 url: string,
19 generation: number = 0,
50}
51
52function App() {
53 const [url, setUrl] = useState("");
54 const [nodes, setNodes] = useState([]);
139 });
140
141 cyRef.current.on("tap", "node", function(evt) {
142 if (isCytoscapeDisabled) return;
143 const node = evt.target;
163 });
164
165 cyRef.current.on("layoutstop", function() {
166 cyRef.current.center();
167 cyRef.current.fit();
378}
379
380function client() {
381 createRoot(document.getElementById("root")).render(<App />);
382}
386}
387
388async function server(req: Request): Promise<Response> {
389 const url = new URL(req.url);
390
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
1// This approach uses the Lucia authentication library with a custom ValTownAdapter.
2// It provides signup, login, and logout functionality with session management.
3// The main tradeoff is the complexity of setting up Lucia, but it offers robust auth features.
4
34}
35
36// Helper function for redirects
37function redirect(url: string, status = 302): Response {
38 return new Response(null, {
39 status,
127}
128
129function transformIntoDatabaseSession(raw: SessionSchema): DatabaseSession {
130 const { id, user_id: userId, expires_at: expiresAtUnix, ...attributes } = raw;
131 return {
137}
138
139function transformIntoDatabaseUser(raw: UserSchema): DatabaseUser {
140 const { id, ...attributes } = raw;
141 return {
145}
146
147function escapeName(val: string): string {
148 return "`" + val + "`";
149}
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 20);