From 4bbc0c19076dc8490c451a1f535f3e018fb8dda3 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Thu, 22 Jan 2026 13:27:36 -0500 Subject: Simple web server for viewing trees --- .gitignore | 2 + github-scraper.js | 74 --------------- package.json | 22 +++++ pnpm-lock.yaml | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 36 +++++++ src/scraper.ts | 91 ++++++++++++++++++ static/style.css | 14 +++ tsconfig.json | 19 ++++ views/tree.eta | 42 +++++++++ 9 files changed, 499 insertions(+), 74 deletions(-) create mode 100644 .gitignore delete mode 100755 github-scraper.js create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 src/index.ts create mode 100644 src/scraper.ts create mode 100644 static/style.css create mode 100644 tsconfig.json create mode 100644 views/tree.eta diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34b23da --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build/ +/node_modules/ diff --git a/github-scraper.js b/github-scraper.js deleted file mode 100755 index 7e07adc..0000000 --- a/github-scraper.js +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env node -/** - * GitHub Directory Listing Scraper - * - * Gets directory listings from GitHub without using the API (no rate limits!) - * Works by parsing the server-rendered HTML that GitHub sends to browsers. - */ - -async function getGitHubDirectory(owner, repo, path = '') { - // Always use the tree URL pattern, even for root directory - const url = `https://github.com/${owner}/${repo}/tree/main/${path}`; - - console.error(`Fetching: ${url}`); - - const response = await fetch(url); - const html = await response.text(); - - // GitHub embeds the directory data in a JSON script tag - // Using the tree (subdirectory) pattern for all cases - const subdirMatch = html.match(/