From d0dccc7a910a579d8c172c3d5a5a02ea3abd964d 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 --- cgithub/.gitignore | 2 + cgithub/github-scraper.js | 74 ------------- cgithub/package.json | 22 ++++ cgithub/pnpm-lock.yaml | 273 ++++++++++++++++++++++++++++++++++++++++++++++ cgithub/src/index.ts | 36 ++++++ cgithub/src/scraper.ts | 91 ++++++++++++++++ cgithub/static/style.css | 14 +++ cgithub/tsconfig.json | 19 ++++ cgithub/views/tree.eta | 42 +++++++ 9 files changed, 499 insertions(+), 74 deletions(-) create mode 100644 cgithub/.gitignore delete mode 100755 cgithub/github-scraper.js create mode 100644 cgithub/package.json create mode 100644 cgithub/pnpm-lock.yaml create mode 100644 cgithub/src/index.ts create mode 100644 cgithub/src/scraper.ts create mode 100644 cgithub/static/style.css create mode 100644 cgithub/tsconfig.json create mode 100644 cgithub/views/tree.eta (limited to 'cgithub') diff --git a/cgithub/.gitignore b/cgithub/.gitignore new file mode 100644 index 0000000..34b23da --- /dev/null +++ b/cgithub/.gitignore @@ -0,0 +1,2 @@ +/build/ +/node_modules/ diff --git a/cgithub/github-scraper.js b/cgithub/github-scraper.js deleted file mode 100755 index 7e07adc..0000000 --- a/cgithub/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(/