commit
Port the web UI to SvelteKit and the doughmination.gay look
Pages and git transport are SvelteKit routes; serve.ts runs the build on Bun.serve with no idle timeout or body limit, so big pushes still stream. lucide icons become iconsax, IBM Plex Sans for text, Comic Code for code. MINIGIT_STATIC_DIR is gone.
diff --git a/.dockerignore b/.dockerignore
index 25b8428..b586c74 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -4,3 +4,5 @@ node_modules
data
*.md
test
+build
+.svelte-kit
diff --git a/.env.example b/.env.example
index 9df5f7c..aeed9f5 100644
--- a/.env.example
+++ b/.env.example
@@ -16,9 +16,6 @@ MINIGIT_PORT=4010
# Site title shown in the header.
MINIGIT_TITLE=dough-git
-# Directory served at /static. Drop your own style.css here to restyle.
-MINIGIT_STATIC_DIR=./public
-
# Site icon: the favicon, and the image used in link/social previews. Wants to
# be an absolute URL so it resolves off-site too.
MINIGIT_FAVICON=https://m.doughmination.gay/img/avatars/git.png
@@ -28,7 +25,7 @@ MINIGIT_FAVICON=https://m.doughmination.gay/img/avatars/git.png
MINIGIT_DESCRIPTION=A minimal self-hosted git mirror.
# Browser UI colour on mobile (<meta name="theme-color">).
-MINIGIT_THEME_COLOR=#060d18
+MINIGIT_THEME_COLOR=#eb459e
# Filename that marks a bare repo public. Absent from the repo dir = private.
# Public = anyone may read, no login needed.
diff --git a/.gitignore b/.gitignore
index 36f2b78..dfa5790 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ data/
*.db
*.db-shm
*.db-wal
+build/
+.svelte-kit/
diff --git a/Dockerfile b/Dockerfile
index 0685bea..3a191dc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,15 @@
# syntax=docker/dockerfile:1
-# Bun runs the TypeScript sources directly, so there is no build stage.
-# git is needed for upload-pack / receive-pack, the viewer, and imports.
+# The SvelteKit UI is built once; serve.ts then runs it on Bun.serve, with git
+# transport streaming through the same server. git is needed for
+# upload-pack / receive-pack, the viewer, and imports.
+FROM oven/bun:1-slim AS build
+WORKDIR /app
+COPY package.json bun.lock ./
+RUN bun install --frozen-lockfile
+COPY . .
+RUN bun run build
+
FROM oven/bun:1-slim
WORKDIR /app
ENV NODE_ENV=production
@@ -13,16 +21,17 @@ RUN apt-get update \
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production
-COPY src ./src
-COPY public ./public
+COPY --from=build /app/build ./build
+COPY serve.ts ./
+COPY src/lib/server ./src/lib/server
+COPY src/lib/index.ts ./src/lib/index.ts
# Sensible in-container defaults; secrets come from the environment / .env.
ENV MINIGIT_HOST=0.0.0.0 \
MINIGIT_PORT=4010 \
- MINIGIT_REPOS_ROOT=/srv/git \
- MINIGIT_STATIC_DIR=/app/public
+ MINIGIT_REPOS_ROOT=/srv/git
EXPOSE 4010
VOLUME ["/srv/git"]
-CMD ["bun", "src/server.ts"]
+CMD ["bun", "serve.ts"]
diff --git a/bun.lock b/bun.lock
index c52cba6..65dd3d1 100644
--- a/bun.lock
+++ b/bun.lock
@@ -5,75 +5,197 @@
"": {
"name": "dough-git",
"dependencies": {
- "hono": "^4.13.8",
- "lucide-static": "^1.49.0",
+ "iconsax": "^0.1.1",
"openid-client": "^6.8.8",
+ "simple-icons": "npm:@icons-pack/svelte-simple-icons@^7.2.0",
},
"devDependencies": {
+ "@sveltejs/adapter-node": "^6.0.0",
+ "@sveltejs/kit": "^3.1.0",
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
"@types/bun": "^1.4.2",
- "typescript": "^7.0.2",
+ "svelte": "^5.57.3",
+ "svelte-check": "^4.7.7",
+ "typescript": "^6.0.3",
+ "vite": "^8.3.5",
},
},
},
"packages": {
- "@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.4.2" } }, "sha512-GimotNn7+ZV0uVArItBbriZsR1oNf0+WTzPkdcFrzShI7k2norL0uzEaJT8T33dWr7O/c9ZDuAFQrctKCi72oQ=="],
+ "@jridgewell/gen-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
- "@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g=="],
+ "@jridgewell/remapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
- "@typescript/typescript-aix-ppc64": ["@typescript/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="],
+ "@jridgewell/resolve-uri": ["@jridgewell/[email protected]", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
- "@typescript/typescript-darwin-arm64": ["@typescript/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA=="],
+ "@jridgewell/sourcemap-codec": ["@jridgewell/[email protected]", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
- "@typescript/typescript-darwin-x64": ["@typescript/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA=="],
+ "@jridgewell/trace-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
- "@typescript/typescript-freebsd-arm64": ["@typescript/[email protected]", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ=="],
+ "@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q=="],
- "@typescript/typescript-freebsd-x64": ["@typescript/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw=="],
+ "@polka/url": ["@polka/[email protected]", "", {}, "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww=="],
- "@typescript/typescript-linux-arm": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ=="],
+ "@rolldown/binding-android-arm-eabi": ["@rolldown/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-aLcgK9gIJ3YRvrrtfSBbRa27F5WrpiTaPulnFpsHPxpUHgFlSgnU4854MHwoRGEBhfRJDWCS2WQ7lIjskE9Olw=="],
- "@typescript/typescript-linux-arm64": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ=="],
+ "@rolldown/binding-android-arm64": ["@rolldown/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-xD7DdZCrbThKuxNg7ooQmvp07ys4J/pnSEMTG3/OdOWl6daC67m/Q4fL78sRHMxTH/N4fGUbYhcPM0MF5WFHkg=="],
- "@typescript/typescript-linux-loong64": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ=="],
+ "@rolldown/binding-darwin-arm64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-m2WuQ6r0B4OTYxyPpNLtXaMRbRDUbG8YQV2Q3KTdSSK8Th6KHCnC8jVCJt8bvYeSB5WivkkNbc85mKadaSdOxA=="],
- "@typescript/typescript-linux-mips64el": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA=="],
+ "@rolldown/binding-darwin-x64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-5RtnsHM36nodM9WbMy+zip0LGS/G+y5wro5RHrpOlr4ac24+1zSi9kiV2MP1myZeZ/ifEHfulQcWjnAXzc2C2A=="],
- "@typescript/typescript-linux-ppc64": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA=="],
+ "@rolldown/binding-freebsd-x64": ["@rolldown/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-g3l09pyFqhu+135JKkbkwiKGQmwU5hUMUPJ4VdBADvuqR8d33L6H578rh8m7rtxbdp+VmX/+nzI7nvhSZlzpUQ=="],
- "@typescript/typescript-linux-riscv64": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ=="],
+ "@rolldown/binding-linux-arm-gnueabihf": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-nIe3VugI97nGQtspPxDqA4sXMUpeiocKIP/CqpY/u/vgbT+alX+cVxu1C/oVBPKg4feNTmYovE91v4DgXvXNwQ=="],
- "@typescript/typescript-linux-s390x": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw=="],
+ "@rolldown/binding-linux-arm64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64", "libc": "glibc" }, "sha512-iTBjXx+B5QSvgI89lJfmqh4wTh8NabR1YZIIN3hNx4zSG0EVfVqkOvLulNpG4251pbd6/IAmZ/LefVk1Y4rPhw=="],
- "@typescript/typescript-linux-x64": ["@typescript/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A=="],
+ "@rolldown/binding-linux-arm64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64", "libc": "musl" }, "sha512-uN26XOnVR7rqQupG3V9oAG2EGGatWjcJHOeDOHUFCh4TBWmP2tHTFoVN13aYbwfm0aHqJAEmcwhAu6sooIjfqQ=="],
- "@typescript/typescript-netbsd-arm64": ["@typescript/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA=="],
+ "@rolldown/binding-linux-ppc64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "ppc64", "libc": "glibc" }, "sha512-9nWkcdd+H+XhaA3fQIwpHnKIrfx/PQ6rO0pivr78Og07tXlUlctBBJoEYLPfhTmCR/QxEVdn6uPjHV5SymPhdw=="],
- "@typescript/typescript-netbsd-x64": ["@typescript/[email protected]", "", { "os": "none", "cpu": "x64" }, "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA=="],
+ "@rolldown/binding-linux-s390x-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "s390x", "libc": "glibc" }, "sha512-Ggh0ciFjLwIusLSLz7LZYEaGdxOAUJXI+Qu5JCbhPJJHEt8vP+IjRATTJheiJsdzzTYgUiHUiw3X1Ea3ZpMBdA=="],
- "@typescript/typescript-openbsd-arm64": ["@typescript/[email protected]", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ=="],
+ "@rolldown/binding-linux-x64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64", "libc": "glibc" }, "sha512-FHg60rS6DBePAYZ9X9F67x+JObFdmgn6tupA1C/a3B+CufFmTD4mX+e8M75tCiAO3foR/6xwVBI0KQiI7sn/rw=="],
- "@typescript/typescript-openbsd-x64": ["@typescript/[email protected]", "", { "os": "openbsd", "cpu": "x64" }, "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg=="],
+ "@rolldown/binding-linux-x64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64", "libc": "musl" }, "sha512-/cvV/7v5VGz/moiz0XKRj2dE8DzsKyhIu1KpOvJGPjRywg3yscON889UGvAe8zfiJLHup7VLjBduoGWi3HusWQ=="],
- "@typescript/typescript-sunos-x64": ["@typescript/[email protected]", "", { "os": "sunos", "cpu": "x64" }, "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g=="],
+ "@rolldown/binding-openharmony-arm64": ["@rolldown/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-MyzC5Hrv/sm+Z7TSGKP/j8001RO2xQm1zOpCNVL4j0cY/VhBZviludA2YFQ7i4lH6ZAXxQm0lcMdBzM+99mE7w=="],
- "@typescript/typescript-win32-arm64": ["@typescript/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ=="],
+ "@rolldown/binding-win32-arm64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-+PgYiS+AH5omy6L45ZLxybasauJaj3M8buoT83D+nzPmCayXlxUV9hydhciCKVyIg0B/v0BtXPDE1uGqNwCPpg=="],
- "@typescript/typescript-win32-x64": ["@typescript/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="],
+ "@rolldown/binding-win32-x64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-HFZd2QNQYn1JbIi+Hpd7H+r/lkWxcfIu28nirZ6eCn2LafuvmExMlb/P96Sfx5tf7pPArw39IdhmCF8vmV+NhQ=="],
- "bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-bxV1FgK7yBIzjRe5zBozIM4Bem11ZJcCXSrjWRG3YWLt8yFDePu4cLjpebO8OvPeIE9trbyPF4fuj3Cia4Fj3w=="],
+ "@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="],
- "hono": ["[email protected]", "", {}, "sha512-/Gng7NfoykZl2pjukW5Z6+8Yxm3BPRf86GTbQnt0SbySkvax4fyL4H3HhY1cCpBGmiW9XDRFzRV+CXK2W8QudQ=="],
+ "@standard-schema/spec": ["@standard-schema/[email protected]", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
+
+ "@sveltejs/acorn-typescript": ["@sveltejs/[email protected]", "", { "peerDependencies": { "acorn": "^8.9.0" } }, "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ=="],
+
+ "@sveltejs/adapter-node": ["@sveltejs/[email protected]", "", { "peerDependencies": { "@sveltejs/kit": "^3.0.0-next.0" } }, "sha512-s7muM4JmJ75OZ8o0G4VRhrEKdi8twuEm3t2o/qQsdlm12hKaX7S/CuUBuw3n983wB/IFBSpzG2ugX0xdGzbKwg=="],
+
+ "@sveltejs/kit": ["@sveltejs/[email protected]", "", { "dependencies": { "@rolldown/pluginutils": "^1.0.1", "@standard-schema/spec": "^1.1.0", "cookie": "^2.0.1", "devalue": "^5.9.4", "esm-env": "^1.2.2", "magic-string": "^1.2.3", "mrmime": "^2.0.1", "sirv": "^3.0.2" }, "peerDependencies": { "@opentelemetry/api": "^1.0.0", "@sveltejs/vite-plugin-svelte": "^7.0.0", "svelte": "^5.57.1", "typescript": "^6.0.0", "vite": "^8.0.12" }, "optionalPeers": ["@opentelemetry/api", "typescript"], "bin": { "svelte-kit": "svelte-kit.js" } }, "sha512-JTWlq2HQlkqx6vIoxhC0R6sc4WVqbQoRyEmr5YlqKmiYbzY1U3awtSWTmjMLlS056a49AmkQR6rnNANXIE8B0Q=="],
+
+ "@sveltejs/load-config": ["@sveltejs/[email protected]", "", {}, "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ=="],
+
+ "@sveltejs/vite-plugin-svelte": ["@sveltejs/[email protected]", "", { "dependencies": { "deepmerge": "^4.3.1", "magic-string": "^1.0.0", "obug": "^2.1.0", "vitefu": "^1.1.2" }, "peerDependencies": { "svelte": "^5.46.4", "vite": "^8.0.0-beta.7 || ^8.0.0" } }, "sha512-ZPsLN8B1e/En+Ak5s4V7srFDT532oS0qieLsQwu63NGKsS+iAjoO2Js1BochlHlglcU+Pt7WAO3C5Ee+4f6gVA=="],
+
+ "@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.4.4" } }, "sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ=="],
+
+ "@types/estree": ["@types/[email protected]", "", {}, "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g=="],
+
+ "@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog=="],
+
+ "acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw=="],
+
+ "aria-query": ["[email protected]", "", {}, "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g=="],
+
+ "axobject-query": ["[email protected]", "", {}, "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="],
+
+ "bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ=="],
+
+ "chokidar": ["[email protected]", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="],
+
+ "clsx": ["[email protected]", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
+
+ "cookie": ["[email protected]", "", {}, "sha512-yuToqVvRrj6pfDXREyQAAv8SkAEk/8GS3jQRTiUMm66TVtBYmqQeoEjL2Lmq8Rpo6271vH76InTChTitEAm65w=="],
+
+ "deepmerge": ["[email protected]", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],
+
+ "detect-libc": ["[email protected]", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
+
+ "devalue": ["[email protected]", "", {}, "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg=="],
+
+ "esm-env": ["[email protected]", "", {}, "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA=="],
+
+ "esrap": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" }, "peerDependencies": { "@typescript-eslint/types": "^8.2.0" }, "optionalPeers": ["@typescript-eslint/types"] }, "sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA=="],
+
+ "fdir": ["[email protected]", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
+
+ "fsevents": ["[email protected]", "", { "os": "darwin", "hasInstallScript": true }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
+
+ "iconsax": ["[email protected]", "", { "bin": { "iconsax": "bin/iconsax.js" } }, "sha512-/HXomG+SuhytKH/Yw4ZdunDGyWP02Osuk/pjony1k9CCMOsg7dUpnomu7HZUOHNu0yK0b3phErjH2IgUTJFjPA=="],
+
+ "is-reference": ["[email protected]", "", { "dependencies": { "@types/estree": "^1.0.6" } }, "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw=="],
"jose": ["[email protected]", "", {}, "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw=="],
- "lucide-static": ["[email protected]", "", {}, "sha512-gSjtl7bR2v26oDInh2Wua1PrF2BRRXl9inhnLWcFfnRqRShmgZvlFRisPHqTfU7kxsuZU8ThNjAFotbInrzKow=="],
+ "lightningcss": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.33.0", "lightningcss-darwin-arm64": "1.33.0", "lightningcss-darwin-x64": "1.33.0", "lightningcss-freebsd-x64": "1.33.0", "lightningcss-linux-arm-gnueabihf": "1.33.0", "lightningcss-linux-arm64-gnu": "1.33.0", "lightningcss-linux-arm64-musl": "1.33.0", "lightningcss-linux-x64-gnu": "1.33.0", "lightningcss-linux-x64-musl": "1.33.0", "lightningcss-win32-arm64-msvc": "1.33.0", "lightningcss-win32-x64-msvc": "1.33.0" } }, "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA=="],
+
+ "lightningcss-android-arm64": ["[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg=="],
+
+ "lightningcss-darwin-arm64": ["[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg=="],
+
+ "lightningcss-darwin-x64": ["[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ=="],
+
+ "lightningcss-freebsd-x64": ["[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg=="],
+
+ "lightningcss-linux-arm-gnueabihf": ["[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ=="],
+
+ "lightningcss-linux-arm64-gnu": ["[email protected]", "", { "os": "linux", "cpu": "arm64", "libc": "glibc" }, "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg=="],
+
+ "lightningcss-linux-arm64-musl": ["[email protected]", "", { "os": "linux", "cpu": "arm64", "libc": "musl" }, "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ=="],
+
+ "lightningcss-linux-x64-gnu": ["[email protected]", "", { "os": "linux", "cpu": "x64", "libc": "glibc" }, "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg=="],
+
+ "lightningcss-linux-x64-musl": ["[email protected]", "", { "os": "linux", "cpu": "x64", "libc": "musl" }, "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw=="],
+
+ "lightningcss-win32-arm64-msvc": ["[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA=="],
+
+ "lightningcss-win32-x64-msvc": ["[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA=="],
+
+ "locate-character": ["[email protected]", "", {}, "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA=="],
+
+ "magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.6.0" } }, "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w=="],
+
+ "mri": ["[email protected]", "", {}, "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="],
+
+ "mrmime": ["[email protected]", "", {}, "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ=="],
+
+ "nanoid": ["[email protected]", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ=="],
"oauth4webapi": ["[email protected]", "", {}, "sha512-8N28E+a/oxfXWBgOMt+ZP/JUf/XR+IFbvkAEPP3gznXOMv9BpAAwiIj0TFNz3tGTPc0ZQ8zmWBNgN1nAys0gng=="],
+ "obug": ["[email protected]", "", {}, "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q=="],
+
"openid-client": ["[email protected]", "", { "dependencies": { "jose": "^6.2.12", "oauth4webapi": "^3.8.8" } }, "sha512-ZsucJA5Ad04Uv7YN4ql+s4GXNmb9uAYQwyJTsJx7CH/MX3JZioLE2pVKi1SC+YrbSLA4Px3Gi30dMjgOZtb6pA=="],
- "typescript": ["[email protected]", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
+ "picocolors": ["[email protected]", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
+
+ "picomatch": ["[email protected]", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="],
+
+ "postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.20", "picocolors": "^1.1.1", "source-map-js": "^1.2.2" } }, "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g=="],
+
+ "readdirp": ["[email protected]", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="],
+
+ "rolldown": ["[email protected]", "", { "dependencies": { "@oxc-project/types": "=0.155.0", "@rolldown/pluginutils": "^1.0.0" }, "optionalDependencies": { "@rolldown/binding-android-arm-eabi": "1.2.15", "@rolldown/binding-android-arm64": "1.2.15", "@rolldown/binding-darwin-arm64": "1.2.15", "@rolldown/binding-darwin-x64": "1.2.15", "@rolldown/binding-freebsd-x64": "1.2.15", "@rolldown/binding-linux-arm-gnueabihf": "1.2.15", "@rolldown/binding-linux-arm64-gnu": "1.2.15", "@rolldown/binding-linux-arm64-musl": "1.2.15", "@rolldown/binding-linux-ppc64-gnu": "1.2.15", "@rolldown/binding-linux-s390x-gnu": "1.2.15", "@rolldown/binding-linux-x64-gnu": "1.2.15", "@rolldown/binding-linux-x64-musl": "1.2.15", "@rolldown/binding-openharmony-arm64": "1.2.15", "@rolldown/binding-win32-arm64-msvc": "1.2.15", "@rolldown/binding-win32-x64-msvc": "1.2.15" }, "bin": { "rolldown": "./bin/cli.mjs" } }, "sha512-6odND+fel5zVw3I4Yc2e69gvguDnX0CAAGiNDZSq4ik5WUcaLrkD2GLuog0XcODbor31hZ5ayEMgVDno+KPV5g=="],
+
+ "sade": ["[email protected]", "", { "dependencies": { "mri": "^1.1.0" } }, "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A=="],
+
+ "simple-icons": ["@icons-pack/[email protected]", "", { "peerDependencies": { "@sveltejs/kit": "^2.5.0", "svelte": "^5.0.0" } }, "sha512-zH4YByltlMBipdijJ1ZN4YGmxn2LKLCt+wCDC1rF0+3yor95Df090lZ5wfsN/UN4JsLjr7e6nxp6MOsEfYv/cQ=="],
+
+ "sirv": ["[email protected]", "", { "dependencies": { "@polka/url": "^1.0.0-next.24", "mrmime": "^2.0.0", "totalist": "^3.0.0" } }, "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g=="],
+
+ "source-map-js": ["[email protected]", "", {}, "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw=="],
+
+ "svelte": ["[email protected]", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "@jridgewell/sourcemap-codec": "^1.6.0", "@sveltejs/acorn-typescript": "^1.0.13", "@types/estree": "^1.0.9", "acorn": "^8.18.0", "aria-query": "5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", "devalue": "^5.9.2", "esm-env": "^1.2.1", "esrap": "^2.3.6", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", "zimmerframe": "^1.1.2" } }, "sha512-5mAftM3SoDV9X0zdF386F9p2pv8iKOwi/KfBS1XnBAkVCKFzVOLHUoa8iGWAt4buoicLmyWVRpuuD5wplXOQsg=="],
+
+ "svelte-check": ["[email protected]", "", { "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "@sveltejs/load-config": "^0.2.3", "chokidar": "^4.0.1", "fdir": "^6.2.0", "picocolors": "^1.0.0", "sade": "^1.7.4" }, "peerDependencies": { "svelte": "^4.0.0 || ^5.0.0-next.0", "typescript": "^5.0.0 || ^6.0.0" }, "bin": { "svelte-check": "bin/svelte-check" } }, "sha512-Ge2IMdeTpbJuzNFGRiiMg0RWgbScysKQu7xwcyFJ22+DU9F5nPX51+Q3gHmGqRxYQMx2knreVWt5oCtfe0vf2g=="],
+
+ "tinyglobby": ["[email protected]", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
+
+ "totalist": ["[email protected]", "", {}, "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ=="],
+
+ "typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw=="],
"undici-types": ["[email protected]", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
+
+ "vite": ["[email protected]", "", { "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", "postcss": "^8.5.30", "rolldown": "~1.2.14", "tinyglobby": "^0.2.17" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.7.1 || ^0.8.0", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "@vitejs/devtools", "esbuild", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ=="],
+
+ "vitefu": ["[email protected]", "", { "peerDependencies": { "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" }, "optionalPeers": ["vite"] }, "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg=="],
+
+ "zimmerframe": ["[email protected]", "", {}, "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA=="],
+
+ "svelte/magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
}
}
diff --git a/compose.yml b/compose.yml
index df49e44..9c877ac 100644
--- a/compose.yml
+++ b/compose.yml
@@ -14,7 +14,6 @@ services:
MINIGIT_HOST: "0.0.0.0"
MINIGIT_PORT: "4010"
MINIGIT_REPOS_ROOT: /srv/git
- MINIGIT_STATIC_DIR: /app/public
# Token DB lives on the repos volume so it persists across restarts.
MINIGIT_DB_PATH: /srv/git/dough-git.db
diff --git a/package.json b/package.json
index 9e5c819..8598db4 100644
--- a/package.json
+++ b/package.json
@@ -1,22 +1,34 @@
{
"name": "dough-git",
- "version": "1.0.0",
+ "version": "2.0.0",
"description": "A minimal self-hosted git mirror: HTTP clone/pull/push + cgit-style viewer, gated by OIDC SSO.",
"type": "module",
"private": true,
"scripts": {
- "start": "bun src/server.ts",
- "dev": "bun --watch src/server.ts",
- "typecheck": "tsc --noEmit",
+ "dev": "bunx --bun vite dev",
+ "build": "bunx --bun vite build",
+ "start": "bun serve.ts",
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
+ "typecheck": "bun run check",
"test": "bun test/run.ts"
},
+ "imports": {
+ "#lib": "./src/lib/index.ts",
+ "#lib/*": "./src/lib/*"
+ },
"dependencies": {
- "hono": "^4.13.8",
- "lucide-static": "^1.49.0",
- "openid-client": "^6.8.8"
+ "iconsax": "^0.1.1",
+ "openid-client": "^6.8.8",
+ "simple-icons": "npm:@icons-pack/svelte-simple-icons@^7.2.0"
},
"devDependencies": {
+ "@sveltejs/adapter-node": "^6.0.0",
+ "@sveltejs/kit": "^3.1.0",
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
"@types/bun": "^1.4.2",
- "typescript": "^7.0.2"
+ "svelte": "^5.57.3",
+ "svelte-check": "^4.7.7",
+ "typescript": "^6.0.3",
+ "vite": "^8.3.5"
}
}
diff --git a/public/app.js b/public/app.js
deleted file mode 100644
index 327069d..0000000
--- a/public/app.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/* public/app.js
- * LICENCED DASL-1.0 (c) Clove Twilight
- */
-
-document.addEventListener(
- "error",
- function (event) {
- var target = event.target;
- if (target instanceof HTMLImageElement && target.hasAttribute("data-avatar")) {
- target.remove();
- }
- },
- true,
-);
-
-document.addEventListener("submit", function (event) {
- var form = event.target;
- if (!(form instanceof HTMLFormElement)) return;
-
- var prompt = form.getAttribute("data-confirm");
- if (prompt && !window.confirm(prompt)) {
- event.preventDefault();
- }
-});
-
-document.addEventListener("change", function (event) {
- var control = event.target;
- if (control instanceof HTMLSelectElement && control.hasAttribute("data-autosubmit")) {
- if (control.form) control.form.submit();
- }
-});
diff --git a/public/cursors/default-dark.png b/public/cursors/default-dark.png
deleted file mode 100644
index df31375..0000000
Binary files a/public/cursors/default-dark.png and /dev/null differ
diff --git a/public/cursors/pointer-dark.png b/public/cursors/pointer-dark.png
deleted file mode 100644
index 554a18d..0000000
Binary files a/public/cursors/pointer-dark.png and /dev/null differ
diff --git a/public/style.css b/public/style.css
deleted file mode 100644
index 1b37492..0000000
--- a/public/style.css
+++ /dev/null
@@ -1,741 +0,0 @@
-/* public/style.css
- * LICENCED DASL-1.0 (c) Clove Twilight
- */
-
-:root {
- color-scheme: dark;
-
- --accent: #c22a44;
- --gilt: #d8b775;
- --danger: #ff4d5e;
- --success: #5f9e78;
-
- --bg-deep: #030207;
- --bg-raised: #100a10;
- --bg: #07050a;
- --surface: #1a1016;
- --surface-hi: #241318;
- --border: #34141c;
-
- --text-faint: #6b4a53;
- --text-dim: #82616a;
- --text-muted: #9c848c;
- --text-soft: #c7b6ba;
- --text: #ece3e6;
-
- --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
- --display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
- --mono: ui-monospace, "Cascadia Code", Menlo, monospace;
- --radius: 8px;
-
- --cursor-normal: url("https://m.doughmination.gay/cursors/sandrone/Normal.png") 0 0, default;
- --cursor-link: url("https://m.doughmination.gay/cursors/sandrone/Link.png") 4 0, pointer;
- --cursor-text: url("https://m.doughmination.gay/cursors/sandrone/Text.png") 4 9, text;
- --cursor-no: url("https://m.doughmination.gay/cursors/sandrone/Unavailable.png") 0 0, not-allowed;
-}
-
-/* Base */
-
-* {
- box-sizing: border-box;
-}
-
-html {
- min-height: 100%;
- background: linear-gradient(135deg, var(--bg) 0%, var(--bg-raised) 60%, var(--bg-deep) 100%);
-}
-
-body {
- margin: 0;
- min-height: 100vh;
- font-family: var(--font);
- font-size: 15px;
- line-height: 1.5;
- color: var(--text);
- cursor: var(--cursor-normal);
-}
-
-a {
- color: var(--accent);
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-a,
-button,
-label:has(input[type="checkbox"]) {
- cursor: var(--cursor-link);
-}
-
-h1,
-h2,
-h3 {
- font-weight: 600;
- line-height: 1.25;
-}
-
-table {
- width: 100%;
- border-collapse: collapse;
-}
-
-th,
-td {
- text-align: left;
- padding: 0.4rem 0.6rem;
- border-bottom: 1px solid var(--border);
- vertical-align: top;
-}
-
-th {
- color: var(--text-muted);
- font-weight: 600;
- font-size: 0.85em;
-}
-
-code,
-pre {
- font-family: var(--mono);
-}
-
-pre {
- margin: 0;
- overflow-x: auto;
-}
-
-/* Form controls */
-
-button,
-input[type="text"],
-input[type="url"],
-select {
- font: inherit;
- line-height: 1.5;
- padding: 0.2rem 0.7rem;
- border: 1px solid var(--border);
- border-radius: var(--radius);
-}
-
-button {
- display: inline-flex;
- align-items: center;
- gap: 0.35rem;
- background: var(--surface-hi);
- color: var(--text-soft);
-}
-
-button:hover {
- border-color: var(--accent);
- color: var(--text);
-}
-
-button:active {
- background: var(--surface);
-}
-
-input[type="text"],
-input[type="url"],
-select {
- min-width: 0;
- background: var(--bg-deep);
- color: var(--text);
- cursor: var(--cursor-text);
-}
-
-input::placeholder {
- color: var(--text-faint);
-}
-
-input:hover,
-select:hover {
- border-color: var(--text-faint);
-}
-
-button:focus-visible,
-input:focus-visible,
-select:focus-visible {
- outline: 1px solid var(--accent);
- outline-offset: 1px;
- border-color: var(--accent);
-}
-
-button:disabled {
- opacity: 0.5;
- cursor: var(--cursor-no);
-}
-
-input[type="checkbox"] {
- accent-color: var(--accent);
- vertical-align: -0.1em;
- margin: 0 0.35rem 0 0;
-}
-
-.icon {
- display: inline-block;
- vertical-align: middle;
- flex-shrink: 0;
-}
-
-/* Site chrome */
-
-.site-header {
- display: grid;
- grid-template-columns: 1fr auto 1fr;
- align-items: center;
- gap: 1rem;can we make
- padding: 0.75rem 1.25rem;
- border-bottom: 1px solid var(--border);
- background: var(--bg-raised);
-}
-
-.site-title {
- display: flex;
- align-items: center;
- gap: 0.5rem;
- font-weight: 700;
- font-size: 1.1rem;
- color: var(--text);
-}
-
-.site-logo {
- width: 1.5rem;
- height: 1.5rem;
- object-fit: cover;
-}
-
-.site-who {
- display: flex;
- justify-content: center;
- min-width: 0;
-}
-
-.site-nav {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 0.75rem;
-}
-
-.nav-link {
- display: inline-flex;
- align-items: center;
- gap: 0.35rem;
- color: var(--accent);
-}
-
-.nav-form {
- display: inline;
- margin: 0;
-}
-
-/* A form button that looks like the nav links beside it */
-.nav-link.nav-button,
-.nav-link.nav-button:hover,
-.nav-link.nav-button:active {
- padding: 0;
- border: 0;
- background: none;
- color: var(--accent);
-}
-
-.nav-link.nav-button:hover {
- text-decoration: underline;
-}
-
-.user {
- display: flex;
- align-items: center;
- gap: 0.4rem;
- min-width: 0;
- color: var(--text-muted);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-.content {
- max-width: 960px;
- margin: 0 auto;
- padding: 1.25rem;
-}
-
-.site-footer {
- color: var(--text-dim);
- text-align: center;
- padding: 2rem 0;
- font-size: 0.85em;
-}
-
-/* Avatars and profiles */
-
-.avatar {
- position: relative;
- flex-shrink: 0;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- background: var(--surface-hi);
- color: var(--text-soft);
- font-weight: 600;
- line-height: 1;
- overflow: hidden;
- user-select: none;
-}
-
-.avatar-sm {
- width: 25px;
- height: 25px;
- font-size: 13px;
-}
-
-.avatar-lg {
- width: 60px;
- height: 60px;
- font-size: 30px;
-}
-
-.avatar img {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
- object-fit: cover;
-}
-
-.profile-head {
- display: flex;
- align-items: center;
- gap: 1rem;
- margin: 0.5rem 0 1.5rem;
-}
-
-/* Headings */
-
-.page-title {
- font-size: 1.4rem;
- margin: 0.25rem 0 1rem;
-}
-
-.repo-title,
-.profile-name {
- font-family: var(--display);
- color: var(--gilt);
- font-weight: 500;
- letter-spacing: 0.01em;
- margin: 0.25rem 0 1rem;
-}
-
-.repo-title {
- font-size: 1.55rem;
-}
-
-.profile-name {
- font-size: 1.6rem;
- margin: 0;
-}
-
-.section-title {
- display: flex;
- align-items: center;
- gap: 0.4rem;
- font-size: 1.05rem;
- margin: 1.5rem 0 0.5rem;
- color: var(--text-soft);
-}
-
-/* Text helpers */
-
-.with-icon {
- display: inline-flex;
- align-items: center;
- gap: 0.4rem;
-}
-
-.muted {
- color: var(--text-muted);
-}
-
-.empty {
- color: var(--text-dim);
-}
-
-.mono {
- font-family: var(--mono);
- font-size: 0.85em;
- color: var(--text-dim);
- white-space: nowrap;
-}
-
-.repo-name {
- font-family: var(--display);
- color: var(--gilt);
- font-size: 1.05em;
- font-weight: 500;
-}
-
-.right {
- text-align: right;
-}
-
-.good {
- color: var(--success);
-}
-
-.warn {
- color: var(--accent);
-}
-
-.bad {
- color: var(--danger);
-}
-
-.badge {
- display: inline-flex;
- align-items: center;
- gap: 0.25rem;
- padding: 0.05rem 0.4rem;
- margin-left: 0.4rem;
- border: 1px solid var(--border);
- background: var(--surface-hi);
- font-family: var(--mono);
- font-size: 0.75em;
- color: var(--text-muted);
- vertical-align: middle;
-}
-
-/* Boxes, rows, tabs */
-
-.box {
- margin: 1rem 0;
- padding: 0.6rem 0.9rem;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius);
-}
-
-.label {
- color: var(--text-muted);
- margin-right: 0.5rem;
-}
-
-.row {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 0.5rem;
-}
-
-.grow {
- flex: 1 1 12rem;
- min-width: 0;
-}
-
-.tabs {
- display: flex;
- gap: 0.5rem;
- margin: 0.75rem 0;
-}
-
-.tab {
- display: inline-flex;
- align-items: center;
- gap: 0.4rem;
- padding: 0.2rem 0.7rem;
- border: 1px solid var(--border);
- border-radius: var(--radius);
- color: var(--text-soft);
-}
-
-.tab.active {
- background: var(--surface-hi);
- color: var(--text);
- font-weight: 600;
-}
-
-.rev-picker {
- margin: 0.75rem 0;
-}
-
-.code {
- display: block;
- padding: 0.75rem 1rem;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius);
- font-size: 0.85rem;
- color: var(--text-soft);
-}
-
-.commit-meta {
- display: grid;
- grid-template-columns: max-content 1fr;
- gap: 0.2rem 1rem;
- margin: 0.75rem 0;
-}
-
-.mirror-row {
- display: grid;
- grid-template-columns: minmax(5rem, auto) minmax(9rem, auto) auto 1fr;
- gap: 0.5rem 1rem;
- align-items: baseline;
- padding: 0.3rem 0;
-}
-
-.mirror-kind {
- color: var(--text-soft);
- font-weight: 600;
-}
-
-@media screen and (max-width: 40rem) {
- .mirror-row {
- grid-template-columns: 1fr;
- gap: 0.1rem;
- padding-bottom: 0.6rem;
- }
-}
-
-/* Rendered README */
-
-.readme {
- margin: 1rem 0;
- padding: 1rem 1.25rem;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius);
- overflow-wrap: break-word;
-}
-
-.readme > :first-child,
-.readme .md-alert > :first-child {
- margin-top: 0;
-}
-
-.readme > :last-child,
-.readme .md-alert > :last-child {
- margin-bottom: 0;
-}
-
-.readme :is(h1, h2, h3, h4, h5, h6) {
- font-family: var(--display);
- font-weight: 600;
- line-height: 1.25;
- letter-spacing: 0.01em;
- margin: 1.5rem 0 0.75rem;
-}
-
-.readme h1 {
- font-size: 1.5rem;
-}
-
-.readme h2 {
- font-size: 1.25rem;
-}
-
-.readme h3 {
- font-size: 1.05rem;
-}
-
-.readme :is(h4, h5, h6) {
- font-size: 0.95rem;
- color: var(--text-soft);
-}
-
-.readme :is(h1, h2) {
- padding-bottom: 0.3rem;
- border-bottom: 1px solid var(--border);
-}
-
-.readme :is(p, ul, ol, pre, blockquote, table) {
- margin: 0.75rem 0;
-}
-
-.readme code {
- background: var(--surface-hi);
- padding: 0.12em 0.35em;
- font-size: 0.9em;
-}
-
-.readme pre {
- padding: 0.75rem 1rem;
- background: var(--bg-deep);
- border: 1px solid var(--border);
- border-radius: var(--radius);
-}
-
-.readme pre code {
- background: none;
- padding: 0;
- font-size: 0.85rem;
- color: var(--text-soft);
-}
-
-.readme blockquote {
- padding: 0.1rem 0 0.1rem 1rem;
- border-left: 3px solid var(--border);
- color: var(--text-muted);
-}
-
-.readme :is(ul, ol) {
- padding-left: 1.5rem;
-}
-
-.readme li {
- margin: 0.25rem 0;
-}
-
-.readme hr {
- border: 0;
- border-top: 1px solid var(--border);
- margin: 1.5rem 0;
-}
-
-.readme img {
- max-width: 100%;
- vertical-align: middle;
-}
-
-.readme table {
- display: block;
- width: max-content;
- max-width: 100%;
- overflow-x: auto;
-}
-
-.readme [data-align="center"] {
- text-align: center;
-}
-
-.readme [data-align="right"] {
- text-align: right;
-}
-
-.readme del {
- color: var(--text-dim);
-}
-
-/* README alerts: > [!NOTE] and friends */
-
-.readme .md-alert {
- --alert: var(--border);
- margin: 0.75rem 0;
- padding: 0.5rem 1rem;
- border-left: 3px solid var(--alert);
- border-radius: var(--radius);
- color: var(--text-soft);
-}
-
-.readme .md-alert-title {
- display: flex;
- align-items: center;
- gap: 0.4rem;
- margin: 0 0 0.5rem;
- font-weight: 600;
- color: var(--alert);
-}
-
-.readme .md-alert-note {
- --alert: #47b6ee;
-}
-
-.readme .md-alert-tip {
- --alert: #96d94f;
-}
-
-.readme .md-alert-important {
- --alert: #b58fe0;
-}
-
-.readme .md-alert-warning {
- --alert: #f2b23c;
-}
-
-.readme .md-alert-caution {
- --alert: #ef6144;
-}
-
-.readme .md-alert-frozen {
- --alert: #b8dfe8;
- background: rgba(184, 223, 232, 0.05);
-}
-
-.readme .md-alert-aside {
- --alert: #74c2a8;
- border-left-width: 2px;
- color: var(--text-muted);
-}
-
-.readme .md-alert-aside .md-alert-title {
- font-weight: 400;
-}
-
-/* README pride text: gradient-filled words */
-
-.readme .md-pride {
- font-weight: 600;
- color: var(--text);
-}
-
-@supports (background-clip: text) or (-webkit-background-clip: text) {
- .readme .md-pride {
- -webkit-background-clip: text;
- background-clip: text;
- color: transparent;
- }
-}
-
-@media (prefers-contrast: more) {
- .readme .md-pride {
- background-image: none !important;
- color: var(--text);
- -webkit-text-fill-color: var(--text);
- }
-}
-
-.readme .md-pride a {
- color: inherit;
- text-decoration: underline;
-}
-
-.readme .md-pride code {
- color: var(--text-soft);
- -webkit-text-fill-color: var(--text-soft);
-}
-
-.readme .md-pride-gay {
- background-image: linear-gradient(96deg, #13a888, #26ceaa, #98e8c1, #7bade2, #918cdf);
-}
-
-.readme .md-pride-lesbian {
- background-image: linear-gradient(96deg, #ec7151, #e8782e, #ee9d67, #f2f7fb, #d675af, #ee63b5);
-}
-
-.readme .md-pride-bisexual {
- background-image: linear-gradient(96deg, #ee64ab, #bf80ba, #6894ee);
-}
-
-.readme .md-pride-transgender {
- background-image: linear-gradient(96deg, #67c9ee, #f5a9b8, #f2f7fb, #f5a9b8, #67c9ee);
-}
-
-.readme .md-pride-pansexual {
- background-image: linear-gradient(96deg, #ee65a7, #e6c619, #37aae9);
-}
-
-.readme .md-pride-asexual {
- background-image: linear-gradient(96deg, #8fa4bc, #c3d3e2, #f2f7fb, #ec54ec);
-}
-
-.readme .md-pride-aromantic {
- background-image: linear-gradient(96deg, #3fab44, #a7d379, #f2f7fb, #c3d3e2, #8fa4bc);
-}
-
-.readme .md-pride-nonbinary {
- background-image: linear-gradient(96deg, #eae446, #f2f7fb, #b480dc, #8fa4bc);
-}
-
-.readme .md-pride-queer {
- background-image: linear-gradient(96deg, #ef6d6d, #e68a19, #e6d719, #13ac41, #7994dd, #c578d5);
-}
diff --git a/serve.ts b/serve.ts
new file mode 100644
index 0000000..a0c2d84
--- /dev/null
+++ b/serve.ts
@@ -0,0 +1,76 @@
+/* serve.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+// Runs the built SvelteKit app on Bun.serve. adapter-node's own server caps
+// request bodies and idles connections out; a big push or clone needs neither
+
+import { join, normalize } from "node:path";
+import { config } from "./src/lib/server/config.ts";
+
+const BUILD = join(import.meta.dir, "build");
+const CLIENT = join(BUILD, "client");
+
+// adapter-node's build exposes the SvelteKit server it would have wrapped
+const { server } = await import(join(BUILD, "adapter-node.js"));
+
+await server.init({
+ env: process.env,
+ read: (file: string) => Bun.file(join(CLIENT, file)).stream(),
+});
+
+const SITE = new URL(config.baseUrl);
+
+// Hashed build output never changes under the same name
+function cacheFor(path: string): string {
+ return path.startsWith("/_app/immutable/") ? "public, max-age=31536000, immutable" : "public, max-age=3600";
+}
+
+async function staticFile(pathname: string): Promise<Response | null> {
+ let path: string;
+ try {
+ path = normalize(decodeURIComponent(pathname));
+ } catch {
+ return null;
+ }
+ if (path.includes("\0") || path.includes("..") || path === "/") return null;
+
+ const file = Bun.file(join(CLIENT, path));
+ if (!(await file.exists())) return null;
+
+ return new Response(file, {
+ headers: {
+ "Cache-Control": cacheFor(path),
+ },
+ });
+}
+
+Bun.serve({
+ port: config.port,
+ hostname: config.host,
+ // Big pushes and imports can sit quiet for minutes; never cut them off
+ idleTimeout: 0,
+ maxRequestBodySize: Number.MAX_SAFE_INTEGER,
+
+ async fetch(request, bun) {
+ const url = new URL(request.url);
+
+ if (request.method === "GET" || request.method === "HEAD") {
+ const asset = await staticFile(url.pathname);
+ if (asset) return asset;
+ }
+
+ // SvelteKit sees the public URL, so its own origin checks match what browsers send
+ const publicUrl = new URL(url.pathname + url.search, SITE);
+ const forwarded = new Request(publicUrl, request);
+
+ return server.respond(forwarded, {
+ getClientAddress: () => bun.requestIP(request)?.address ?? "",
+ platform: {},
+ });
+ },
+});
+
+console.log(`dough-git listening on http://${config.host}:${config.port}`);
+console.log(` repos root: ${config.reposRoot}`);
+console.log(` base url: ${config.baseUrl}`);
diff --git a/src/app.d.ts b/src/app.d.ts
new file mode 100644
index 0000000..eb1b6d6
--- /dev/null
+++ b/src/app.d.ts
@@ -0,0 +1,33 @@
+/* src/app.d.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { SessionUser } from "#lib/server/auth.ts";
+
+declare global {
+ namespace App {
+ interface Error {
+ message: string;
+ title?: string;
+ }
+
+ interface Locals {
+ user: SessionUser | null;
+ }
+ }
+}
+
+// <iconsax-icon> is registered by `import "iconsax"` in src/hooks.client.ts
+declare module "svelte/elements" {
+ export interface SvelteHTMLElements {
+ "iconsax-icon": HTMLAttributes<HTMLElement> & {
+ name: string;
+ type?: "bold" | "broken" | "bulk" | "linear" | "outline" | "twotone";
+ size?: number | string;
+ color?: string;
+ pro?: boolean;
+ };
+ }
+}
+
+export {};
diff --git a/src/app.html b/src/app.html
new file mode 100644
index 0000000..3368e2d
--- /dev/null
+++ b/src/app.html
@@ -0,0 +1,17 @@
+<!-- src/app.html
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="color-scheme" content="dark" />
+ <meta name="generator" content="dough-git" />
+ %sveltekit.head%
+ </head>
+ <body data-sveltekit-preload-data="hover">
+ <div class="app">%sveltekit.body%</div>
+ </body>
+</html>
diff --git a/src/hooks.client.ts b/src/hooks.client.ts
new file mode 100644
index 0000000..42c96a8
--- /dev/null
+++ b/src/hooks.client.ts
@@ -0,0 +1,6 @@
+/* src/hooks.client.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+// Registers <iconsax-icon>. Client-only: the package extends HTMLElement, which doesn't exist during SSR
+import "iconsax";
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
new file mode 100644
index 0000000..57d292d
--- /dev/null
+++ b/src/hooks.server.ts
@@ -0,0 +1,124 @@
+/* src/hooks.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { Handle, HandleServerError, ServerInit } from "@sveltejs/kit/hooks";
+import { config, oidcEnabled } from "#lib/server/config.ts";
+import { SESSION_COOKIE, oidcIssuer, sessionUser } from "#lib/server/auth.ts";
+import { purgeExpiredSessions } from "#lib/server/sessions.ts";
+import { purgeAllExpired } from "#lib/server/git.ts";
+import { clearRepoMetadata } from "#lib/server/repometa.ts";
+
+const SITE_ORIGIN = new URL(config.baseUrl).origin;
+
+// Logging out POSTs to /auth/logout, which redirects on to the SSO's logout,
+// and browsers check form-action against that redirect too
+const SSO_ORIGIN = config.oidc.issuer ? new URL(config.oidc.issuer).origin : "";
+
+const GIT_TRANSPORT = /\/(?:git-upload-pack|git-receive-pack|info\/refs)$/;
+
+const SWEEP_INTERVAL_MS = 6 * 60 * 60 * 1000;
+
+function sweepSessions(): void {
+ try {
+ const purged = purgeExpiredSessions();
+ if (purged) console.log(`[auth] purged ${purged} expired sessions`);
+ } catch (err) {
+ console.warn("[auth] session sweep failed:", err);
+ }
+}
+
+async function sweepTrash(): Promise<void> {
+ try {
+ for (const gone of await purgeAllExpired()) {
+ clearRepoMetadata({
+ owner: gone.owner,
+ name: gone.name,
+ });
+ console.log(`[trash] expired ${gone.owner}/${gone.name}`);
+ }
+ } catch (err) {
+ console.warn("[trash] scheduled sweep failed:", err);
+ }
+}
+
+export const init: ServerInit = async () => {
+ console.log(` oidc: ${oidcEnabled ? "enabled" : "disabled"}`);
+ console.log(
+ ` trash: ${config.trashDays > 0 ? `${config.trashDays}d, swept every 6h` : "kept forever"}`,
+ );
+ if (oidcEnabled) {
+ try {
+ console.log(` oidc issuer (must equal the callback's iss): ${await oidcIssuer()}`);
+ console.log(` oidc redirect_uri: ${config.baseUrl}/auth/callback`);
+ } catch (err) {
+ console.error(" oidc discovery FAILED (check OIDC_ISSUER):", err instanceof Error ? err.message : err);
+ }
+ }
+
+ void sweepTrash();
+ sweepSessions();
+ setInterval(() => {
+ void sweepTrash();
+ sweepSessions();
+ }, SWEEP_INTERVAL_MS).unref();
+};
+
+function sameOrigin(request: Request): boolean {
+ const origin = request.headers.get("origin");
+ if (origin) return origin === SITE_ORIGIN;
+
+ const referer = request.headers.get("referer");
+ if (!referer) return false;
+ try {
+ return new URL(referer).origin === SITE_ORIGIN;
+ } catch {
+ return false;
+ }
+}
+
+export const handle: Handle = async ({ event, resolve }) => {
+ const { request, url } = event;
+
+ // Git transport never looks at the browser session, and skipping it keeps
+ // SSO re-checks off that hot path. It authenticates with Basic auth instead
+ if (GIT_TRANSPORT.test(url.pathname)) {
+ event.locals.user = null;
+ return resolve(event);
+ }
+
+ const unsafe = !["GET", "HEAD", "OPTIONS"].includes(request.method);
+ if (unsafe && !sameOrigin(request)) {
+ return new Response("cross-site request refused\n", { status: 403 });
+ }
+
+ const token = event.cookies.get(SESSION_COOKIE);
+ event.locals.user = await sessionUser(token);
+ if (token && !event.locals.user) event.cookies.delete(SESSION_COOKIE, { path: "/" });
+
+ const response = await resolve(event);
+ const headers = response.headers;
+
+ const csp = headers.get("content-security-policy");
+ if (csp && SSO_ORIGIN) {
+ headers.set("content-security-policy", csp.replace("form-action 'self'", `form-action 'self' ${SSO_ORIGIN}`));
+ }
+ headers.set("X-Content-Type-Options", "nosniff");
+ headers.set("Referrer-Policy", "same-origin");
+ headers.set("X-Frame-Options", "DENY");
+ if (SITE_ORIGIN.startsWith("https://")) {
+ headers.set("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
+ }
+ return response;
+};
+
+// App errors (thrown with error()) keep their own title and message; this only softens unknown ones
+export const handleError: HandleServerError = ({ kind, error, event }) => {
+ if (kind !== "unknown") return;
+
+ console.error("[error]", event.request.method, event.url.pathname, error);
+ return {
+ title: "something went wrong",
+ message: "Something went wrong on our side. Please try again.",
+ };
+};
diff --git a/src/icons.ts b/src/icons.ts
deleted file mode 100644
index 4d53240..0000000
--- a/src/icons.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/* src/icons.ts
- * LICENCED DASL-1.0 (c) Clove Twilight
- */
-
-import { readFileSync } from "node:fs";
-import { createRequire } from "node:module";
-
-// Stroke width in rendered pixels, kept constant at every size
-// (lucide's absoluteStrokeWidth behaviour)
-const STROKE_WIDTH = 2.25;
-const GRID = 24;
-
-const require = createRequire(import.meta.url);
-const cache = new Map<string, string>();
-
-// "house" -> "lucide-static/icons/house.svg"
-function assetPath(name: string): string {
- return `lucide-static/icons/${name}.svg`;
-}
-
-function parse(name: string): string {
- const cached = cache.get(name);
- if (cached !== undefined) return cached;
-
- let source: string;
- try {
- source = readFileSync(require.resolve(assetPath(name)), "utf8");
- } catch {
- throw new Error(`icon: unknown lucide icon "${name}"`);
- }
-
- // Skip the licence comment and the <svg ...> open tag
- const open = source.indexOf("<svg");
- const body = source
- .slice(source.indexOf(">", open) + 1, source.lastIndexOf("</svg>"))
- .replace(/\s*\n\s*/g, " ")
- .replace(/>\s+</g, "><")
- .trim();
-
- cache.set(name, body);
- return body;
-}
-
-export function icon(name: string, size = 16): string {
- const body = parse(name);
- const stroke = +((STROKE_WIDTH * GRID) / size).toFixed(3);
- return `<svg class="icon" viewBox="0 0 ${GRID} ${GRID}" width="${size}" height="${size}" fill="none" stroke="currentColor" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`;
-}
diff --git a/src/lib/components/Avatar.svelte b/src/lib/components/Avatar.svelte
new file mode 100644
index 0000000..1e8b4af
--- /dev/null
+++ b/src/lib/components/Avatar.svelte
@@ -0,0 +1,57 @@
+<!-- src/lib/components/Avatar.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { displayName, type Profile } from "#lib";
+
+ let { profile, size }: { profile: Profile; size: "sm" | "lg" } = $props();
+
+ // A broken picture falls back to the initial underneath it
+ let broken = $state(false);
+
+ const initial = $derived(displayName(profile).trim().slice(0, 1).toUpperCase() || "?");
+</script>
+
+<span class="avatar {size}">
+ {initial}
+ {#if profile.picture && !broken}
+ <img src={profile.picture} alt="" loading="lazy" onerror={() => (broken = true)} />
+ {/if}
+</span>
+
+<style>
+ .avatar {
+ display: inline-grid;
+ position: relative;
+ flex-shrink: 0;
+ place-items: center;
+ overflow: hidden;
+ border-radius: 50%;
+ outline: 1px solid var(--line);
+ background: var(--accent-dim);
+ color: var(--accent);
+ font-weight: 600;
+ }
+
+ .sm {
+ width: 1.75rem;
+ height: 1.75rem;
+ font-size: 0.8rem;
+ }
+
+ .lg {
+ width: 4.5rem;
+ height: 4.5rem;
+ font-size: 1.75rem;
+ box-shadow: 0 0 0 4px var(--accent-dim);
+ }
+
+ img {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+</style>
diff --git a/src/lib/components/ConfirmForm.svelte b/src/lib/components/ConfirmForm.svelte
new file mode 100644
index 0000000..7c5436e
--- /dev/null
+++ b/src/lib/components/ConfirmForm.svelte
@@ -0,0 +1,26 @@
+<!-- src/lib/components/ConfirmForm.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import type { Snippet } from "svelte";
+
+ // A POST form that asks first. Without scripting it just submits
+ let {
+ action,
+ prompt,
+ children,
+ }: {
+ action: string;
+ prompt: string;
+ children: Snippet;
+ } = $props();
+
+ function onsubmit(event: SubmitEvent) {
+ if (!window.confirm(prompt)) event.preventDefault();
+ }
+</script>
+
+<form method="post" {action} {onsubmit}>
+ {@render children()}
+</form>
diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte
new file mode 100644
index 0000000..6228056
--- /dev/null
+++ b/src/lib/components/Footer.svelte
@@ -0,0 +1,29 @@
+<!-- src/lib/components/Footer.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import "#lib/styles/footer.css";
+ import { page } from "$app/state";
+ import { mainSite } from "#lib";
+
+ const site = $derived(page.data.site);
+</script>
+
+<footer>
+ <p class="footer-line">
+ <span class="footer-brand">
+ {#if site.favicon}
+ <img src={site.favicon} alt="" width="20" height="20" />
+ {/if}
+ {site.title} · a minimal git mirror
+ </span>
+
+ <span>
+ part of <a href={mainSite}>doughmination.gay</a>
+ <iconsax-icon name="heart" type="bulk" size="16" class="beat"></iconsax-icon>
+ </span>
+
+ <span>Clove Twilight © 2026</span>
+ </p>
+</footer>
diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte
new file mode 100644
index 0000000..b05c480
--- /dev/null
+++ b/src/lib/components/Header.svelte
@@ -0,0 +1,68 @@
+<!-- src/lib/components/Header.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import "#lib/styles/header.css";
+ import { page } from "$app/state";
+ import { displayName } from "#lib";
+ import Avatar from "#lib/components/Avatar.svelte";
+
+ const site = $derived(page.data.site);
+ const user = $derived(page.data.user);
+</script>
+
+<!-- Fixed-height page backdrop, so every page gets the same amount of background -->
+<div class="backdrop" aria-hidden="true"></div>
+
+<header>
+ <a class="brand" href="/">
+ {#if site.favicon}
+ <img src={site.favicon} alt="" width="32" height="32" />
+ {/if}
+ <span>{site.title}</span>
+ </a>
+
+ <nav>
+ {#if user}
+ <a href="/{user.slug}">
+ <Avatar profile={user} size="sm" />{displayName(user)}
+ </a>
+ <a href="/new">
+ <iconsax-icon name="add-circle" type="bulk" size="24" class="nav-icon"></iconsax-icon>New
+ </a>
+ <a href="/settings">
+ <iconsax-icon name="setting-2" type="bulk" size="24" class="nav-icon"></iconsax-icon>Settings
+ </a>
+ <form method="post" action="/auth/logout" class="inline">
+ <button type="submit" class="nav-button">
+ <iconsax-icon name="logout-01" type="bulk" size="24" class="nav-icon"></iconsax-icon>Sign out
+ </button>
+ </form>
+ {:else}
+ <a href="/auth/login">
+ <iconsax-icon name="login-01" type="bulk" size="24" class="nav-icon"></iconsax-icon>Sign in
+ </a>
+ {/if}
+ </nav>
+</header>
+
+<style>
+ nav {
+ flex-wrap: wrap;
+ align-items: center;
+ }
+
+ /* A form button that reads as one of the header's links */
+ .nav-button {
+ padding: 0;
+ border: 0;
+ background: none;
+ color: var(--muted);
+ font-size: inherit;
+ }
+
+ .nav-button:hover:not(:disabled) {
+ color: var(--text);
+ }
+</style>
diff --git a/src/lib/components/Meta.svelte b/src/lib/components/Meta.svelte
new file mode 100644
index 0000000..5d82656
--- /dev/null
+++ b/src/lib/components/Meta.svelte
@@ -0,0 +1,39 @@
+<!-- src/lib/components/Meta.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { page } from "$app/state";
+ import { metaText } from "#lib";
+
+ let {
+ title,
+ description = "",
+ noindex = false,
+ }: {
+ title: string;
+ description?: string;
+ noindex?: boolean;
+ } = $props();
+
+ const site = $derived(page.data.site);
+ const text = $derived(metaText(description || site.description));
+ const url = $derived(site.baseUrl + page.url.pathname);
+</script>
+
+<svelte:head>
+ <title>{title}</title>
+ <meta name="description" content={text} />
+ {#if noindex}
+ <meta name="robots" content="noindex, nofollow" />
+ {:else}
+ <link rel="canonical" href={url} />
+ {/if}
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content={site.title} />
+ <meta property="og:title" content={title} />
+ <meta property="og:description" content={text} />
+ <meta property="og:url" content={url} />
+ <meta property="og:image" content={site.favicon} />
+ <meta name="twitter:card" content="summary" />
+</svelte:head>
diff --git a/src/lib/components/OwnerHead.svelte b/src/lib/components/OwnerHead.svelte
new file mode 100644
index 0000000..8fc4169
--- /dev/null
+++ b/src/lib/components/OwnerHead.svelte
@@ -0,0 +1,86 @@
+<!-- src/lib/components/OwnerHead.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { displayName, fmtDate } from "#lib";
+ import Avatar from "#lib/components/Avatar.svelte";
+ import Tabs from "#lib/components/Tabs.svelte";
+
+ type Profile = {
+ slug: string;
+ name: string | null;
+ username: string | null;
+ picture: string | null;
+ createdAt: number;
+ };
+
+ let {
+ owner,
+ profile,
+ active,
+ }: {
+ owner: string;
+ profile: Profile | null;
+ active: "profile" | "repos";
+ } = $props();
+
+ const handle = $derived(profile?.username && profile.username !== profile.slug ? profile.username : null);
+ const shown = $derived(
+ profile ?? {
+ name: owner,
+ username: null,
+ picture: null,
+ },
+ );
+</script>
+
+<section class="owner-head">
+ <Avatar profile={shown} size="lg" />
+ <div>
+ <h1>{displayName(shown)}</h1>
+ {#if profile}
+ <p class="muted">
+ @{profile.slug}{#if handle} · {handle}{/if} · joined {fmtDate(profile.createdAt).slice(0, 10)}
+ </p>
+ {:else}
+ <p class="muted">@{owner} · no account on this instance</p>
+ {/if}
+ </div>
+</section>
+
+<Tabs
+ {active}
+ items={[
+ {
+ id: "profile",
+ label: "profile",
+ icon: "user",
+ href: `/${owner}`,
+ },
+ {
+ id: "repos",
+ label: "repositories",
+ icon: "hierarchy",
+ href: `/${owner}/+repos`,
+ },
+ ]}
+/>
+
+<style>
+ .owner-head {
+ display: flex;
+ gap: 1.25rem;
+ align-items: center;
+ }
+
+ h1 {
+ margin: 0;
+ font-size: clamp(1.75rem, 5vw, 2.5rem);
+ letter-spacing: -0.02em;
+ }
+
+ p {
+ margin: 0;
+ }
+</style>
diff --git a/src/lib/components/RepoNav.svelte b/src/lib/components/RepoNav.svelte
new file mode 100644
index 0000000..5cb2860
--- /dev/null
+++ b/src/lib/components/RepoNav.svelte
@@ -0,0 +1,45 @@
+<!-- src/lib/components/RepoNav.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import Tabs from "#lib/components/Tabs.svelte";
+
+ let {
+ owner,
+ name,
+ active,
+ query,
+ }: {
+ owner: string;
+ name: string;
+ active: "summary" | "log" | "tree";
+ query: string;
+ } = $props();
+
+ const base = $derived(`/${owner}/${name}`);
+</script>
+
+<Tabs
+ {active}
+ items={[
+ {
+ id: "summary",
+ label: "summary",
+ icon: "document-text",
+ href: `${base}${query}`,
+ },
+ {
+ id: "log",
+ label: "log",
+ icon: "record-circle",
+ href: `${base}/log${query}`,
+ },
+ {
+ id: "tree",
+ label: "tree",
+ icon: "folder-2",
+ href: `${base}/tree${query}`,
+ },
+ ]}
+/>
diff --git a/src/lib/components/RepoTable.svelte b/src/lib/components/RepoTable.svelte
new file mode 100644
index 0000000..c459615
--- /dev/null
+++ b/src/lib/components/RepoTable.svelte
@@ -0,0 +1,76 @@
+<!-- src/lib/components/RepoTable.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Visibility from "#lib/components/Visibility.svelte";
+
+ type Repo = {
+ owner: string;
+ name: string;
+ description: string;
+ isPublic: boolean;
+ lastCommit: number | null;
+ shared?: boolean;
+ };
+
+ let {
+ repos,
+ showOwner,
+ empty,
+ }: {
+ repos: Repo[];
+ showOwner: boolean;
+ empty: string;
+ } = $props();
+</script>
+
+<div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>repository</th>
+ <th>description</th>
+ <th>visibility</th>
+ <th>updated</th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each repos as repo (`${repo.owner}/${repo.name}`)}
+ <tr>
+ <td class="repo-name">
+ <iconsax-icon name="hierarchy" type="bulk" size="16"></iconsax-icon>
+ {#if showOwner}
+ <a class="muted" href="/{repo.owner}">{repo.owner}</a>/{/if}<a href="/{repo.owner}/{repo.name}">{repo.name}</a>
+ {#if repo.shared}
+ <span class="badge"><iconsax-icon name="people" type="bulk" size="12"></iconsax-icon> shared</span>
+ {/if}
+ </td>
+ <td class="muted">{repo.description}</td>
+ <td class="mono"><Visibility isPublic={repo.isPublic} /></td>
+ <td class="mono">{fmtDate(repo.lastCommit)}</td>
+ </tr>
+ {:else}
+ <tr>
+ <td colspan="4" class="empty">{empty}</td>
+ </tr>
+ {/each}
+ </tbody>
+ </table>
+</div>
+
+<style>
+ .repo-name {
+ font-weight: 600;
+ white-space: nowrap;
+ }
+
+ .repo-name a {
+ text-decoration: none;
+ }
+
+ .repo-name a:hover {
+ color: var(--accent);
+ }
+</style>
diff --git a/src/lib/components/RevPicker.svelte b/src/lib/components/RevPicker.svelte
new file mode 100644
index 0000000..2250b97
--- /dev/null
+++ b/src/lib/components/RevPicker.svelte
@@ -0,0 +1,59 @@
+<!-- src/lib/components/RevPicker.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ type Refs = {
+ branches: string[];
+ tags: string[];
+ };
+
+ let { refs, rev }: { refs: Refs; rev: string } = $props();
+
+ const all = $derived([...refs.branches, ...refs.tags]);
+ const shown = $derived(all.length > 0 && !(all.length < 2 && all.includes(rev)));
+ const detached = $derived(!all.includes(rev));
+</script>
+
+{#if shown}
+ <form method="get" class="rev-picker">
+ <label class="field-label with-icon" for="rev-picker">
+ <iconsax-icon name="hierarchy" type="bulk" size="16"></iconsax-icon>revision
+ </label>
+ <!-- Picking a revision is the whole form; the button stays for no-JS -->
+ <select id="rev-picker" name="h" value={rev} onchange={(event) => event.currentTarget.form?.submit()}>
+ {#if detached}
+ <option value={rev}>{rev.slice(0, 10)}</option>
+ {/if}
+ {#if refs.branches.length}
+ <optgroup label="branches">
+ {#each refs.branches as name (name)}
+ <option value={name}>{name}</option>
+ {/each}
+ </optgroup>
+ {/if}
+ {#if refs.tags.length}
+ <optgroup label="tags">
+ {#each refs.tags as name (name)}
+ <option value={name}>{name}</option>
+ {/each}
+ </optgroup>
+ {/if}
+ </select>
+ <button type="submit"><iconsax-icon name="arrow-right-01" type="bulk" size="16"></iconsax-icon>go</button>
+ </form>
+{/if}
+
+<style>
+ .rev-picker {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.6rem;
+ align-items: center;
+ }
+
+ select {
+ width: auto;
+ min-width: 12rem;
+ }
+</style>
diff --git a/src/lib/components/Tabs.svelte b/src/lib/components/Tabs.svelte
new file mode 100644
index 0000000..5a119cf
--- /dev/null
+++ b/src/lib/components/Tabs.svelte
@@ -0,0 +1,55 @@
+<!-- src/lib/components/Tabs.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ type Tab = {
+ id: string;
+ label: string;
+ icon: string;
+ href: string;
+ };
+
+ let { active, items }: { active: string; items: Tab[] } = $props();
+</script>
+
+<nav class="tabs">
+ {#each items as tab (tab.id)}
+ <a class="tab" class:active={tab.id === active} href={tab.href}>
+ <iconsax-icon name={tab.icon} type="bulk" size="18"></iconsax-icon>{tab.label}
+ </a>
+ {/each}
+</nav>
+
+<style>
+ .tabs {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.25rem;
+ padding: 0.25rem;
+ border: 1px solid var(--line);
+ border-radius: 999px;
+ background: var(--raised);
+ align-self: flex-start;
+ }
+
+ .tab {
+ display: inline-flex;
+ gap: 0.4em;
+ align-items: center;
+ padding: 0.3rem 0.9rem;
+ border-radius: 999px;
+ color: var(--muted);
+ font-size: 0.9rem;
+ text-decoration: none;
+ }
+
+ .tab:hover {
+ color: var(--text);
+ }
+
+ .active {
+ background: var(--accent-dim);
+ color: var(--accent);
+ }
+</style>
diff --git a/src/lib/components/Visibility.svelte b/src/lib/components/Visibility.svelte
new file mode 100644
index 0000000..94f71c0
--- /dev/null
+++ b/src/lib/components/Visibility.svelte
@@ -0,0 +1,12 @@
+<!-- src/lib/components/Visibility.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ let { isPublic }: { isPublic: boolean } = $props();
+</script>
+
+<span class="with-icon">
+ <iconsax-icon name={isPublic ? "unlock" : "lock"} type="bulk" size="14"></iconsax-icon>
+ {isPublic ? "public" : "private"}
+</span>
diff --git a/src/lib/fonts/IBMPlexSans-Bold.woff2 b/src/lib/fonts/IBMPlexSans-Bold.woff2
new file mode 100644
index 0000000..486c376
Binary files /dev/null and b/src/lib/fonts/IBMPlexSans-Bold.woff2 differ
diff --git a/src/lib/fonts/IBMPlexSans-Medium.woff2 b/src/lib/fonts/IBMPlexSans-Medium.woff2
new file mode 100644
index 0000000..ce72c05
Binary files /dev/null and b/src/lib/fonts/IBMPlexSans-Medium.woff2 differ
diff --git a/src/lib/fonts/IBMPlexSans-Regular.woff2 b/src/lib/fonts/IBMPlexSans-Regular.woff2
new file mode 100644
index 0000000..136597e
Binary files /dev/null and b/src/lib/fonts/IBMPlexSans-Regular.woff2 differ
diff --git a/src/lib/fonts/IBMPlexSans-SemiBold.woff2 b/src/lib/fonts/IBMPlexSans-SemiBold.woff2
new file mode 100644
index 0000000..78cbe9a
Binary files /dev/null and b/src/lib/fonts/IBMPlexSans-SemiBold.woff2 differ
diff --git a/src/lib/index.ts b/src/lib/index.ts
new file mode 100644
index 0000000..cd1f528
--- /dev/null
+++ b/src/lib/index.ts
@@ -0,0 +1,42 @@
+/* src/lib/index.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+// Formatting shared by pages; safe on the client
+
+export const mainSite = "https://doughmination.gay";
+
+export function fmtDate(unix: number | null | undefined): string {
+ if (!unix) return "";
+ return new Date(unix * 1000).toISOString().slice(0, 16).replace("T", " ");
+}
+
+export function fmtBytes(bytes: number): string {
+ if (bytes < 1024) return `${bytes} B`;
+ if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
+}
+
+export function ago(seconds: number): string {
+ if (seconds < 90) return `${Math.max(0, Math.round(seconds))}s`;
+ if (seconds < 5400) return `${Math.round(seconds / 60)}m`;
+ if (seconds < 172800) return `${Math.round(seconds / 3600)}h`;
+ return `${Math.round(seconds / 86400)}d`;
+}
+
+export interface Profile {
+ name: string | null;
+ username: string | null;
+ picture: string | null;
+}
+
+export function displayName(profile: Profile & { sub?: string }): string {
+ return profile.name ?? profile.username ?? profile.sub ?? "user";
+}
+
+/** Clips text for <meta name="description"> */
+export function metaText(text: string, max = 200): string {
+ const flat = text.replace(/\s+/g, " ").trim();
+ if (flat.length <= max) return flat;
+ return flat.slice(0, max - 1).replace(/\s+\S*$/, "") + "…";
+}
diff --git a/src/access.ts b/src/lib/server/access.ts
similarity index 99%
rename from src/access.ts
rename to src/lib/server/access.ts
index 5cacdfc..6f2753a 100644
--- a/src/access.ts
+++ b/src/lib/server/access.ts
@@ -1,4 +1,4 @@
-/* src/access.ts
+/* src/lib/server/access.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/auth.ts b/src/lib/server/auth.ts
similarity index 99%
rename from src/auth.ts
rename to src/lib/server/auth.ts
index 23a6fb7..4db9204 100644
--- a/src/auth.ts
+++ b/src/lib/server/auth.ts
@@ -1,4 +1,4 @@
-/* src/auth.ts
+/* src/lib/server/auth.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/config.ts b/src/lib/server/config.ts
similarity index 91%
rename from src/config.ts
rename to src/lib/server/config.ts
index 3c1ac47..ebb0ac7 100644
--- a/src/config.ts
+++ b/src/lib/server/config.ts
@@ -1,4 +1,4 @@
-/* src/config.ts
+/* src/lib/server/config.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
@@ -15,8 +15,6 @@ export const config = {
port: Number(optional("MINIGIT_PORT", "4010")),
title: optional("MINIGIT_TITLE", "dough-git"),
- staticDir: optional("MINIGIT_STATIC_DIR", "./public"),
-
favicon: optional(
"MINIGIT_FAVICON",
"https://m.doughmination.gay/img/avatars/git.png",
@@ -27,7 +25,7 @@ export const config = {
"A minimal self-hosted git mirror.",
),
- themeColor: optional("MINIGIT_THEME_COLOR", "#060d18"),
+ themeColor: optional("MINIGIT_THEME_COLOR", "#eb459e"),
publicMarker: optional("MINIGIT_PUBLIC_MARKER", "minigit-public"),
diff --git a/src/db.ts b/src/lib/server/db.ts
similarity index 96%
rename from src/db.ts
rename to src/lib/server/db.ts
index ea58d06..424bc17 100644
--- a/src/db.ts
+++ b/src/lib/server/db.ts
@@ -1,4 +1,4 @@
-/* src/db.ts
+/* src/lib/server/db.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/git.ts b/src/lib/server/git.ts
similarity index 99%
rename from src/git.ts
rename to src/lib/server/git.ts
index 18c13c2..c82b891 100644
--- a/src/git.ts
+++ b/src/lib/server/git.ts
@@ -1,4 +1,4 @@
-/* src/git.ts
+/* src/lib/server/git.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/markdown.ts b/src/lib/server/markdown.ts
similarity index 98%
rename from src/markdown.ts
rename to src/lib/server/markdown.ts
index 2ac6dce..8e2116b 100644
--- a/src/markdown.ts
+++ b/src/lib/server/markdown.ts
@@ -1,8 +1,7 @@
-/* src/markdown.ts
+/* src/lib/server/markdown.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
-import { icon } from "./icons.ts";
export function escapeHtml(s: string): string {
return s
@@ -373,20 +372,21 @@ const QUOTE = /^\s{0,3}>/;
const ALERT = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|FROZEN|ASIDE)\]\s*$/i;
+// iconsax names; <iconsax-icon> is a web component the browser fills in
const ALERT_ICON: Record<string, string> = {
- note: "info",
- tip: "lightbulb",
+ note: "info-circle",
+ tip: "lamp-on",
important: "flag",
- warning: "triangle-alert",
- caution: "octagon-alert",
- frozen: "snowflake",
+ warning: "danger",
+ caution: "warning-2",
+ frozen: "cloud-snow",
aside: "wind",
};
function alertBlock(kind: string, body: string[], depth: number): string {
const key = kind.toLowerCase();
const label = key.charAt(0).toUpperCase() + key.slice(1);
- const glyph = icon(ALERT_ICON[key] ?? "info");
+ const glyph = `<iconsax-icon name="${ALERT_ICON[key] ?? "info-circle"}" type="bulk" size="16" class="icon"></iconsax-icon>`;
const inner = blocks(body, depth + 1);
const title = `<p class="md-alert-title">${glyph}${label}</p>`;
return `<div class="md-alert md-alert-${key}">\n${title}\n${inner}\n</div>`;
diff --git a/src/mirror.ts b/src/lib/server/mirror.ts
similarity index 99%
rename from src/mirror.ts
rename to src/lib/server/mirror.ts
index 78566c5..9bdf173 100644
--- a/src/mirror.ts
+++ b/src/lib/server/mirror.ts
@@ -1,4 +1,4 @@
-/* src/mirror.ts
+/* src/lib/server/mirror.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/lib/server/mirrorview.ts b/src/lib/server/mirrorview.ts
new file mode 100644
index 0000000..216e3ec
--- /dev/null
+++ b/src/lib/server/mirrorview.ts
@@ -0,0 +1,136 @@
+/* src/lib/server/mirrorview.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+// How a mirror's last check reads on the repository page
+
+import { ago } from "../index.ts";
+import { mirrorSlug } from "./urls.ts";
+import type { MirrorLink } from "./git.ts";
+import type { MirrorStatus } from "./mirror.ts";
+
+const MIRROR_LABELS: Record<string, { label: string; glyph: string; cls: string }> = {
+ synced: {
+ label: "Up to date",
+ glyph: "tick-circle",
+ cls: "good",
+ },
+ ahead: {
+ label: "Mirror behind",
+ glyph: "arrow-up-01",
+ cls: "warn",
+ },
+ behind: {
+ label: "Local behind",
+ glyph: "arrow-down-01",
+ cls: "warn",
+ },
+ diverged: {
+ label: "Diverged",
+ glyph: "danger",
+ cls: "bad",
+ },
+ out_of_sync: {
+ label: "Out of sync",
+ glyph: "danger",
+ cls: "bad",
+ },
+ denied: {
+ label: "Private or missing",
+ glyph: "lock",
+ cls: "warn",
+ },
+ missing: {
+ label: "Repository missing",
+ glyph: "close-circle",
+ cls: "bad",
+ },
+};
+
+const UNKNOWN_STATE = {
+ label: "Unavailable",
+ glyph: "message-question",
+ cls: "bad",
+};
+
+// A verified state older than this is flagged as stale
+const STALE_AFTER = 24 * 3600;
+
+export interface MirrorRow {
+ kind: string;
+ url: string;
+ slug: string;
+ label: string;
+ glyph: string;
+ cls: string;
+ sha: string;
+ detail: string;
+ note: string;
+ noteCls: string;
+}
+
+export function describeMirror(link: MirrorLink, status: MirrorStatus | null, nowSec: number): MirrorRow {
+ const shown = {
+ kind: link.kind,
+ url: link.url,
+ slug: mirrorSlug(link.kind, link.url),
+ };
+ const idle = {
+ ...shown,
+ glyph: "hourglass",
+ cls: "empty",
+ sha: "",
+ note: "",
+ noteCls: "muted",
+ };
+
+ if (link.isPrivate) {
+ return {
+ ...idle,
+ label: "Not checked (private)",
+ glyph: "lock",
+ detail: "status checks are anonymous",
+ };
+ }
+ if (!status || (!status.state && !status.error)) {
+ return {
+ ...idle,
+ label: "not checked yet",
+ detail: "",
+ };
+ }
+
+ const known = (status.state && MIRROR_LABELS[status.state]) || UNKNOWN_STATE;
+ const sha = status.remoteSha ? status.remoteSha.slice(0, 7) : "";
+ const verifiedAgo = status.okAt !== null ? nowSec - status.okAt : null;
+ const stale = verifiedAgo !== null && verifiedAgo > STALE_AFTER;
+
+ if (status.error) {
+ let note = `${link.kind}: check failed ${ago(nowSec - status.checkedAt)} ago (${status.error})`;
+ if (verifiedAgo !== null) {
+ note += stale
+ ? ` — NOT VERIFIED for ${ago(verifiedAgo)}`
+ : ` — showing last verified state from ${ago(verifiedAgo)} ago`;
+ }
+ return {
+ ...shown,
+ ...known,
+ cls: status.state ? "empty" : "bad",
+ sha,
+ detail: verifiedAgo !== null ? `last verified ${ago(verifiedAgo)} ago` : "never verified",
+ note,
+ noteCls: stale || verifiedAgo === null ? "bad" : "warn",
+ };
+ }
+
+ return {
+ ...shown,
+ ...known,
+ sha,
+ detail: [status.detail, verifiedAgo !== null ? `checked ${ago(verifiedAgo)} ago` : ""]
+ .filter(Boolean)
+ .join(" · "),
+ note: stale ? `${link.kind}: not verified for ${ago(verifiedAgo!)}` : "",
+ noteCls: "bad",
+ };
+}
diff --git a/src/notify.ts b/src/lib/server/notify.ts
similarity index 99%
rename from src/notify.ts
rename to src/lib/server/notify.ts
index 8fad751..acf81ce 100644
--- a/src/notify.ts
+++ b/src/lib/server/notify.ts
@@ -1,4 +1,4 @@
-/* src/notify.ts
+/* src/lib/server/notify.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/lib/server/owner.ts b/src/lib/server/owner.ts
new file mode 100644
index 0000000..8f78806
--- /dev/null
+++ b/src/lib/server/owner.ts
@@ -0,0 +1,80 @@
+/* src/lib/server/owner.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { canRead } from "./access.ts";
+import { findUserBySlug } from "./users.ts";
+import { renderMarkdown, plainSummary } from "./markdown.ts";
+import {
+ PROFILE_REPO,
+ headReadme,
+ isProfileRepo,
+ isRepoPublic,
+ listRepos,
+ repoExists,
+ safeRef,
+ type RepoSummary,
+} from "./git.ts";
+import { notFound } from "./web.ts";
+
+function readable(all: RepoSummary[], viewer: string | null): RepoSummary[] {
+ return all.filter((r) =>
+ canRead({
+ ref: {
+ owner: r.owner,
+ name: r.name,
+ },
+ isPublic: r.isPublic,
+ viewer,
+ }),
+ );
+}
+
+async function profileReadme(owner: string, viewer: string | null) {
+ const ref = safeRef(owner, PROFILE_REPO);
+ if (!ref || !(await repoExists(ref))) return null;
+
+ const isPublic = await isRepoPublic(ref);
+ if (!canRead({ ref, isPublic, viewer })) return null;
+ return headReadme(ref);
+}
+
+/** Everything the profile and repository-list pages show about an owner */
+export async function ownerPage(owner: string, viewer: string | null, withReadme: boolean) {
+ if (!safeRef(owner, "x")) notFound();
+
+ const all = await listRepos();
+ const owned = all.filter((r) => r.owner === owner);
+ const profile = findUserBySlug(owner);
+ if (!profile && owned.length === 0) notFound();
+
+ const repos = readable(
+ owned.filter((r) => !isProfileRepo(r.name)),
+ viewer,
+ );
+ const readme = withReadme ? await profileReadme(owner, viewer) : null;
+
+ return {
+ owner,
+ profile: profile
+ ? {
+ slug: profile.slug,
+ name: profile.name,
+ username: profile.username,
+ picture: profile.picture,
+ createdAt: profile.created_at,
+ }
+ : null,
+ repos,
+ readme: readme
+ ? {
+ path: readme.path,
+ html: renderMarkdown(readme.text),
+ summary: plainSummary(readme.text),
+ }
+ : null,
+ hasProfileRepo: owned.some((r) => isProfileRepo(r.name)),
+ isOwn: viewer === owner,
+ profileRepo: PROFILE_REPO,
+ };
+}
diff --git a/src/repometa.ts b/src/lib/server/repometa.ts
similarity index 90%
rename from src/repometa.ts
rename to src/lib/server/repometa.ts
index cfbe50b..ac17641 100644
--- a/src/repometa.ts
+++ b/src/lib/server/repometa.ts
@@ -1,4 +1,4 @@
-/* src/repometa.ts
+/* src/lib/server/repometa.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/sessions.ts b/src/lib/server/sessions.ts
similarity index 99%
rename from src/sessions.ts
rename to src/lib/server/sessions.ts
index 864de5c..f5e875e 100644
--- a/src/sessions.ts
+++ b/src/lib/server/sessions.ts
@@ -1,4 +1,4 @@
-/* src/sessions.ts
+/* src/lib/server/sessions.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/settings.ts b/src/lib/server/settings.ts
similarity index 98%
rename from src/settings.ts
rename to src/lib/server/settings.ts
index a062d00..918f795 100644
--- a/src/settings.ts
+++ b/src/lib/server/settings.ts
@@ -1,4 +1,4 @@
-/* src/settings.ts
+/* src/lib/server/settings.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/smart-http.ts b/src/lib/server/smart-http.ts
similarity index 94%
rename from src/smart-http.ts
rename to src/lib/server/smart-http.ts
index 921c6af..04aa7d3 100644
--- a/src/smart-http.ts
+++ b/src/lib/server/smart-http.ts
@@ -1,4 +1,4 @@
-/* src/smart-http.ts
+/* src/lib/server/smart-http.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
@@ -60,7 +60,7 @@ export function serviceRpc(opts: RpcOptions): Response {
if (opts.body) {
let input: NodeJS.ReadableStream = Readable.fromWeb(
- opts.body as import("node:stream/web").ReadableStream,
+ opts.body as unknown as import("node:stream/web").ReadableStream,
);
if (opts.gzip) {
input = input.pipe(createGunzip());
@@ -104,7 +104,7 @@ export async function advertiseResponse(
service: GitService,
): Promise<Response> {
const body = await advertiseRefs(repoDir, service);
- return new Response(body, {
+ return new Response(new Uint8Array(body), {
status: 200,
headers: {
"Content-Type": `application/x-${service}-advertisement`,
diff --git a/src/tokens.ts b/src/lib/server/tokens.ts
similarity index 98%
rename from src/tokens.ts
rename to src/lib/server/tokens.ts
index f48107e..999edb3 100644
--- a/src/tokens.ts
+++ b/src/lib/server/tokens.ts
@@ -1,4 +1,4 @@
-/* src/tokens.ts
+/* src/lib/server/tokens.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/lib/server/transport.ts b/src/lib/server/transport.ts
new file mode 100644
index 0000000..d85e018
--- /dev/null
+++ b/src/lib/server/transport.ts
@@ -0,0 +1,135 @@
+/* src/lib/server/transport.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { config } from "./config.ts";
+import { authenticateGit, gitActor } from "./auth.ts";
+import { canRead, canWrite } from "./access.ts";
+import { clearRepoMetadata } from "./repometa.ts";
+import { notifyPush, notifyRepoCreated } from "./notify.ts";
+import { markStale } from "./mirror.ts";
+import { serviceRpc, type GitService } from "./smart-http.ts";
+import {
+ initBareRepo,
+ isRepoPublic,
+ localMirrorRefs,
+ refDir,
+ refSlug,
+ repoExists,
+ trashHasName,
+ type RepoRef,
+} from "./git.ts";
+
+export const GIT_SERVICES: GitService[] = ["git-upload-pack", "git-receive-pack"];
+
+function authChallenge(message = "authentication required"): Response {
+ return new Response(`${message}\n`, {
+ status: 401,
+ headers: { "WWW-Authenticate": 'Basic realm="dough-git"' },
+ });
+}
+
+interface GitGate {
+ response: Response | null;
+ actor: string | null;
+}
+
+const ALLOW = (actor: string | null): GitGate => ({ response: null, actor });
+const DENY = (response: Response): GitGate => ({ response, actor: null });
+
+export async function gitGate(request: Request, ref: RepoRef, needPush: boolean): Promise<GitGate> {
+ const auth = authenticateGit(request.headers.get("authorization") ?? undefined);
+ const actor = gitActor(auth);
+ const exists = await repoExists(ref);
+
+ if (auth.kind === "rejected") {
+ console.warn(`[git] denied ${refSlug(ref)}: ${auth.message}`);
+ return DENY(new Response(`${auth.message}\n`, { status: 403 }));
+ }
+
+ if (needPush) {
+ if (!actor) return DENY(authChallenge());
+
+ if (!exists) {
+ if (actor !== ref.owner) {
+ console.warn(`[git] denied create of ${refSlug(ref)} by ${actor}`);
+ return DENY(
+ new Response(`${actor} can only create repositories under ${actor}/\n`, {
+ status: 403,
+ }),
+ );
+ }
+ if (await trashHasName(ref.owner, ref.name)) {
+ console.warn(`[git] refused auto-create of trashed ${refSlug(ref)}`);
+ return DENY(
+ new Response(
+ `${refSlug(ref)} is in Recently Deleted. Restore it, or delete it ` +
+ `permanently, before pushing to that name again.\n`,
+ { status: 409 },
+ ),
+ );
+ }
+ if (!config.autoCreate) {
+ return DENY(new Response("repository not found\n", { status: 404 }));
+ }
+ await initBareRepo(ref);
+ clearRepoMetadata(ref);
+ console.log(`[git] auto-created ${refSlug(ref)}.git on first push`);
+ notifyRepoCreated(ref, actor, false);
+ return ALLOW(actor);
+ }
+
+ const isPublic = await isRepoPublic(ref);
+ if (!canWrite({ ref, isPublic, viewer: actor })) {
+ console.warn(`[git] denied push to ${refSlug(ref)} by ${actor}`);
+ return DENY(
+ new Response(`${actor} does not have write access to ${refSlug(ref)}\n`, {
+ status: 403,
+ }),
+ );
+ }
+ return ALLOW(actor);
+ }
+
+ if (exists) {
+ const isPublic = await isRepoPublic(ref);
+ if (canRead({ ref, isPublic, viewer: actor })) return ALLOW(actor);
+ }
+ if (auth.kind === "anonymous") return DENY(authChallenge());
+ return DENY(new Response("repository not found\n", { status: 404 }));
+}
+
+/** Serves git-upload-pack or git-receive-pack once the gate lets the request through */
+export async function rpc(request: Request, ref: RepoRef, service: GitService): Promise<Response> {
+ const isPush = service === "git-receive-pack";
+ const gate = await gitGate(request, ref, isPush);
+ if (gate.response) return gate.response;
+
+ const before = isPush ? await localMirrorRefs(ref) : new Map<string, string>();
+ const actor = gate.actor;
+ const isPublic = isPush ? await isRepoPublic(ref) : false;
+
+ return serviceRpc({
+ repoDir: refDir(ref),
+ service,
+ body: request.body,
+ gzip: request.headers.get("content-encoding") === "gzip",
+ onDone: isPush
+ ? (code) => {
+ if (code !== 0) {
+ console.warn(`[git] receive-pack for ${refSlug(ref)} exited ${code}`);
+ return;
+ }
+ void (async () => {
+ try {
+ const after = await localMirrorRefs(ref);
+ markStale(ref);
+ notifyPush(ref, actor ?? "unknown", isPublic, before, after);
+ } catch (err) {
+ console.warn(`[git] post-push processing failed for ${refSlug(ref)}:`, err);
+ }
+ })();
+ }
+ : undefined,
+ });
+}
diff --git a/src/urls.ts b/src/lib/server/urls.ts
similarity index 99%
rename from src/urls.ts
rename to src/lib/server/urls.ts
index c883108..4e35ff5 100644
--- a/src/urls.ts
+++ b/src/lib/server/urls.ts
@@ -1,4 +1,4 @@
-/* src/urls.ts
+/* src/lib/server/urls.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/users.ts b/src/lib/server/users.ts
similarity index 99%
rename from src/users.ts
rename to src/lib/server/users.ts
index f8cf42f..b94e991 100644
--- a/src/users.ts
+++ b/src/lib/server/users.ts
@@ -1,4 +1,4 @@
-/* src/users.ts
+/* src/lib/server/users.ts
* LICENCED DASL-1.0 (c) Clove Twilight
*/
diff --git a/src/lib/server/web.ts b/src/lib/server/web.ts
new file mode 100644
index 0000000..bc29fcd
--- /dev/null
+++ b/src/lib/server/web.ts
@@ -0,0 +1,115 @@
+/* src/lib/server/web.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+// Glue between SvelteKit requests and the git/access modules
+
+import { error, redirect, type RequestEvent } from "@sveltejs/kit";
+import { sessionSlug, type SessionUser } from "./auth.ts";
+import { accessFor, canWrite, type Access } from "./access.ts";
+import {
+ isRepoPublic,
+ listRefs,
+ repoExists,
+ resolveRev,
+ safeRef,
+ type RefList,
+ type RepoRef,
+} from "./git.ts";
+
+/** An error page with a title, like the old messagePage */
+export function fail(title: string, message: string, status = 400): never {
+ error(status, {
+ title,
+ message,
+ });
+}
+
+export function notFound(): never {
+ fail("not found", "No such repository, or you don't have access.", 404);
+}
+
+/** The signed-in user, or off to sign in */
+export function me(event: RequestEvent): SessionUser {
+ const user = event.locals.user;
+ if (user) return user;
+ if (event.request.method === "GET") redirect(303, "/auth/login");
+ fail("forbidden", "Sign in first.", 403);
+}
+
+export function viewerOf(event: RequestEvent): string | null {
+ const user = event.locals.user;
+ return user ? sessionSlug(user) : null;
+}
+
+export function refFrom(event: RequestEvent): RepoRef | null {
+ const { owner, name } = event.params as { owner?: string; name?: string };
+ if (!owner || !name) return null;
+ return safeRef(owner, name);
+}
+
+export interface ViewableRepo {
+ ref: RepoRef;
+ isPublic: boolean;
+ access: Access;
+ refs: RefList;
+ rev: string;
+}
+
+/** A repository this viewer may read, at the revision asked for in ?h= */
+export async function viewable(event: RequestEvent): Promise<ViewableRepo> {
+ const ref = refFrom(event);
+ if (!ref || !(await repoExists(ref))) notFound();
+
+ const isPublic = await isRepoPublic(ref);
+ const access = accessFor({
+ ref,
+ isPublic,
+ viewer: viewerOf(event),
+ });
+ if (access === "none") notFound();
+
+ const refs = await listRefs(ref);
+ const rev = await resolveRev(ref, event.url.searchParams.get("h") ?? undefined, refs);
+ return {
+ ref,
+ isPublic,
+ access,
+ refs,
+ rev,
+ };
+}
+
+/** A repository the signed-in user owns */
+export async function ownedRef(event: RequestEvent): Promise<RepoRef> {
+ const user = event.locals.user;
+ const ref = refFrom(event);
+ if (!user || !ref || ref.owner !== sessionSlug(user) || !(await repoExists(ref))) notFound();
+ return ref;
+}
+
+/** A repository the signed-in user may push to */
+export async function writableRef(event: RequestEvent): Promise<RepoRef> {
+ const ref = refFrom(event);
+ if (!ref || !(await repoExists(ref))) notFound();
+
+ const isPublic = await isRepoPublic(ref);
+ const allowed = canWrite({
+ ref,
+ isPublic,
+ viewer: viewerOf(event),
+ });
+ if (!allowed) notFound();
+ return ref;
+}
+
+/** A form field as a string, "" when missing */
+export function field(form: FormData, name: string): string {
+ const value = form.get(name);
+ return typeof value === "string" ? value : "";
+}
+
+/** The ?h= suffix that keeps a non-default revision across links */
+export function revQuery(rev: string, head: string): string {
+ return rev === head ? "" : `?h=${encodeURIComponent(rev)}`;
+}
diff --git a/src/lib/styles/fonts.css b/src/lib/styles/fonts.css
new file mode 100644
index 0000000..fa41b23
--- /dev/null
+++ b/src/lib/styles/fonts.css
@@ -0,0 +1,67 @@
+/* src/lib/styles/fonts.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+/* IBM Plex Sans for text, same files as doughmination.gay */
+
+@font-face {
+ font-family: "IBM Plex Sans";
+ src: url("../fonts/IBMPlexSans-Regular.woff2") format("woff2");
+ font-weight: 400;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: "IBM Plex Sans";
+ src: url("../fonts/IBMPlexSans-Medium.woff2") format("woff2");
+ font-weight: 500;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: "IBM Plex Sans";
+ src: url("../fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
+ font-weight: 600;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: "IBM Plex Sans";
+ src: url("../fonts/IBMPlexSans-Bold.woff2") format("woff2");
+ font-weight: 700;
+ font-display: swap;
+}
+
+/* Comic Code for anything monospace */
+
+@font-face {
+ font-family: "Comic Code";
+ src: url("https://raw.doughmination.gay/f/Comic-Code/woff2/ComicCode-Regular.woff2") format("woff2");
+ font-weight: 400;
+ font-style: normal;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: "Comic Code";
+ src: url("https://raw.doughmination.gay/f/Comic-Code/woff2/ComicCode-Italic.woff2") format("woff2");
+ font-weight: 400;
+ font-style: italic;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: "Comic Code";
+ src: url("https://raw.doughmination.gay/f/Comic-Code/woff2/ComicCode-Medium.woff2") format("woff2");
+ font-weight: 500;
+ font-style: normal;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: "Comic Code";
+ src: url("https://raw.doughmination.gay/f/Comic-Code/woff2/ComicCode-Bold.woff2") format("woff2");
+ font-weight: 700;
+ font-style: normal;
+ font-display: swap;
+}
diff --git a/src/lib/styles/footer.css b/src/lib/styles/footer.css
new file mode 100644
index 0000000..20c65c1
--- /dev/null
+++ b/src/lib/styles/footer.css
@@ -0,0 +1,122 @@
+/* src/lib/styles/footer.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+/* Sits in the page flow; margin-top: auto pins it to the bottom of short pages */
+footer {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1rem 1.5rem;
+ align-items: center;
+ justify-content: space-between;
+ width: 100%;
+ max-width: 62rem;
+ margin: auto auto 0;
+ padding: 1.25rem 1.5rem;
+ border-top: 1px solid var(--line);
+ color: var(--muted);
+ font-size: 0.85rem;
+}
+
+.footer-line {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.25rem 0.75rem;
+ align-items: center;
+ margin: 0;
+}
+
+.footer-line > span {
+ display: inline-flex;
+ gap: 0.4em;
+ align-items: center;
+}
+
+/* Dot between items, skipped on the first */
+.footer-line > span + span::before {
+ content: "·";
+ margin-right: 0.75rem;
+ color: var(--line);
+}
+
+.footer-brand img {
+ border-radius: 50%;
+}
+
+/* Heart */
+
+.beat {
+ color: var(--accent);
+ animation: beat 1.2s ease-in-out infinite;
+}
+
+.beat svg {
+ width: 1em;
+ height: 1em;
+}
+
+/* Two quick pulses, then a rest, like a heartbeat */
+@keyframes beat {
+ 0%,
+ 40%,
+ 100% {
+ transform: scale(1);
+ }
+ 10%,
+ 30% {
+ transform: scale(1.25);
+ }
+ 20% {
+ transform: scale(1.05);
+ }
+}
+
+/* "Not by AI" badge */
+
+.no-ai {
+ line-height: 0;
+}
+
+.no-ai img {
+ display: block;
+ transition: filter 0.2s ease;
+}
+
+.no-ai:hover img {
+ filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent));
+}
+
+.no-ai:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+}
+
+/* Narrow screens: stack and centre */
+@media (max-width: 40rem) {
+ footer,
+ .footer-line {
+ flex-direction: column;
+ justify-content: center;
+ text-align: center;
+ }
+
+ .footer-line > span + span::before {
+ content: none;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .beat {
+ animation: none;
+ }
+
+ .no-ai img {
+ transition: none;
+ }
+}
+
+@media print {
+ footer {
+ display: none;
+ }
+}
\ No newline at end of file
diff --git a/src/lib/styles/git.css b/src/lib/styles/git.css
new file mode 100644
index 0000000..c5fc7da
--- /dev/null
+++ b/src/lib/styles/git.css
@@ -0,0 +1,378 @@
+/* src/lib/styles/git.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+/* dough-git's own pieces: tables, code, the rendered README */
+
+.mono {
+ font-family: var(--mono);
+ font-size: 0.85rem;
+}
+
+.with-icon {
+ display: inline-flex;
+ gap: 0.35em;
+ align-items: center;
+}
+
+.empty {
+ color: var(--muted);
+ font-style: italic;
+}
+
+.good {
+ color: var(--ok);
+}
+
+.warn {
+ color: var(--warn);
+}
+
+.bad {
+ color: var(--bad);
+}
+
+.right {
+ text-align: right;
+}
+
+.section-title {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ margin: 0.5rem 0 0;
+ font-size: 1.15rem;
+ font-weight: 600;
+}
+
+.field-label {
+ color: var(--muted);
+ font-size: 0.75rem;
+ font-weight: 600;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+ white-space: nowrap;
+}
+
+/* A one-line form: label, input, button */
+.row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.6rem;
+ align-items: center;
+}
+
+.row > input:not([type="checkbox"]) {
+ flex: 1 1 14rem;
+ width: auto;
+}
+
+.row > select {
+ width: auto;
+}
+
+/* Tables */
+
+.table-wrap {
+ overflow-x: auto;
+ border: 1px solid var(--line);
+ border-radius: 1rem;
+ background: var(--raised);
+}
+
+table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: 0.92rem;
+}
+
+th,
+td {
+ padding: 0.6rem 1rem;
+ border-bottom: 1px solid var(--line);
+ text-align: left;
+ vertical-align: middle;
+}
+
+th {
+ color: var(--accent);
+ font-size: 0.7rem;
+ font-weight: 600;
+ letter-spacing: 0.14em;
+ text-transform: uppercase;
+}
+
+tbody tr:last-child td {
+ border-bottom: 0;
+}
+
+tbody tr:hover td {
+ background: rgb(255 255 255 / 2%);
+}
+
+td iconsax-icon {
+ vertical-align: -0.2em;
+ color: var(--accent);
+}
+
+/* Code */
+
+pre.code {
+ margin: 0;
+ padding: 1rem 1.25rem;
+ overflow-x: auto;
+ border: 1px solid var(--line);
+ border-radius: 1rem;
+ background: rgb(0 0 0 / 30%);
+ font-size: 0.85rem;
+ line-height: 1.55;
+}
+
+.panel code,
+.readme code {
+ overflow-wrap: anywhere;
+}
+
+/* Rendered README */
+
+.readme {
+ padding: 1.25rem 1.5rem;
+ overflow-wrap: break-word;
+ border: 1px solid var(--line);
+ border-radius: 1rem;
+ background: var(--raised);
+}
+
+.readme > :first-child,
+.readme .md-alert > :first-child {
+ margin-top: 0;
+}
+
+.readme > :last-child,
+.readme .md-alert > :last-child {
+ margin-bottom: 0;
+}
+
+.readme :is(h1, h2, h3, h4, h5, h6) {
+ margin: 1.5rem 0 0.75rem;
+ font-weight: 600;
+ line-height: 1.25;
+ letter-spacing: -0.01em;
+}
+
+.readme h1 {
+ font-size: 1.6rem;
+}
+
+.readme h2 {
+ font-size: 1.3rem;
+}
+
+.readme h3 {
+ font-size: 1.05rem;
+}
+
+.readme :is(h4, h5, h6) {
+ color: var(--muted);
+ font-size: 0.95rem;
+}
+
+.readme :is(h1, h2) {
+ padding-bottom: 0.3rem;
+ border-bottom: 1px solid var(--line);
+}
+
+.readme :is(p, ul, ol, pre, blockquote, table) {
+ margin: 0.75rem 0;
+}
+
+.readme code {
+ padding: 0.12em 0.35em;
+ border-radius: 0.35rem;
+ background: rgb(255 255 255 / 6%);
+}
+
+.readme pre {
+ padding: 0.75rem 1rem;
+ overflow-x: auto;
+ border: 1px solid var(--line);
+ border-radius: 0.75rem;
+ background: rgb(0 0 0 / 30%);
+}
+
+.readme pre code {
+ padding: 0;
+ background: none;
+ font-size: 0.85rem;
+}
+
+.readme blockquote {
+ padding: 0.1rem 0 0.1rem 1rem;
+ border-left: 3px solid var(--accent-line);
+ color: var(--muted);
+}
+
+.readme :is(ul, ol) {
+ padding-left: 1.5rem;
+}
+
+.readme li {
+ margin: 0.25rem 0;
+}
+
+.readme hr {
+ margin: 1.5rem 0;
+ border: 0;
+ border-top: 1px solid var(--line);
+}
+
+.readme img {
+ max-width: 100%;
+ vertical-align: middle;
+}
+
+.readme table {
+ display: block;
+ width: max-content;
+ max-width: 100%;
+ overflow-x: auto;
+}
+
+.readme th,
+.readme td {
+ border: 1px solid var(--line);
+}
+
+.readme [data-align="center"] {
+ text-align: center;
+}
+
+.readme [data-align="right"] {
+ text-align: right;
+}
+
+.readme del {
+ color: var(--muted);
+}
+
+/* README alerts: > [!NOTE] and friends */
+
+.readme .md-alert {
+ --alert: var(--line);
+ margin: 0.75rem 0;
+ padding: 0.6rem 1rem;
+ border-left: 3px solid var(--alert);
+ border-radius: 0.75rem;
+ background: var(--raised);
+}
+
+.readme .md-alert-title {
+ display: flex;
+ gap: 0.4rem;
+ align-items: center;
+ margin: 0 0 0.5rem;
+ color: var(--alert);
+ font-weight: 600;
+}
+
+.readme .md-alert-note {
+ --alert: #47b6ee;
+}
+
+.readme .md-alert-tip {
+ --alert: #96d94f;
+}
+
+.readme .md-alert-important {
+ --alert: var(--accent);
+}
+
+.readme .md-alert-warning {
+ --alert: var(--warn);
+}
+
+.readme .md-alert-caution {
+ --alert: var(--bad);
+}
+
+.readme .md-alert-frozen {
+ --alert: #b8dfe8;
+}
+
+.readme .md-alert-aside {
+ --alert: #74c2a8;
+ border-left-width: 2px;
+ color: var(--muted);
+}
+
+.readme .md-alert-aside .md-alert-title {
+ font-weight: 400;
+}
+
+/* README pride text: gradient-filled words */
+
+.readme .md-pride {
+ color: var(--text);
+ font-weight: 600;
+}
+
+@supports (background-clip: text) or (-webkit-background-clip: text) {
+ .readme .md-pride {
+ -webkit-background-clip: text;
+ background-clip: text;
+ color: transparent;
+ }
+}
+
+@media (prefers-contrast: more) {
+ .readme .md-pride {
+ background-image: none !important;
+ color: var(--text);
+ -webkit-text-fill-color: var(--text);
+ }
+}
+
+.readme .md-pride a {
+ color: inherit;
+ text-decoration: underline;
+}
+
+.readme .md-pride code {
+ color: var(--muted);
+ -webkit-text-fill-color: var(--muted);
+}
+.readme .md-pride-gay {
+ background-image: linear-gradient(96deg, #13a888, #26ceaa, #98e8c1, #7bade2, #918cdf);
+}
+
+.readme .md-pride-lesbian {
+ background-image: linear-gradient(96deg, #ec7151, #e8782e, #ee9d67, #f2f7fb, #d675af, #ee63b5);
+}
+
+.readme .md-pride-bisexual {
+ background-image: linear-gradient(96deg, #ee64ab, #bf80ba, #6894ee);
+}
+
+.readme .md-pride-transgender {
+ background-image: linear-gradient(96deg, #67c9ee, #f5a9b8, #f2f7fb, #f5a9b8, #67c9ee);
+}
+
+.readme .md-pride-pansexual {
+ background-image: linear-gradient(96deg, #ee65a7, #e6c619, #37aae9);
+}
+
+.readme .md-pride-asexual {
+ background-image: linear-gradient(96deg, #8fa4bc, #c3d3e2, #f2f7fb, #ec54ec);
+}
+
+.readme .md-pride-aromantic {
+ background-image: linear-gradient(96deg, #3fab44, #a7d379, #f2f7fb, #c3d3e2, #8fa4bc);
+}
+
+.readme .md-pride-nonbinary {
+ background-image: linear-gradient(96deg, #eae446, #f2f7fb, #b480dc, #8fa4bc);
+}
+
+.readme .md-pride-queer {
+ background-image: linear-gradient(96deg, #ef6d6d, #e68a19, #e6d719, #13ac41, #7994dd, #c578d5);
+}
diff --git a/src/lib/styles/global.css b/src/lib/styles/global.css
new file mode 100644
index 0000000..0fec48e
--- /dev/null
+++ b/src/lib/styles/global.css
@@ -0,0 +1,121 @@
+/* src/lib/styles/global.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+* {
+ box-sizing: border-box;
+}
+
+/* <iconsax-icon> renders its <svg> inside itself, so size that via `... svg` selectors */
+iconsax-icon {
+ display: inline-flex;
+ flex-shrink: 0;
+}
+
+html {
+ height: 100%;
+}
+
+body {
+ display: flex;
+ position: relative;
+ flex-direction: column;
+ min-height: 100%;
+ margin: 0;
+ font-size: 1rem;
+ line-height: 1.6;
+}
+
+/* Keeps page sections laid out as before they were wrapped in <main> */
+main {
+ display: flex;
+ flex-direction: column;
+}
+
+a {
+ color: var(--text);
+ text-decoration-color: rgb(235 69 158 / 55%);
+ text-underline-offset: 0.2em;
+}
+
+a:hover {
+ color: #fff;
+ text-decoration-color: var(--accent);
+}
+
+h1 {
+ line-height: 1.25;
+ text-wrap: balance;
+}
+
+br {
+ display: block;
+ content: "";
+ margin-bottom: 1em;
+}
+
+/* Hero */
+
+/* The background image lives in the header"s .backdrop */
+.hero {
+ padding-block: 4rem 2rem;
+}
+
+.eyebrow {
+ margin: 0 0 0.5rem;
+ color: var(--accent);
+ font-size: 0.75rem;
+ font-weight: 600;
+ letter-spacing: 0.14em;
+ text-transform: uppercase;
+}
+
+.hero h1 {
+ margin: 0 0 0.25rem;
+ font-size: clamp(2.75rem, 9vw, 4.5rem);
+ font-weight: 700;
+ letter-spacing: -0.03em;
+}
+
+.subtitle {
+ margin: 0 0 1.25rem;
+ color: var(--muted);
+ font-size: clamp(1.05rem, 2.5vw, 1.25rem);
+}
+
+.lede {
+ max-width: 36rem;
+ margin: 0 0 2rem;
+ color: #cfc9d6;
+}
+
+.intro {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1.5rem 2.5rem;
+ align-items: flex-start;
+}
+
+.intro .lede {
+ flex: 1 1 20rem;
+ margin: 0;
+}
+
+.wrap {
+ width: 100%;
+ max-width: 62rem;
+ margin: 0 auto;
+ padding-inline: 1.5rem;
+}
+
+@media print {
+ .hero {
+ display: none;
+ }
+ .lede {
+ display: none;
+ }
+ .wrap {
+ display: none;
+ }
+}
\ No newline at end of file
diff --git a/src/lib/styles/header.css b/src/lib/styles/header.css
new file mode 100644
index 0000000..d2ba161
--- /dev/null
+++ b/src/lib/styles/header.css
@@ -0,0 +1,94 @@
+/* src/lib/styles/header.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+/* Backdrop */
+
+.backdrop {
+ position: absolute;
+ top: 0;
+ right: 0;
+ left: 0;
+ z-index: -1;
+ height: 30rem;
+ overflow: hidden;
+ pointer-events: none;
+}
+
+.backdrop::before {
+ content: "";
+ position: absolute;
+ inset: 0;
+ background: url("/background.avif") center / cover no-repeat;
+ opacity: 0.5;
+}
+
+.backdrop::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ background:
+ linear-gradient(rgb(11 10 13 / 55%), rgb(11 10 13 / 80%) 55%, var(--bg)),
+ radial-gradient(70% 60% at 20% 30%, rgb(235 69 158 / 12%), transparent 70%);
+}
+
+/* Top bar */
+
+header {
+ position: relative;
+ z-index: 2;
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1rem 1.5rem;
+ align-items: center;
+ justify-content: space-between;
+ width: 100%;
+ max-width: 62rem;
+ margin: 0 auto;
+ padding: 1.25rem 1.5rem;
+}
+
+header nav {
+ display: flex;
+ gap: 1.25rem;
+ font-size: 0.9rem;
+}
+
+header nav a {
+ display: inline-flex;
+ gap: 0.4em;
+ align-items: center;
+ color: var(--muted);
+ text-decoration: none;
+}
+
+header nav a:hover {
+ color: var(--text);
+}
+
+.brand {
+ display: inline-flex;
+ gap: 0.6rem;
+ align-items: center;
+ font-weight: 600;
+ letter-spacing: 0.01em;
+ text-decoration: none;
+}
+
+.brand img {
+ border-radius: 50%;
+ outline: 1px solid var(--line);
+}
+
+.nav-icon,
+.nav-icon svg {
+ width: 1.2em;
+ height: 1.2em;
+ flex-shrink: 0;
+}
+
+@media print {
+ header{
+ display: none;
+ }
+}
\ No newline at end of file
diff --git a/src/lib/styles/theme.css b/src/lib/styles/theme.css
new file mode 100644
index 0000000..6c70f84
--- /dev/null
+++ b/src/lib/styles/theme.css
@@ -0,0 +1,27 @@
+/* src/lib/styles/theme.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+/* doughmination.gay's tokens, plus the few an app needs on top */
+:root {
+ --bg: #0b0a0d;
+ --raised: rgb(255 255 255 / 3.5%);
+ --line: rgb(255 255 255 / 9%);
+ --text: #ece9ef;
+ --muted: #a49eab;
+ --accent: #eb459e;
+ --accent-dim: rgb(235 69 158 / 14%);
+ --accent-line: rgb(235 69 158 / 40%);
+
+ --ok: #7fd98b;
+ --warn: #f2c46d;
+ --bad: #ff8a9a;
+ --on-accent: #1a0611;
+
+ --mono: "Comic Code", ui-monospace, "Cascadia Code", Menlo, monospace;
+
+ color-scheme: dark;
+ font-family: "IBM Plex Sans", system-ui, sans-serif;
+ background: var(--bg);
+ color: var(--text);
+}
diff --git a/src/lib/styles/ui.css b/src/lib/styles/ui.css
new file mode 100644
index 0000000..233d328
--- /dev/null
+++ b/src/lib/styles/ui.css
@@ -0,0 +1,344 @@
+/* src/lib/styles/ui.css
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+/* App controls in the doughmination.gay look: raised surfaces, hairlines, accent rings */
+
+/* app.html's wrapper; a class, since the CSP allows no style attributes */
+.app {
+ display: contents;
+}
+
+/* Monospace */
+
+code,
+kbd,
+pre,
+samp {
+ font-family: var(--mono);
+ font-size: 0.9em;
+}
+
+::selection {
+ background: var(--accent);
+ color: var(--on-accent);
+}
+
+/* Page width, same as the header and footer */
+
+.page {
+ display: flex;
+ flex-direction: column;
+ gap: 1.25rem;
+ width: 100%;
+ max-width: 62rem;
+ margin: 0 auto;
+ padding: 2rem 1.5rem 3rem;
+}
+
+.page.narrow {
+ max-width: 34rem;
+}
+
+.page-head h1 {
+ margin: 0;
+ font-size: clamp(1.75rem, 5vw, 2.5rem);
+ font-weight: 700;
+ letter-spacing: -0.02em;
+}
+
+.page-head p {
+ margin: 0.25rem 0 0;
+}
+
+/* Panels: web's .card without the hover lift, for things you work in */
+
+.panel {
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+ padding: 1.25rem 1.5rem;
+ border: 1px solid var(--line);
+ border-radius: 1rem;
+ background: var(--raised);
+}
+
+.panel h2 {
+ margin: 0;
+ font-size: 1.15rem;
+ font-weight: 600;
+}
+
+/* Buttons */
+
+button,
+.btn {
+ display: inline-flex;
+ gap: 0.4em;
+ align-items: center;
+ justify-content: center;
+ padding: 0.4rem 0.9rem;
+ border: 1px solid var(--line);
+ /* Soft corners: a full pill curve clips text once a button wraps */
+ border-radius: 0.75rem;
+ background: var(--raised);
+ color: inherit;
+ font: inherit;
+ font-size: 0.9rem;
+ line-height: 1.35;
+ text-decoration: none;
+ cursor: pointer;
+ transition:
+ border-color 0.15s ease,
+ background 0.15s ease,
+ color 0.15s ease,
+ filter 0.15s ease;
+}
+
+button:hover:not(:disabled),
+.btn:hover:not([aria-disabled="true"]) {
+ border-color: var(--accent-line);
+ color: var(--text);
+}
+
+button:disabled,
+.btn[aria-disabled="true"] {
+ opacity: 0.4;
+ cursor: default;
+}
+
+button.primary,
+.btn.primary {
+ border-color: var(--accent);
+ background: var(--accent);
+ color: var(--on-accent);
+ font-weight: 600;
+}
+
+button.primary:hover:not(:disabled),
+.btn.primary:hover {
+ color: var(--on-accent);
+ filter: brightness(1.12);
+}
+
+button.danger,
+.btn.danger {
+ color: var(--bad);
+}
+
+button.danger:hover:not(:disabled) {
+ border-color: var(--bad);
+}
+
+button.small,
+.btn.small {
+ padding: 0.25rem 0.7rem;
+ font-size: 0.82rem;
+}
+
+button iconsax-icon svg,
+.btn iconsax-icon svg {
+ width: 1.1em;
+ height: 1.1em;
+}
+
+.buttons {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.5rem;
+ align-items: center;
+}
+
+form.inline {
+ display: inline;
+}
+
+/* Fields */
+
+input,
+select,
+textarea {
+ width: 100%;
+ padding: 0.5rem 0.75rem;
+ border: 1px solid var(--line);
+ border-radius: 0.75rem;
+ background: rgb(0 0 0 / 25%);
+ color: var(--text);
+ font: inherit;
+}
+
+textarea {
+ min-height: 12rem;
+ font-family: var(--mono);
+ font-size: 0.875rem;
+ line-height: 1.55;
+ tab-size: 2;
+ resize: vertical;
+}
+
+input[type="checkbox"],
+input[type="radio"] {
+ width: auto;
+ accent-color: var(--accent);
+}
+
+input[readonly],
+input:disabled {
+ color: var(--muted);
+}
+
+:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+}
+
+input:focus-visible,
+select:focus-visible,
+textarea:focus-visible {
+ outline-offset: 0;
+ border-color: var(--accent-line);
+}
+
+.field {
+ display: flex;
+ flex-direction: column;
+ gap: 0.35rem;
+}
+
+.field > span,
+.field > legend {
+ color: var(--muted);
+ font-size: 0.75rem;
+ font-weight: 600;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+}
+
+fieldset {
+ margin: 0;
+ padding: 0;
+ border: 0;
+}
+
+legend {
+ padding: 0;
+}
+
+.check {
+ display: flex;
+ gap: 0.6rem;
+ align-items: flex-start;
+}
+
+.check input {
+ margin-top: 0.35rem;
+}
+
+.stack {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+}
+
+.grid2 {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
+ gap: 1rem;
+}
+
+/* Notices and badges */
+
+.notice {
+ margin: 0;
+ padding: 0.65rem 1rem;
+ border: 1px solid var(--line);
+ border-radius: 0.75rem;
+ background: var(--raised);
+}
+
+.notice.ok {
+ border-color: rgb(127 217 139 / 40%);
+ background: rgb(127 217 139 / 8%);
+}
+
+.notice.error {
+ border-color: rgb(255 138 154 / 45%);
+ background: rgb(255 138 154 / 8%);
+}
+
+.badge {
+ display: inline-block;
+ padding: 0.05rem 0.55rem;
+ border: 1px solid var(--line);
+ border-radius: 999px;
+ color: var(--muted);
+ font-size: 0.75rem;
+ white-space: nowrap;
+}
+
+.badge.accent {
+ border-color: var(--accent-line);
+ background: var(--accent-dim);
+ color: var(--accent);
+}
+
+.badge.danger {
+ border-color: rgb(255 138 154 / 45%);
+ color: var(--bad);
+}
+
+/* Lists of rows */
+
+.rows {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+.rows > li {
+ display: flex;
+ gap: 0.75rem;
+ align-items: center;
+ padding: 0.7rem 0;
+ border-bottom: 1px solid var(--line);
+}
+
+.rows > li:last-child {
+ border-bottom: 0;
+}
+
+.meta {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.4rem;
+ align-items: center;
+ margin: 0.15rem 0 0;
+}
+
+.pager {
+ display: flex;
+ gap: 0.75rem;
+ align-items: center;
+}
+
+/* Text helpers */
+
+.muted {
+ color: var(--muted);
+}
+
+.small {
+ font-size: 0.85rem;
+}
+
+.grow {
+ flex: 1;
+ min-width: 0;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ button,
+ .btn {
+ transition: none;
+ }
+}
diff --git a/src/params.ts b/src/params.ts
new file mode 100644
index 0000000..51f429a
--- /dev/null
+++ b/src/params.ts
@@ -0,0 +1,13 @@
+/* src/params.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { defineParams } from "@sveltejs/kit/params";
+
+export const params = defineParams({
+ // A repository name: anything but the owner's repository listing
+ repo: (param) => (param !== "+repos" ? param : undefined),
+
+ // The owner's full repository listing, /<owner>/+repos
+ repos: (param) => (param === "+repos" ? param : undefined),
+});
diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte
new file mode 100644
index 0000000..e6fd830
--- /dev/null
+++ b/src/routes/+error.svelte
@@ -0,0 +1,32 @@
+<!-- src/routes/+error.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { page } from "$app/state";
+ import Meta from "#lib/components/Meta.svelte";
+
+ const notFound = $derived(page.status === 404 && !page.error?.title);
+ const title = $derived(page.error?.title ?? (notFound ? "not found" : "something went wrong"));
+ const message = $derived(notFound ? "There's nothing at that address." : (page.error?.message ?? ""));
+</script>
+
+<Meta {title} description={message} noindex />
+
+<div class="page narrow">
+ <section class="panel">
+ <p class="eyebrow">Error {page.status}</p>
+ <h1>{title}</h1>
+ <p class="muted">{message}</p>
+ <p>
+ <a class="btn" href="/"><iconsax-icon name="arrow-left-01" type="bulk" size="16"></iconsax-icon>all repositories</a>
+ </p>
+ </section>
+</div>
+
+<style>
+ h1,
+ p {
+ margin: 0;
+ }
+</style>
diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts
new file mode 100644
index 0000000..cdf67f4
--- /dev/null
+++ b/src/routes/+layout.server.ts
@@ -0,0 +1,28 @@
+/* src/routes/+layout.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { LayoutServerLoad } from "./$types";
+import { config } from "#lib/server/config.ts";
+import { sessionSlug } from "#lib/server/auth.ts";
+
+export const load: LayoutServerLoad = ({ locals }) => {
+ const user = locals.user;
+ return {
+ site: {
+ title: config.title,
+ favicon: config.favicon,
+ description: config.description,
+ baseUrl: config.baseUrl,
+ themeColor: config.themeColor,
+ },
+ user: user
+ ? {
+ slug: sessionSlug(user),
+ name: user.name,
+ username: user.username,
+ picture: user.picture,
+ }
+ : null,
+ };
+};
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
new file mode 100644
index 0000000..cd08289
--- /dev/null
+++ b/src/routes/+layout.svelte
@@ -0,0 +1,27 @@
+<!-- src/routes/+layout.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import "#lib/styles/fonts.css";
+ import "#lib/styles/theme.css";
+ import "#lib/styles/global.css";
+ import "#lib/styles/ui.css";
+ import "#lib/styles/git.css";
+ import Header from "#lib/components/Header.svelte";
+ import Footer from "#lib/components/Footer.svelte";
+
+ let { data, children } = $props();
+</script>
+
+<svelte:head>
+ <meta name="theme-color" content={data.site.themeColor} />
+ <link rel="icon" href={data.site.favicon} />
+ <link rel="apple-touch-icon" href={data.site.favicon} />
+</svelte:head>
+
+<Header />
+<main>
+ {@render children()}
+</main>
+<Footer />
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts
new file mode 100644
index 0000000..0b24724
--- /dev/null
+++ b/src/routes/+page.server.ts
@@ -0,0 +1,32 @@
+/* src/routes/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { canRead, sharedWith } from "#lib/server/access.ts";
+import { isProfileRepo, listRepos } from "#lib/server/git.ts";
+import { viewerOf } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const viewer = viewerOf(event);
+ const shared = viewer ? new Set(sharedWith(viewer).map((r) => `${r.owner}/${r.name}`)) : null;
+
+ const repos = (await listRepos())
+ .filter((r) => !isProfileRepo(r.name))
+ .filter((r) =>
+ canRead({
+ ref: {
+ owner: r.owner,
+ name: r.name,
+ },
+ isPublic: r.isPublic,
+ viewer,
+ }),
+ )
+ .map((r) => ({
+ ...r,
+ shared: shared?.has(`${r.owner}/${r.name}`) ?? false,
+ }));
+
+ return { repos };
+};
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
new file mode 100644
index 0000000..da1ae40
--- /dev/null
+++ b/src/routes/+page.svelte
@@ -0,0 +1,21 @@
+<!-- src/routes/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import Meta from "#lib/components/Meta.svelte";
+ import RepoTable from "#lib/components/RepoTable.svelte";
+
+ let { data } = $props();
+</script>
+
+<Meta title={data.site.title} />
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">git mirror</p>
+ <h1>Repositories</h1>
+ </div>
+
+ <RepoTable repos={data.repos} showOwner empty="no repositories visible" />
+</div>
diff --git a/src/routes/[owner]/+page.server.ts b/src/routes/[owner]/+page.server.ts
new file mode 100644
index 0000000..0b4e5de
--- /dev/null
+++ b/src/routes/[owner]/+page.server.ts
@@ -0,0 +1,9 @@
+/* src/routes/[owner]/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { ownerPage } from "#lib/server/owner.ts";
+import { viewerOf } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = (event) => ownerPage(event.params.owner, viewerOf(event), true);
diff --git a/src/routes/[owner]/+page.svelte b/src/routes/[owner]/+page.svelte
new file mode 100644
index 0000000..e06f90e
--- /dev/null
+++ b/src/routes/[owner]/+page.svelte
@@ -0,0 +1,53 @@
+<!-- src/routes/[owner]/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { displayName } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import OwnerHead from "#lib/components/OwnerHead.svelte";
+ import RepoTable from "#lib/components/RepoTable.svelte";
+
+ let { data } = $props();
+
+ const PREVIEW = 6;
+
+ const name = $derived(data.profile ? displayName(data.profile) : data.owner);
+ const preview = $derived(data.repos.slice(0, PREVIEW));
+ const profileHref = $derived(`/${data.owner}/${data.profileRepo}`);
+</script>
+
+<Meta
+ title={name}
+ description={data.readme?.summary || `${name} (@${data.owner}) on ${data.site.title}.`}
+ noindex={!data.repos.some((r) => r.isPublic) && !data.readme}
+/>
+
+<div class="page">
+ <OwnerHead owner={data.owner} profile={data.profile} active="profile" />
+
+ {#if data.readme}
+ <article class="readme">{@html data.readme.html}</article>
+ {#if data.isOwn}
+ <p class="muted"><a href={profileHref}>{data.profileRepo}/{data.readme.path}</a></p>
+ {/if}
+ {:else if data.isOwn && data.hasProfileRepo}
+ <p class="panel muted">
+ <a href={profileHref}>{data.profileRepo}</a> has no <code>README.md</code> yet. Push one and it shows up here.
+ </p>
+ {:else if data.isOwn}
+ <form method="post" action="/new?/create" class="panel row">
+ <input type="hidden" name="name" value={data.profileRepo} />
+ <span class="field-label with-icon"><iconsax-icon name="document" type="bulk" size="16"></iconsax-icon>profile readme</span>
+ <span class="muted grow">Create <code>{data.profileRepo}</code> and its README.md shows up here.</span>
+ <button type="submit" class="primary"><iconsax-icon name="add" type="bulk" size="16"></iconsax-icon>create</button>
+ </form>
+ {/if}
+
+ <h2 class="section-title">Repositories</h2>
+ <RepoTable repos={preview} showOwner={false} empty="nothing here yet" />
+
+ {#if data.repos.length > preview.length}
+ <p class="muted"><a href="/{data.owner}/+repos">all {data.repos.length} repositories →</a></p>
+ {/if}
+</div>
diff --git a/src/routes/[owner]/[list=repos]/+page.server.ts b/src/routes/[owner]/[list=repos]/+page.server.ts
new file mode 100644
index 0000000..fec6b2d
--- /dev/null
+++ b/src/routes/[owner]/[list=repos]/+page.server.ts
@@ -0,0 +1,9 @@
+/* src/routes/[owner]/[list=repos]/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { ownerPage } from "#lib/server/owner.ts";
+import { viewerOf } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = (event) => ownerPage(event.params.owner, viewerOf(event), false);
diff --git a/src/routes/[owner]/[list=repos]/+page.svelte b/src/routes/[owner]/[list=repos]/+page.svelte
new file mode 100644
index 0000000..e8bcabf
--- /dev/null
+++ b/src/routes/[owner]/[list=repos]/+page.svelte
@@ -0,0 +1,27 @@
+<!-- src/routes/[owner]/[list=repos]/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { displayName } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import OwnerHead from "#lib/components/OwnerHead.svelte";
+ import RepoTable from "#lib/components/RepoTable.svelte";
+
+ let { data } = $props();
+
+ const name = $derived(data.profile ? displayName(data.profile) : data.owner);
+</script>
+
+<Meta
+ title="{name} repositories"
+ description="Repositories owned by {name} (@{data.owner}) on {data.site.title}."
+ noindex={!data.repos.some((r) => r.isPublic)}
+/>
+
+<div class="page">
+ <OwnerHead owner={data.owner} profile={data.profile} active="repos" />
+
+ <h2 class="section-title">Repositories</h2>
+ <RepoTable repos={data.repos} showOwner={false} empty="nothing here yet" />
+</div>
diff --git a/src/routes/[owner]/[name=repo]/+page.server.ts b/src/routes/[owner]/[name=repo]/+page.server.ts
new file mode 100644
index 0000000..d114452
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/+page.server.ts
@@ -0,0 +1,243 @@
+/* src/routes/[owner]/[name=repo]/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { Actions, PageServerLoad } from "./$types";
+import { config } from "#lib/server/config.ts";
+import { sessionSlug } from "#lib/server/auth.ts";
+import { findUserBySlug } from "#lib/server/users.ts";
+import { getSettings } from "#lib/server/settings.ts";
+import { clearRepoMetadata } from "#lib/server/repometa.ts";
+import { notifyRepoDeleted } from "#lib/server/notify.ts";
+import { renderMarkdown, plainSummary } from "#lib/server/markdown.ts";
+import { describeMirror } from "#lib/server/mirrorview.ts";
+import {
+ isLevel,
+ listCollaborators,
+ removeCollaborator,
+ setCollaborator,
+} from "#lib/server/access.ts";
+import {
+ MIRROR_KINDS,
+ mirrorHost,
+ mirrorSlug,
+ mirrorUrl,
+ type MirrorKind,
+} from "#lib/server/urls.ts";
+import {
+ checkAllMirrors,
+ dropMirrorStatusKind,
+ getStatuses,
+ needsCheck,
+} from "#lib/server/mirror.ts";
+import {
+ description,
+ isRepoPublic,
+ localMirrorRefs,
+ log,
+ readLinks,
+ readme,
+ refSlug,
+ setDescription,
+ setLinks,
+ setRepoPublic,
+ trashRepo,
+ type MirrorLink,
+ type RepoRef,
+} from "#lib/server/git.ts";
+import {
+ fail,
+ field,
+ me,
+ ownedRef,
+ revQuery,
+ viewable,
+ writableRef,
+} from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const { ref, isPublic, access, refs, rev } = await viewable(event);
+
+ const [commits, rawDescription, links] = await Promise.all([
+ log(ref, rev, 1),
+ description(ref),
+ readLinks(ref),
+ ]);
+ const readmeFile = commits.length ? await readme(ref, rev) : null;
+
+ const user = event.locals.user;
+ const viewer = user ? sessionSlug(user) : null;
+ const isOwner = viewer === ref.owner;
+ const canPush = access === "write";
+
+ const statuses = getStatuses(ref);
+ let localSha: string | null = null;
+ if (links.length > 0) {
+ const localRefs = await localMirrorRefs(ref);
+ localSha = localRefs.get(`refs/heads/${refs.head}`) ?? null;
+
+ if (canPush && getSettings(ref.owner).mirrorAuto) {
+ const due = links.filter((l) => !l.isPrivate && needsCheck(statuses.get(l.kind)));
+ if (due.length > 0) {
+ void checkAllMirrors(ref, due).catch((err) => {
+ console.warn(`[mirror] background check failed for ${refSlug(ref)}:`, err);
+ });
+ }
+ }
+ }
+
+ const nowSec = Math.floor(Date.now() / 1000);
+ const summary = readmeFile ? plainSummary(readmeFile.text) : "";
+
+ return {
+ owner: ref.owner,
+ name: ref.name,
+ isPublic,
+ empty: refs.branches.length === 0,
+ refs,
+ rev,
+ query: revQuery(rev, refs.head),
+ cloneUrl: `${config.baseUrl}/${ref.owner}/${ref.name}.git`,
+ pusher: viewer ?? ref.owner,
+ rawDescription,
+ metaDescription:
+ rawDescription.trim() || summary || `${ref.owner}/${ref.name} — a git repository on ${config.title}.`,
+ readme: readmeFile
+ ? {
+ path: readmeFile.path,
+ html: renderMarkdown(readmeFile.text),
+ }
+ : null,
+ canPush,
+ isOwner,
+ collaborators: isOwner ? listCollaborators(ref) : null,
+ mirrors: links.map((link) => describeMirror(link, statuses.get(link.kind) ?? null, nowSec)),
+ canCheckMirrors: canPush && links.some((l) => !l.isPrivate),
+ mirrorFields: MIRROR_KINDS.map((kind) => {
+ const existing = links.find((l) => l.kind === kind);
+ return {
+ kind,
+ value: existing ? mirrorSlug(kind, existing.url) : "",
+ isPrivate: existing?.isPrivate ?? false,
+ };
+ }),
+ mirrorHosts: MIRROR_KINDS.map(mirrorHost).join(" or "),
+ localSha,
+ };
+};
+
+function back(ref: RepoRef): never {
+ redirect(303, `/${ref.owner}/${ref.name}`);
+}
+
+export const actions: Actions = {
+ description: async (event) => {
+ const ref = await writableRef(event);
+ const form = await event.request.formData();
+ await setDescription(ref, field(form, "description"));
+ back(ref);
+ },
+
+ visibility: async (event) => {
+ const ref = await ownedRef(event);
+ const form = await event.request.formData();
+ await setRepoPublic(ref, form.get("public") === "on");
+ back(ref);
+ },
+
+ delete: async (event) => {
+ const ref = await ownedRef(event);
+ const slug = sessionSlug(me(event));
+ const wasPublic = await isRepoPublic(ref);
+
+ const result = await trashRepo(ref, {
+ deletedAt: Math.floor(Date.now() / 1000),
+ deletedBy: slug,
+ grants: listCollaborators(ref).map((g) => ({
+ slug: g.slug,
+ level: g.level,
+ })),
+ });
+ if (!result.ok) fail("could not delete", result.error ?? "unknown error");
+
+ clearRepoMetadata(ref);
+ notifyRepoDeleted(ref, slug, wasPublic);
+ redirect(303, "/settings/deleted");
+ },
+
+ collaborator: async (event) => {
+ const ref = await ownedRef(event);
+ const form = await event.request.formData();
+ const slug = field(form, "slug").trim().toLowerCase();
+ const levelRaw = field(form, "level") || "read";
+ const level = isLevel(levelRaw) ? levelRaw : "read";
+
+ const invited = findUserBySlug(slug);
+ if (!invited) {
+ fail(
+ "no such user",
+ `Nobody on this instance goes by "${slug}". They have to sign in ` +
+ `to this instance once before they can be added.`,
+ );
+ }
+ if (invited.slug === ref.owner) {
+ fail("already the owner", "You can't add yourself as a collaborator on your own repo.");
+ }
+
+ setCollaborator(ref, invited.slug, level);
+ back(ref);
+ },
+
+ uncollaborate: async (event) => {
+ const ref = await ownedRef(event);
+ const form = await event.request.formData();
+ removeCollaborator(ref, field(form, "slug"));
+ back(ref);
+ },
+
+ mirrors: async (event) => {
+ const ref = await ownedRef(event);
+ const form = await event.request.formData();
+
+ const links: MirrorLink[] = [];
+ const rejected: MirrorKind[] = [];
+ for (const kind of MIRROR_KINDS) {
+ const raw = field(form, kind).trim();
+ if (!raw) continue;
+ const url = mirrorUrl(kind, raw);
+ if (!url) {
+ rejected.push(kind);
+ continue;
+ }
+ links.push({
+ kind,
+ url,
+ isPrivate: form.get(`${kind}_private`) != null,
+ });
+ }
+
+ if (rejected.length > 0) {
+ fail(
+ "that isn't a mirror URL",
+ `The ${rejected.join(" and ")} link was refused. Give the repository as ` +
+ `owner/repo — for example doughmination/dough-git — and it is looked up on ` +
+ `${mirrorHost(rejected[0]!)}.`,
+ );
+ }
+
+ const before = await readLinks(ref);
+ await setLinks(ref, links);
+ for (const old of before) {
+ const still = links.find((l) => l.kind === old.kind && l.url === old.url);
+ if (!still) dropMirrorStatusKind(ref, old.kind);
+ }
+ back(ref);
+ },
+
+ check: async (event) => {
+ const ref = await writableRef(event);
+ await checkAllMirrors(ref, await readLinks(ref));
+ back(ref);
+ },
+};
diff --git a/src/routes/[owner]/[name=repo]/+page.svelte b/src/routes/[owner]/[name=repo]/+page.svelte
new file mode 100644
index 0000000..bc83c91
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/+page.svelte
@@ -0,0 +1,243 @@
+<!-- src/routes/[owner]/[name=repo]/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import RepoNav from "#lib/components/RepoNav.svelte";
+ import RevPicker from "#lib/components/RevPicker.svelte";
+ import Visibility from "#lib/components/Visibility.svelte";
+ import ConfirmForm from "#lib/components/ConfirmForm.svelte";
+
+ let { data } = $props();
+
+ const title = $derived(`${data.owner}/${data.name}`);
+</script>
+
+<Meta {title} description={data.metaDescription} noindex={!data.isPublic} />
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">repository</p>
+ <h1><a class="owner" href="/{data.owner}">{data.owner}</a>/{data.name}</h1>
+ <p class="muted meta">
+ <Visibility isPublic={data.isPublic} />
+ {#if data.canPush && !data.isOwner}
+ <span class="badge accent"><iconsax-icon name="export-arrow-01" type="bulk" size="12"></iconsax-icon> you can push</span>
+ {/if}
+ </p>
+ </div>
+
+ <RepoNav owner={data.owner} name={data.name} active="summary" query={data.query} />
+
+ {#if data.canPush}
+ <form method="post" action="?/description" class="panel row">
+ <label class="field-label with-icon" for="repo-description">
+ <iconsax-icon name="note-2" type="bulk" size="16"></iconsax-icon>description
+ </label>
+ <input
+ id="repo-description"
+ type="text"
+ name="description"
+ maxlength="300"
+ value={data.rawDescription}
+ placeholder="what this repository is for"
+ />
+ <button type="submit"><iconsax-icon name="save-2" type="bulk" size="16"></iconsax-icon>save</button>
+ </form>
+ {:else if data.rawDescription}
+ <p class="muted">{data.rawDescription}</p>
+ {/if}
+
+ <RevPicker refs={data.refs} rev={data.rev} />
+
+ <section class="panel">
+ <span class="field-label with-icon"><iconsax-icon name="import-arrow-01" type="bulk" size="16"></iconsax-icon>clone</span>
+ <code>git clone {data.cloneUrl}</code>
+ </section>
+
+ {#if data.empty && data.canPush}
+ <section class="panel">
+ <p><strong>This repository is empty.</strong> Push to get started:</p>
+ <pre class="code"><code>git remote add mirror {data.cloneUrl}
+git push --mirror mirror</code></pre>
+ <p class="muted">
+ When prompted, the <strong>username</strong> is <code>{data.pusher}</code> and the
+ <strong>password</strong> is a token from <a href="/settings/tokens">settings</a>.
+ </p>
+ </section>
+ {:else if data.empty}
+ <p class="panel empty">This repository is empty.</p>
+ {/if}
+
+ {#if data.mirrors.length > 0 || data.isOwner}
+ <h2 class="section-title"><iconsax-icon name="driver" type="bulk" size="20"></iconsax-icon>External mirrors</h2>
+
+ {#if data.mirrors.length > 0}
+ <section class="panel mirrors">
+ {#each data.mirrors as mirror (mirror.kind)}
+ <div class="mirror-row">
+ <a class="with-icon" href={mirror.url} rel="nofollow noopener noreferrer">
+ <iconsax-icon name="global" type="bulk" size="16"></iconsax-icon>{mirror.slug}
+ </a>
+ <span class="{mirror.cls} with-icon">
+ <iconsax-icon name={mirror.glyph} type="bulk" size="16"></iconsax-icon>{mirror.label}
+ </span>
+ <span class="mono">{mirror.sha}</span>
+ <span class="muted">{mirror.detail}</span>
+ </div>
+ {#if mirror.note}
+ <p class={mirror.noteCls}>{mirror.note}</p>
+ {/if}
+ {/each}
+
+ {#if data.localSha}
+ <div class="mirror-row">
+ <span class="with-icon"><iconsax-icon name="home-2" type="bulk" size="16"></iconsax-icon>local</span>
+ <span class="empty">this repository</span>
+ <span class="mono">{data.localSha.slice(0, 7)}</span>
+ <span></span>
+ </div>
+ {/if}
+
+ {#if data.canCheckMirrors}
+ <form method="post" action="?/check">
+ <button type="submit"><iconsax-icon name="refresh-arrow-01" type="bulk" size="16"></iconsax-icon>check now</button>
+ </form>
+ {/if}
+ </section>
+ {:else}
+ <p class="empty">No mirrors configured.</p>
+ {/if}
+
+ {#if data.isOwner}
+ <form method="post" action="?/mirrors" class="panel">
+ {#each data.mirrorFields as mirror (mirror.kind)}
+ <div class="row">
+ <label class="field-label with-icon" for="mirror-{mirror.kind}">
+ <iconsax-icon name="global" type="bulk" size="16"></iconsax-icon>{mirror.kind}
+ </label>
+ <input
+ id="mirror-{mirror.kind}"
+ type="text"
+ name={mirror.kind}
+ value={mirror.value}
+ placeholder="user/repo"
+ pattern={"[^\\s/]+/[^\\s/]+/?"}
+ autocapitalize="off"
+ spellcheck="false"
+ />
+ <label class="check">
+ <input type="checkbox" name="{mirror.kind}_private" checked={mirror.isPrivate} /> private
+ </label>
+ </div>
+ {/each}
+ <p class="muted small">
+ Give the <code>user/repo</code> on {data.mirrorHosts} — not a full URL. Mark a mirror <em>private</em> to
+ skip status checks — they are anonymous, so a private mirror would otherwise always look unreachable.
+ Clear a field to remove it.
+ </p>
+ <div>
+ <button type="submit"><iconsax-icon name="save-2" type="bulk" size="16"></iconsax-icon>save mirrors</button>
+ </div>
+ </form>
+ {/if}
+ {/if}
+
+ {#if data.readme}
+ <h2 class="section-title"><iconsax-icon name="document-text" type="bulk" size="20"></iconsax-icon>{data.readme.path}</h2>
+ <article class="readme">{@html data.readme.html}</article>
+ {:else if !data.empty}
+ <h2 class="section-title"><iconsax-icon name="document-text" type="bulk" size="20"></iconsax-icon>Readme</h2>
+ <p class="empty">No ReadMe was found, commit one to add a summary</p>
+ {/if}
+
+ {#if data.isOwner && data.collaborators}
+ <h2 class="section-title"><iconsax-icon name="setting-2" type="bulk" size="20"></iconsax-icon>Manage</h2>
+ <div class="buttons">
+ <form method="post" action="?/visibility">
+ <input type="hidden" name="public" value={data.isPublic ? "" : "on"} />
+ <button type="submit">
+ <iconsax-icon name={data.isPublic ? "lock" : "unlock"} type="bulk" size="16"></iconsax-icon>
+ make {data.isPublic ? "private" : "public"}
+ </button>
+ </form>
+ <ConfirmForm action="?/delete" prompt="Delete {title}? It moves to Recently Deleted.">
+ <button type="submit" class="danger"><iconsax-icon name="trash" type="bulk" size="16"></iconsax-icon>delete repository</button>
+ </ConfirmForm>
+ </div>
+
+ <h2 class="section-title"><iconsax-icon name="people" type="bulk" size="20"></iconsax-icon>Collaborators</h2>
+ <p class="muted">
+ People here can see this repository even while it is private. <code>write</code> also lets them push to it.
+ </p>
+ <form method="post" action="?/collaborator" class="panel row">
+ <label class="field-label with-icon" for="collab-slug"><iconsax-icon name="user" type="bulk" size="16"></iconsax-icon>username</label>
+ <input id="collab-slug" type="text" name="slug" placeholder="their handle" pattern="[A-Za-z0-9._\-]+" required />
+ <select name="level" aria-label="access level">
+ <option value="read">read</option>
+ <option value="write">write</option>
+ </select>
+ <button type="submit"><iconsax-icon name="user-add" type="bulk" size="16"></iconsax-icon>add</button>
+ </form>
+
+ <div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>user</th>
+ <th>access</th>
+ <th>added</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each data.collaborators as person (person.slug)}
+ <tr>
+ <td><iconsax-icon name="user" type="bulk" size="14"></iconsax-icon> <a href="/{person.slug}">{person.slug}</a></td>
+ <td class="mono">{person.level}</td>
+ <td class="mono">{fmtDate(person.added_at)}</td>
+ <td>
+ <form method="post" action="?/uncollaborate">
+ <input type="hidden" name="slug" value={person.slug} />
+ <button type="submit" class="small"><iconsax-icon name="user-minus" type="bulk" size="14"></iconsax-icon>remove</button>
+ </form>
+ </td>
+ </tr>
+ {:else}
+ <tr><td colspan="4" class="empty">nobody else has access</td></tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+ {/if}
+</div>
+
+<style>
+ .owner {
+ color: var(--muted);
+ text-decoration: none;
+ }
+
+ .mirrors {
+ gap: 0.5rem;
+ }
+
+ .mirror-row {
+ display: grid;
+ grid-template-columns: minmax(10rem, 1.2fr) minmax(9rem, 1fr) 5rem 2fr;
+ gap: 0.75rem;
+ align-items: center;
+ }
+
+ .mirrors p {
+ margin: 0;
+ }
+
+ @media (max-width: 40rem) {
+ .mirror-row {
+ grid-template-columns: 1fr 1fr;
+ }
+ }
+</style>
diff --git a/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts
new file mode 100644
index 0000000..5e6ffdf
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts
@@ -0,0 +1,23 @@
+/* src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { blob } from "#lib/server/git.ts";
+import { notFound, revQuery, viewable } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const { ref, refs, rev } = await viewable(event);
+ const path = event.params.path;
+
+ const file = await blob(ref, rev, path);
+ if (!file) notFound();
+
+ return {
+ owner: ref.owner,
+ name: ref.name,
+ path,
+ query: revQuery(rev, refs.head),
+ ...file,
+ };
+};
diff --git a/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte
new file mode 100644
index 0000000..ccd95b4
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte
@@ -0,0 +1,51 @@
+<!-- src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtBytes } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import RepoNav from "#lib/components/RepoNav.svelte";
+
+ let { data } = $props();
+
+ const up = $derived(data.path.split("/").slice(0, -1).join("/"));
+ const size = $derived(fmtBytes(data.bytes));
+</script>
+
+<Meta title={data.path} description="{data.path} in {data.owner}/{data.name}." />
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">{data.owner}/{data.name}</p>
+ <h1 class="path">{data.path}</h1>
+ </div>
+
+ <RepoNav owner={data.owner} name={data.name} active="tree" query={data.query} />
+
+ <p class="muted">
+ <a class="with-icon" href="/{data.owner}/{data.name}/tree/{up}{data.query}">
+ <iconsax-icon name="arrow-left-01" type="bulk" size="16"></iconsax-icon>back to {up || "tree"}
+ </a>
+ </p>
+
+ {#if data.binary}
+ <p class="muted">binary file not shown ({size})</p>
+ {:else}
+ {#if data.truncated}
+ <p class="muted">Showing the first part of a {size} file. Clone the repository to read all of it.</p>
+ {/if}
+ <pre class="code"><code>{data.text}</code></pre>
+ {/if}
+</div>
+
+<style>
+ .path {
+ font-size: clamp(1.4rem, 4vw, 2rem);
+ overflow-wrap: anywhere;
+ }
+
+ p {
+ margin: 0;
+ }
+</style>
diff --git a/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts
new file mode 100644
index 0000000..7b4ef8c
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts
@@ -0,0 +1,21 @@
+/* src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { commit } from "#lib/server/git.ts";
+import { notFound, viewable } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const { ref, rev } = await viewable(event);
+
+ const detail = await commit(ref, event.params.sha);
+ if (!detail) notFound();
+
+ return {
+ owner: ref.owner,
+ name: ref.name,
+ query: `?h=${encodeURIComponent(rev)}`,
+ commit: detail,
+ };
+};
diff --git a/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte
new file mode 100644
index 0000000..de23893
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte
@@ -0,0 +1,59 @@
+<!-- src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import RepoNav from "#lib/components/RepoNav.svelte";
+
+ let { data } = $props();
+
+ const commit = $derived(data.commit);
+</script>
+
+<Meta title={commit.subject} description="{commit.subject} — {commit.author} in {data.owner}/{data.name}." />
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">commit</p>
+ <h1>{commit.subject}</h1>
+ </div>
+
+ <RepoNav owner={data.owner} name={data.name} active="log" query={data.query} />
+
+ <dl class="panel commit-meta">
+ <dt class="with-icon"><iconsax-icon name="record-circle" type="bulk" size="14"></iconsax-icon>commit</dt>
+ <dd class="mono">{commit.hash}</dd>
+ <dt class="with-icon"><iconsax-icon name="user" type="bulk" size="14"></iconsax-icon>author</dt>
+ <dd>{commit.author} <{commit.email}></dd>
+ <dt class="with-icon"><iconsax-icon name="clock" type="bulk" size="14"></iconsax-icon>date</dt>
+ <dd>{fmtDate(commit.time)}</dd>
+ </dl>
+
+ {#if commit.body}
+ <pre class="code">{commit.body}</pre>
+ {/if}
+ {#if commit.diffTruncated}
+ <p class="muted">This diff is too large to show in full. Clone the repository to read all of it.</p>
+ {/if}
+ <pre class="code"><code>{commit.diff}</code></pre>
+</div>
+
+<style>
+ .commit-meta {
+ display: grid;
+ grid-template-columns: max-content 1fr;
+ gap: 0.4rem 1.25rem;
+ margin: 0;
+ }
+
+ dt {
+ color: var(--muted);
+ }
+
+ dd {
+ margin: 0;
+ overflow-wrap: anywhere;
+ }
+</style>
diff --git a/src/routes/[owner]/[name=repo]/git-receive-pack/+server.ts b/src/routes/[owner]/[name=repo]/git-receive-pack/+server.ts
new file mode 100644
index 0000000..efe469a
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/git-receive-pack/+server.ts
@@ -0,0 +1,13 @@
+/* src/routes/[owner]/[name=repo]/git-receive-pack/+server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { RequestHandler } from "./$types";
+import { safeRef } from "#lib/server/git.ts";
+import { rpc } from "#lib/server/transport.ts";
+
+export const POST: RequestHandler = ({ params, request }) => {
+ const ref = safeRef(params.owner, params.name);
+ if (!ref) return new Response("bad repo\n", { status: 400 });
+ return rpc(request, ref, "git-receive-pack");
+};
diff --git a/src/routes/[owner]/[name=repo]/git-upload-pack/+server.ts b/src/routes/[owner]/[name=repo]/git-upload-pack/+server.ts
new file mode 100644
index 0000000..11cd073
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/git-upload-pack/+server.ts
@@ -0,0 +1,13 @@
+/* src/routes/[owner]/[name=repo]/git-upload-pack/+server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { RequestHandler } from "./$types";
+import { safeRef } from "#lib/server/git.ts";
+import { rpc } from "#lib/server/transport.ts";
+
+export const POST: RequestHandler = ({ params, request }) => {
+ const ref = safeRef(params.owner, params.name);
+ if (!ref) return new Response("bad repo\n", { status: 400 });
+ return rpc(request, ref, "git-upload-pack");
+};
diff --git a/src/routes/[owner]/[name=repo]/info/refs/+server.ts b/src/routes/[owner]/[name=repo]/info/refs/+server.ts
new file mode 100644
index 0000000..a21fc94
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/info/refs/+server.ts
@@ -0,0 +1,20 @@
+/* src/routes/[owner]/[name=repo]/info/refs/+server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { RequestHandler } from "./$types";
+import { refDir, safeRef } from "#lib/server/git.ts";
+import { advertiseResponse, type GitService } from "#lib/server/smart-http.ts";
+import { GIT_SERVICES, gitGate } from "#lib/server/transport.ts";
+
+export const GET: RequestHandler = async ({ params, url, request }) => {
+ const ref = safeRef(params.owner, params.name);
+ const service = url.searchParams.get("service") as GitService | null;
+ if (!ref || !service || !GIT_SERVICES.includes(service)) {
+ return new Response("only smart HTTP is supported\n", { status: 400 });
+ }
+
+ const gate = await gitGate(request, ref, service === "git-receive-pack");
+ if (gate.response) return gate.response;
+ return advertiseResponse(refDir(ref), service);
+};
diff --git a/src/routes/[owner]/[name=repo]/log/+page.server.ts b/src/routes/[owner]/[name=repo]/log/+page.server.ts
new file mode 100644
index 0000000..7faa5f9
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/log/+page.server.ts
@@ -0,0 +1,19 @@
+/* src/routes/[owner]/[name=repo]/log/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { log } from "#lib/server/git.ts";
+import { revQuery, viewable } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const { ref, refs, rev } = await viewable(event);
+ return {
+ owner: ref.owner,
+ name: ref.name,
+ refs,
+ rev,
+ query: revQuery(rev, refs.head),
+ commits: await log(ref, rev, 100),
+ };
+};
diff --git a/src/routes/[owner]/[name=repo]/log/+page.svelte b/src/routes/[owner]/[name=repo]/log/+page.svelte
new file mode 100644
index 0000000..42a2333
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/log/+page.svelte
@@ -0,0 +1,46 @@
+<!-- src/routes/[owner]/[name=repo]/log/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import RepoNav from "#lib/components/RepoNav.svelte";
+ import RevPicker from "#lib/components/RevPicker.svelte";
+
+ let { data } = $props();
+
+ const title = $derived(`${data.owner}/${data.name}`);
+</script>
+
+<Meta title="{title} log" description="Commit history for {title} on {data.rev}." />
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">log</p>
+ <h1>{title}</h1>
+ </div>
+
+ <RepoNav owner={data.owner} name={data.name} active="log" query={data.query} />
+ <RevPicker refs={data.refs} rev={data.rev} />
+
+ <div class="table-wrap">
+ <table>
+ <tbody>
+ {#each data.commits as commit (commit.hash)}
+ <tr>
+ <td class="mono">{fmtDate(commit.time)}</td>
+ <td>
+ <iconsax-icon name="record-circle" type="bulk" size="14"></iconsax-icon>
+ <a href="/{data.owner}/{data.name}/commit/{commit.hash}{data.query}">{commit.subject}</a>
+ </td>
+ <td class="muted">{commit.author}</td>
+ <td class="mono">{commit.hash.slice(0, 10)}</td>
+ </tr>
+ {:else}
+ <tr><td class="empty">no commits</td></tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+</div>
diff --git a/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts
new file mode 100644
index 0000000..d56d431
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts
@@ -0,0 +1,21 @@
+/* src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { PageServerLoad } from "./$types";
+import { tree } from "#lib/server/git.ts";
+import { revQuery, viewable } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const { ref, refs, rev } = await viewable(event);
+ const path = event.params.path.replace(/\/+$/, "");
+ return {
+ owner: ref.owner,
+ name: ref.name,
+ path,
+ refs,
+ rev,
+ query: revQuery(rev, refs.head),
+ entries: await tree(ref, rev, path),
+ };
+};
diff --git a/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte
new file mode 100644
index 0000000..194b621
--- /dev/null
+++ b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte
@@ -0,0 +1,67 @@
+<!-- src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import Meta from "#lib/components/Meta.svelte";
+ import RepoNav from "#lib/components/RepoNav.svelte";
+ import RevPicker from "#lib/components/RevPicker.svelte";
+
+ let { data } = $props();
+
+ const base = $derived(`/${data.owner}/${data.name}`);
+ const up = $derived(data.path.split("/").slice(0, -1).join("/"));
+
+ function child(name: string): string {
+ return data.path ? `${data.path}/${name}` : name;
+ }
+</script>
+
+<Meta
+ title="{data.owner}/{data.name} tree"
+ description="Files in {data.owner}/{data.name}{data.path ? ` at ${data.path}` : ''}."
+/>
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">tree{data.path ? ` · /${data.path}` : ""}</p>
+ <h1>{data.owner}/{data.name}</h1>
+ </div>
+
+ <RepoNav owner={data.owner} name={data.name} active="tree" query={data.query} />
+ <RevPicker refs={data.refs} rev={data.rev} />
+
+ <div class="table-wrap">
+ <table>
+ <tbody>
+ {#if data.path}
+ <tr>
+ <td class="mono"></td>
+ <td>
+ <iconsax-icon name="arrow-up-01" type="bulk" size="14"></iconsax-icon>
+ <a href="{base}/tree/{up}{data.query}">../</a>
+ </td>
+ <td></td>
+ </tr>
+ {/if}
+ {#each data.entries as entry (entry.name)}
+ <tr>
+ <td class="mono">{entry.mode}</td>
+ <td>
+ {#if entry.type === "tree"}
+ <iconsax-icon name="folder-2" type="bulk" size="14"></iconsax-icon>
+ <a href="{base}/tree/{child(entry.name)}{data.query}">{entry.name}/</a>
+ {:else}
+ <iconsax-icon name="document-text" type="bulk" size="14"></iconsax-icon>
+ <a href="{base}/blob/{child(entry.name)}{data.query}">{entry.name}</a>
+ {/if}
+ </td>
+ <td class="mono right">{entry.size}</td>
+ </tr>
+ {:else}
+ <tr><td colspan="3" class="empty">empty</td></tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+</div>
diff --git a/src/routes/auth/callback/+page.server.ts b/src/routes/auth/callback/+page.server.ts
new file mode 100644
index 0000000..0d979b9
--- /dev/null
+++ b/src/routes/auth/callback/+page.server.ts
@@ -0,0 +1,63 @@
+/* src/routes/auth/callback/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { PageServerLoad } from "./$types";
+import { config } from "#lib/server/config.ts";
+import { OAUTH_COOKIE, SESSION_COOKIE, finishLogin } from "#lib/server/auth.ts";
+import { SESSION_TTL } from "#lib/server/sessions.ts";
+import { fail } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async ({ cookies, url }) => {
+ const tx = cookies.get(OAUTH_COOKIE);
+ cookies.delete(OAUTH_COOKIE, { path: "/" });
+
+ const idpError = url.searchParams.get("error");
+ if (idpError) {
+ console.error(`[auth] provider returned error=${idpError} ${url.searchParams.get("error_description") ?? ""}`);
+ }
+ if (!tx) {
+ console.error(
+ "[auth] no oauth transaction cookie on callback — likely a cookie issue " +
+ "(MINIGIT_BASE_URL scheme vs how you're actually reaching the site, or a " +
+ "host mismatch between /auth/login and /auth/callback).",
+ );
+ }
+
+ const currentUrl = `${config.baseUrl}/auth/callback${url.search}`;
+
+ let session: string | null = null;
+ try {
+ session = await finishLogin(currentUrl, tx);
+ } catch (err) {
+ const e = err as {
+ error?: string;
+ error_description?: string;
+ message?: string;
+ };
+ console.error(
+ "[auth] callback failed:",
+ e?.error ? `error=${e.error}` : "",
+ e?.error_description ? `desc=${e.error_description}` : "",
+ err instanceof Error ? e.message : err,
+ );
+ }
+
+ if (!session) {
+ const message =
+ idpError === "access_denied"
+ ? "Your SSO account isn't allowed to use this instance. Ask an SSO admin to add you to its allowed groups."
+ : "Could not complete sign-in. Please try again.";
+ fail("login failed", message, 403);
+ }
+
+ cookies.set(SESSION_COOKIE, session, {
+ httpOnly: true,
+ secure: config.baseUrl.startsWith("https"),
+ sameSite: "lax",
+ path: "/",
+ maxAge: SESSION_TTL,
+ });
+ redirect(303, "/");
+};
diff --git a/src/routes/auth/callback/+page.svelte b/src/routes/auth/callback/+page.svelte
new file mode 100644
index 0000000..20ac22d
--- /dev/null
+++ b/src/routes/auth/callback/+page.svelte
@@ -0,0 +1,5 @@
+<!-- src/routes/auth/callback/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<!-- Never shown: the server load always redirects or errors -->
diff --git a/src/routes/auth/login/+page.server.ts b/src/routes/auth/login/+page.server.ts
new file mode 100644
index 0000000..525794e
--- /dev/null
+++ b/src/routes/auth/login/+page.server.ts
@@ -0,0 +1,29 @@
+/* src/routes/auth/login/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { PageServerLoad } from "./$types";
+import { config, oidcEnabled } from "#lib/server/config.ts";
+import { OAUTH_COOKIE, startLogin } from "#lib/server/auth.ts";
+import { fail } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async ({ cookies }) => {
+ if (!oidcEnabled) {
+ fail("login unavailable", "Single sign-on (OIDC) is not configured on this instance.", 501);
+ }
+
+ const { redirectUrl, txCookie } = await startLogin();
+ cookies.set(OAUTH_COOKIE, txCookie, {
+ httpOnly: true,
+ secure: config.baseUrl.startsWith("https"),
+ sameSite: "lax",
+ path: "/",
+ maxAge: 600,
+ });
+
+ // Off-site, but only ever to the SSO
+ redirect(303, redirectUrl, {
+ external: [new URL(config.oidc.issuer).origin],
+ });
+};
diff --git a/src/routes/auth/login/+page.svelte b/src/routes/auth/login/+page.svelte
new file mode 100644
index 0000000..3ed198e
--- /dev/null
+++ b/src/routes/auth/login/+page.svelte
@@ -0,0 +1,5 @@
+<!-- src/routes/auth/login/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<!-- Never shown: the server load always redirects or errors -->
diff --git a/src/routes/auth/logout/+page.server.ts b/src/routes/auth/logout/+page.server.ts
new file mode 100644
index 0000000..81000a2
--- /dev/null
+++ b/src/routes/auth/logout/+page.server.ts
@@ -0,0 +1,25 @@
+/* src/routes/auth/logout/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { Actions, PageServerLoad } from "./$types";
+import { config } from "#lib/server/config.ts";
+import { SESSION_COOKIE, logout } from "#lib/server/auth.ts";
+
+// POST so a stray link or image can't sign anyone out
+export const load: PageServerLoad = () => redirect(303, "/");
+
+export const actions: Actions = {
+ default: async ({ cookies }) => {
+ const target = await logout(cookies.get(SESSION_COOKIE));
+ cookies.delete(SESSION_COOKIE, { path: "/" });
+
+ // Home, or on to the SSO's own logout
+ const allowed = [new URL(config.baseUrl).origin];
+ if (config.oidc.issuer) allowed.push(new URL(config.oidc.issuer).origin);
+ redirect(303, target, {
+ external: allowed,
+ });
+ },
+};
diff --git a/src/routes/auth/logout/+page.svelte b/src/routes/auth/logout/+page.svelte
new file mode 100644
index 0000000..81ab3b4
--- /dev/null
+++ b/src/routes/auth/logout/+page.svelte
@@ -0,0 +1,5 @@
+<!-- src/routes/auth/logout/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<!-- Never shown: the server load always redirects or errors -->
diff --git a/src/routes/new/+page.server.ts b/src/routes/new/+page.server.ts
new file mode 100644
index 0000000..ea2002b
--- /dev/null
+++ b/src/routes/new/+page.server.ts
@@ -0,0 +1,55 @@
+/* src/routes/new/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect, type RequestEvent } from "@sveltejs/kit";
+import type { Actions, PageServerLoad } from "./$types";
+import { sessionSlug } from "#lib/server/auth.ts";
+import { clearRepoMetadata } from "#lib/server/repometa.ts";
+import { notifyRepoCreated } from "#lib/server/notify.ts";
+import { getSettings } from "#lib/server/settings.ts";
+import {
+ createRepo,
+ importRepo,
+ refSlug,
+ setRepoPublic,
+ type CreateResult,
+} from "#lib/server/git.ts";
+import { fail, field, me } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = (event) => {
+ return { owner: sessionSlug(me(event)) };
+};
+
+// Shared tail of "create empty" and "import": metadata, visibility, notify
+async function finishCreate(event: RequestEvent, result: CreateResult, verb: string): Promise<never> {
+ if (!result.ok || !result.ref) {
+ const title = result.reserved ? "that name is still reserved" : `could not ${verb} repo`;
+ fail(title, result.error ?? "unknown error", result.reserved ? 409 : 400);
+ }
+
+ const owner = sessionSlug(me(event));
+ clearRepoMetadata(result.ref);
+ const startsPublic = !getSettings(owner).defaultPrivate;
+ if (startsPublic) await setRepoPublic(result.ref, true);
+ notifyRepoCreated(result.ref, owner, startsPublic);
+ redirect(303, `/${result.ref.owner}/${result.ref.name}`);
+}
+
+export const actions: Actions = {
+ create: async (event) => {
+ const owner = sessionSlug(me(event));
+ const form = await event.request.formData();
+ const result = await createRepo(owner, field(form, "name"));
+ return finishCreate(event, result, "create");
+ },
+
+ import: async (event) => {
+ const owner = sessionSlug(me(event));
+ const form = await event.request.formData();
+ const url = field(form, "url");
+ const result = await importRepo(owner, field(form, "name"), url);
+ if (result.ref) console.log(`[import] ${refSlug(result.ref)} from ${url}`);
+ return finishCreate(event, result, "import");
+ },
+};
diff --git a/src/routes/new/+page.svelte b/src/routes/new/+page.svelte
new file mode 100644
index 0000000..afbdd63
--- /dev/null
+++ b/src/routes/new/+page.svelte
@@ -0,0 +1,67 @@
+<!-- src/routes/new/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import Meta from "#lib/components/Meta.svelte";
+
+ let { data } = $props();
+</script>
+
+<Meta title="new repository" noindex />
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">git mirror</p>
+ <h1>New repository</h1>
+ </div>
+
+ <h2 class="section-title"><iconsax-icon name="folder-add" type="bulk" size="20"></iconsax-icon>Empty repository</h2>
+ <form method="post" action="?/create" class="panel row">
+ <span class="mono">{data.owner}/</span>
+ <input type="text" name="name" placeholder="my-project" pattern="[A-Za-z0-9._\-]+" required />
+ <button type="submit" class="primary"><iconsax-icon name="add" type="bulk" size="16"></iconsax-icon>create</button>
+ </form>
+
+ <h2 class="section-title">
+ <iconsax-icon name="import-arrow-01" type="bulk" size="20"></iconsax-icon>Import from another forge
+ </h2>
+ <p class="muted">
+ Copies every branch and tag from a public repository on GitHub, Codeberg, GitLab, or any other forge. The
+ import is a one-off copy, not a live mirror.
+ </p>
+ <form method="post" action="?/import" class="panel stack">
+ <div class="row">
+ <label class="field-label with-icon" for="import-url">
+ <iconsax-icon name="link" type="bulk" size="16"></iconsax-icon>clone url
+ </label>
+ <input
+ id="import-url"
+ type="url"
+ name="url"
+ required
+ placeholder="https://codeberg.org/owner/repo.git"
+ autocapitalize="off"
+ spellcheck="false"
+ />
+ </div>
+ <div class="row">
+ <label class="field-label with-icon" for="import-name">
+ <iconsax-icon name="tag" type="bulk" size="16"></iconsax-icon>name
+ </label>
+ <span class="mono">{data.owner}/</span>
+ <input
+ id="import-name"
+ type="text"
+ name="name"
+ pattern="[A-Za-z0-9._\-]+"
+ placeholder="leave blank to use the source name"
+ />
+ </div>
+ <div>
+ <button type="submit" class="primary">
+ <iconsax-icon name="import-arrow-01" type="bulk" size="16"></iconsax-icon>import
+ </button>
+ </div>
+ </form>
+</div>
diff --git a/src/routes/settings/+layout.server.ts b/src/routes/settings/+layout.server.ts
new file mode 100644
index 0000000..31bafbc
--- /dev/null
+++ b/src/routes/settings/+layout.server.ts
@@ -0,0 +1,11 @@
+/* src/routes/settings/+layout.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import type { LayoutServerLoad } from "./$types";
+import { me } from "#lib/server/web.ts";
+
+// Every settings page needs a signed-in user
+export const load: LayoutServerLoad = (event) => {
+ me(event);
+};
diff --git a/src/routes/settings/+layout.svelte b/src/routes/settings/+layout.svelte
new file mode 100644
index 0000000..d8b934b
--- /dev/null
+++ b/src/routes/settings/+layout.svelte
@@ -0,0 +1,51 @@
+<!-- src/routes/settings/+layout.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { page } from "$app/state";
+ import Tabs from "#lib/components/Tabs.svelte";
+
+ let { children } = $props();
+
+ const active = $derived(
+ page.url.pathname.startsWith("/settings/tokens")
+ ? "tokens"
+ : page.url.pathname.startsWith("/settings/deleted")
+ ? "deleted"
+ : "account",
+ );
+</script>
+
+<div class="page">
+ <div class="page-head">
+ <p class="eyebrow">git mirror</p>
+ <h1>Settings</h1>
+ </div>
+
+ <Tabs
+ {active}
+ items={[
+ {
+ id: "account",
+ label: "account",
+ icon: "user",
+ href: "/settings",
+ },
+ {
+ id: "tokens",
+ label: "tokens",
+ icon: "key",
+ href: "/settings/tokens",
+ },
+ {
+ id: "deleted",
+ label: "recently deleted",
+ icon: "trash",
+ href: "/settings/deleted",
+ },
+ ]}
+ />
+
+ {@render children()}
+</div>
diff --git a/src/routes/settings/+page.server.ts b/src/routes/settings/+page.server.ts
new file mode 100644
index 0000000..fdba1e3
--- /dev/null
+++ b/src/routes/settings/+page.server.ts
@@ -0,0 +1,59 @@
+/* src/routes/settings/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { Actions, PageServerLoad } from "./$types";
+import { accountUrl, sessionSlug } from "#lib/server/auth.ts";
+import { getSettings, setDiscordWebhook, setPrefs } from "#lib/server/settings.ts";
+import { discordWebhookUrl, maskWebhook } from "#lib/server/urls.ts";
+import { fail, field, me } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = (event) => {
+ const slug = sessionSlug(me(event));
+ const settings = getSettings(slug);
+
+ return {
+ slug,
+ // The webhook URL is a credential, so only its masked form reaches the page
+ webhook: settings.discordWebhook ? maskWebhook(settings.discordWebhook) : null,
+ webhookError: settings.discordWebhook ? settings.webhookError : null,
+ webhookErrorAt: settings.webhookErrorAt,
+ defaultPrivate: settings.defaultPrivate,
+ discordPrivate: settings.discordPrivate,
+ mirrorAuto: settings.mirrorAuto,
+ accountUrl: accountUrl(),
+ saved: event.url.searchParams.has("saved"),
+ };
+};
+
+export const actions: Actions = {
+ discord: async (event) => {
+ const slug = sessionSlug(me(event));
+ const form = await event.request.formData();
+ const raw = field(form, "url").trim();
+
+ // Blank clears the webhook; anything else must be a real Discord one
+ const url = raw ? discordWebhookUrl(raw) : null;
+ if (raw && !url) {
+ fail(
+ "not a discord webhook",
+ "That doesn't look like a Discord webhook URL. It should start with " +
+ "https://discord.com/api/webhooks/ — nothing else is accepted.",
+ );
+ }
+ setDiscordWebhook(slug, url);
+ redirect(303, "/settings?saved=1");
+ },
+
+ prefs: async (event) => {
+ const slug = sessionSlug(me(event));
+ const form = await event.request.formData();
+ setPrefs(slug, {
+ defaultPrivate: form.get("default_private") != null,
+ discordPrivate: form.get("discord_private") != null,
+ mirrorAuto: form.get("mirror_auto") != null,
+ });
+ redirect(303, "/settings?saved=1");
+ },
+};
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
new file mode 100644
index 0000000..2ec0ef0
--- /dev/null
+++ b/src/routes/settings/+page.svelte
@@ -0,0 +1,90 @@
+<!-- src/routes/settings/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import ConfirmForm from "#lib/components/ConfirmForm.svelte";
+
+ let { data } = $props();
+</script>
+
+<Meta title="settings" description="Account settings." noindex />
+
+{#if data.saved}
+ <p class="notice ok" role="status">Saved.</p>
+{/if}
+
+<h2 class="section-title"><iconsax-icon name="message-text" type="bulk" size="20"></iconsax-icon>Discord notifications</h2>
+<p class="muted">
+ Announces repositories being created and deleted, and commits being pushed. Only repositories you own are
+ announced, and only to this webhook.
+</p>
+
+<section class="panel">
+ {#if data.webhook}
+ <p class="muted">configured · <code>{data.webhook}</code></p>
+ {:else}
+ <p class="empty">not configured — repository events are not announced anywhere.</p>
+ {/if}
+
+ {#if data.webhookError}
+ <p class="bad">
+ last delivery failed{data.webhookErrorAt ? ` at ${fmtDate(data.webhookErrorAt)}` : ""}: {data.webhookError}
+ </p>
+ {/if}
+
+ <form method="post" action="?/discord" class="row">
+ <label class="field-label with-icon" for="discord-url">
+ <iconsax-icon name="link" type="bulk" size="16"></iconsax-icon>webhook
+ </label>
+ <input id="discord-url" type="url" name="url" autocomplete="off" placeholder="https://discord.com/api/webhooks/…" />
+ <button type="submit" class="primary"><iconsax-icon name="save-2" type="bulk" size="16"></iconsax-icon>save</button>
+ </form>
+
+ {#if data.webhook}
+ <ConfirmForm action="?/discord" prompt="Remove the Discord webhook? Events will stop being announced.">
+ <input type="hidden" name="url" value="" />
+ <button type="submit" class="danger"><iconsax-icon name="trash" type="bulk" size="16"></iconsax-icon>remove webhook</button>
+ </ConfirmForm>
+ {/if}
+</section>
+
+<h2 class="section-title"><iconsax-icon name="slider-horizontal" type="bulk" size="20"></iconsax-icon>Preferences</h2>
+<form method="post" action="?/prefs" class="panel">
+ <label class="check">
+ <input type="checkbox" name="default_private" checked={data.defaultPrivate} />
+ <span>New repositories start private</span>
+ </label>
+ <label class="check">
+ <input type="checkbox" name="discord_private" checked={data.discordPrivate} />
+ <span>
+ Announce activity on private repositories
+ <br /><small class="muted">
+ Off by default: commit subjects and repository names would otherwise leave a private repo for a Discord
+ channel.
+ </small>
+ </span>
+ </label>
+ <label class="check">
+ <input type="checkbox" name="mirror_auto" checked={data.mirrorAuto} />
+ <span>
+ Check mirror status automatically when viewing a repository
+ <br /><small class="muted">Off means mirrors are only checked when you press <em>check now</em>.</small>
+ </span>
+ </label>
+ <div>
+ <button type="submit" class="primary">
+ <iconsax-icon name="save-2" type="bulk" size="16"></iconsax-icon>save preferences
+ </button>
+ </div>
+</form>
+
+<h2 class="section-title"><iconsax-icon name="user" type="bulk" size="20"></iconsax-icon>Account</h2>
+<p class="muted">
+ Your name and avatar come from your SSO account and refresh automatically, so there is nothing to edit
+ here{#if data.accountUrl}
+ — change them on <a href={data.accountUrl}>your SSO account page</a>{/if}. Your owner namespace is
+ <code>{data.slug}</code> and never changes.
+</p>
diff --git a/src/routes/settings/deleted/+page.server.ts b/src/routes/settings/deleted/+page.server.ts
new file mode 100644
index 0000000..8442532
--- /dev/null
+++ b/src/routes/settings/deleted/+page.server.ts
@@ -0,0 +1,80 @@
+/* src/routes/settings/deleted/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { Actions, PageServerLoad } from "./$types";
+import { config } from "#lib/server/config.ts";
+import { sessionSlug } from "#lib/server/auth.ts";
+import { isLevel, setCollaborator } from "#lib/server/access.ts";
+import { findUserBySlug } from "#lib/server/users.ts";
+import { clearRepoMetadata } from "#lib/server/repometa.ts";
+import {
+ listTrash,
+ purgeExpired,
+ purgeFromTrash,
+ refSlug,
+ restoreFromTrash,
+} from "#lib/server/git.ts";
+import { fail, field, me } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = async (event) => {
+ const owner = sessionSlug(me(event));
+
+ for (const gone of await purgeExpired(owner)) {
+ clearRepoMetadata({
+ owner,
+ name: gone.name,
+ });
+ console.log(`[trash] purged ${owner}/${gone.name} past retention`);
+ }
+
+ return {
+ entries: await listTrash(owner),
+ retentionDays: config.trashDays,
+ };
+};
+
+export const actions: Actions = {
+ restore: async (event) => {
+ const owner = sessionSlug(me(event));
+ const form = await event.request.formData();
+
+ const result = await restoreFromTrash(owner, field(form, "entry"));
+ if (!result.ok || !result.meta) fail("could not restore", result.error ?? "unknown error");
+
+ const ref = {
+ owner,
+ name: result.meta.name,
+ };
+ for (const grant of result.meta.grants) {
+ if (!isLevel(grant.level)) continue;
+ if (!findUserBySlug(grant.slug)) {
+ console.warn(`[trash] restoring ${refSlug(ref)}: dropping grant for unknown user ${grant.slug}`);
+ continue;
+ }
+ setCollaborator(ref, grant.slug, grant.level);
+ }
+
+ console.log(`[trash] restored ${refSlug(ref)}`);
+ redirect(303, `/${ref.owner}/${ref.name}`);
+ },
+
+ purge: async (event) => {
+ const owner = sessionSlug(me(event));
+ const form = await event.request.formData();
+ const entry = field(form, "entry");
+
+ const found = (await listTrash(owner)).find((e) => e.entry === entry);
+ if (await purgeFromTrash(owner, entry)) {
+ if (found) {
+ clearRepoMetadata({
+ owner,
+ name: found.name,
+ });
+ }
+ console.log(`[trash] purged ${owner}/${found?.name ?? entry}`);
+ }
+ redirect(303, "/settings/deleted");
+ },
+};
diff --git a/src/routes/settings/deleted/+page.svelte b/src/routes/settings/deleted/+page.svelte
new file mode 100644
index 0000000..35d05d2
--- /dev/null
+++ b/src/routes/settings/deleted/+page.svelte
@@ -0,0 +1,89 @@
+<!-- src/routes/settings/deleted/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+ import ConfirmForm from "#lib/components/ConfirmForm.svelte";
+
+ let { data } = $props();
+
+ const nowSec = Math.floor(Date.now() / 1000);
+
+ function daysLeft(deletedAt: number): number {
+ return Math.ceil((deletedAt + data.retentionDays * 86400 - nowSec) / 86400);
+ }
+</script>
+
+<Meta title="recently deleted" description="Recover deleted repositories." noindex />
+
+<h2 class="section-title"><iconsax-icon name="trash" type="bulk" size="20"></iconsax-icon>Recently deleted</h2>
+<p class="muted">
+ {data.retentionDays > 0
+ ? `Deleted repositories are kept for ${data.retentionDays} days, then purged the next time you open this page.`
+ : "Deleted repositories are kept indefinitely — nothing is purged unless you do it here."}
+ A deleted repository keeps its name reserved, so nothing new can take it until it is restored or purged.
+</p>
+
+<div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>repository</th>
+ <th>deleted</th>
+ <th>by</th>
+ <th>retention</th>
+ <th></th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each data.entries as entry (entry.entry)}
+ <tr>
+ <td>
+ <iconsax-icon name="hierarchy" type="bulk" size="14"></iconsax-icon>
+ {entry.name}
+ {#if entry.degraded}
+ <br /><small class="warn">
+ recovery metadata unreadable — restorable, but collaborators will need re-adding
+ </small>
+ {:else if entry.grants.length}
+ <br /><small class="muted">
+ {entry.grants.length} collaborator{entry.grants.length === 1 ? "" : "s"} will be restored
+ </small>
+ {/if}
+ </td>
+ <td class="mono">{fmtDate(entry.deletedAt)}</td>
+ <td class="muted">{entry.deletedBy}</td>
+ <td>
+ {#if data.retentionDays <= 0}
+ <span class="empty">kept until purged</span>
+ {:else if daysLeft(entry.deletedAt) <= 0}
+ <span class="bad">purged on next visit</span>
+ {:else}
+ <span class={daysLeft(entry.deletedAt) <= 3 ? "bad" : "empty"}>{daysLeft(entry.deletedAt)}d left</span>
+ {/if}
+ </td>
+ <td>
+ <form method="post" action="?/restore">
+ <input type="hidden" name="entry" value={entry.entry} />
+ <button type="submit" class="small"><iconsax-icon name="rotate-left" type="bulk" size="14"></iconsax-icon>restore</button>
+ </form>
+ </td>
+ <td>
+ <ConfirmForm
+ action="?/purge"
+ prompt="Permanently delete {entry.name}? This destroys the git data and cannot be undone."
+ >
+ <input type="hidden" name="entry" value={entry.entry} />
+ <button type="submit" class="small danger"><iconsax-icon name="trash" type="bulk" size="14"></iconsax-icon>delete permanently</button>
+ </ConfirmForm>
+ </td>
+ </tr>
+ {:else}
+ <tr><td colspan="6" class="empty">nothing deleted</td></tr>
+ {/each}
+ </tbody>
+ </table>
+</div>
diff --git a/src/routes/settings/tokens/+page.server.ts b/src/routes/settings/tokens/+page.server.ts
new file mode 100644
index 0000000..d0b0d0e
--- /dev/null
+++ b/src/routes/settings/tokens/+page.server.ts
@@ -0,0 +1,35 @@
+/* src/routes/settings/tokens/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { Actions, PageServerLoad } from "./$types";
+import { config } from "#lib/server/config.ts";
+import { sessionSlug } from "#lib/server/auth.ts";
+import { createToken, listTokens, revokeToken } from "#lib/server/tokens.ts";
+import { field, me } from "#lib/server/web.ts";
+
+export const load: PageServerLoad = (event) => {
+ const slug = sessionSlug(me(event));
+ return {
+ slug,
+ baseUrl: config.baseUrl,
+ tokens: listTokens(slug),
+ };
+};
+
+export const actions: Actions = {
+ create: async (event) => {
+ const user = me(event);
+ const form = await event.request.formData();
+ const newToken = createToken(field(form, "label"), sessionSlug(user), user.sub);
+ // Shown once, straight back on this page; never stored in the clear
+ return { newToken };
+ },
+
+ revoke: async (event) => {
+ const form = await event.request.formData();
+ revokeToken(field(form, "id"), sessionSlug(me(event)));
+ redirect(303, "/settings/tokens");
+ },
+};
diff --git a/src/routes/settings/tokens/+page.svelte b/src/routes/settings/tokens/+page.svelte
new file mode 100644
index 0000000..2225116
--- /dev/null
+++ b/src/routes/settings/tokens/+page.svelte
@@ -0,0 +1,68 @@
+<!-- src/routes/settings/tokens/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<script lang="ts">
+ import { fmtDate } from "#lib";
+ import Meta from "#lib/components/Meta.svelte";
+
+ let { data, form } = $props();
+
+ const remote = $derived(
+ form?.newToken ? data.baseUrl.replace("://", `://${data.slug}:${form.newToken}@`) + `/${data.slug}/<repo>.git` : "",
+ );
+</script>
+
+<Meta title="access tokens" description="Manage git access tokens." noindex />
+
+<h2 class="section-title"><iconsax-icon name="key" type="bulk" size="20"></iconsax-icon>Access tokens</h2>
+<p class="muted">
+ These tokens act as <code>{data.slug}</code>: use that as the git <strong>username</strong> and the token as the
+ <strong>password</strong>. They can only push to repositories under <code>{data.slug}/</code>.
+</p>
+
+{#if form?.newToken}
+ <section class="panel">
+ <p><strong>New token — copy it now, it won't be shown again:</strong></p>
+ <code>{form.newToken}</code>
+ <p class="muted">Ready-to-use remote:<br /><code>git remote add mirror {remote}</code></p>
+ </section>
+{/if}
+
+<form method="post" action="?/create" class="panel row">
+ <label class="field-label with-icon" for="token-label"><iconsax-icon name="tag" type="bulk" size="16"></iconsax-icon>label</label>
+ <input id="token-label" type="text" name="label" placeholder="laptop, backup cron, ..." />
+ <button type="submit" class="primary"><iconsax-icon name="add" type="bulk" size="16"></iconsax-icon>create token</button>
+</form>
+
+<div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>label</th>
+ <th>id</th>
+ <th>created</th>
+ <th>last used</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each data.tokens as token (token.id)}
+ <tr>
+ <td>{token.label}</td>
+ <td class="mono">{token.id}</td>
+ <td class="mono">{fmtDate(token.created_at)}</td>
+ <td class="mono">{token.last_used ? fmtDate(token.last_used) : "never"}</td>
+ <td>
+ <form method="post" action="?/revoke">
+ <input type="hidden" name="id" value={token.id} />
+ <button type="submit" class="small danger"><iconsax-icon name="close-circle" type="bulk" size="14"></iconsax-icon>revoke</button>
+ </form>
+ </td>
+ </tr>
+ {:else}
+ <tr><td colspan="5" class="empty">no tokens yet</td></tr>
+ {/each}
+ </tbody>
+ </table>
+</div>
diff --git a/src/routes/tokens/+page.server.ts b/src/routes/tokens/+page.server.ts
new file mode 100644
index 0000000..cf93e99
--- /dev/null
+++ b/src/routes/tokens/+page.server.ts
@@ -0,0 +1,8 @@
+/* src/routes/tokens/+page.server.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import { redirect } from "@sveltejs/kit";
+import type { PageServerLoad } from "./$types";
+
+export const load: PageServerLoad = () => redirect(301, "/settings/tokens");
diff --git a/src/routes/tokens/+page.svelte b/src/routes/tokens/+page.svelte
new file mode 100644
index 0000000..ea4173c
--- /dev/null
+++ b/src/routes/tokens/+page.svelte
@@ -0,0 +1,5 @@
+<!-- src/routes/tokens/+page.svelte
+ LICENCED DASL-1.0 (c) Clove Twilight
+-->
+
+<!-- Never shown: the load always redirects -->
diff --git a/src/server.ts b/src/server.ts
deleted file mode 100644
index 5bbd8c2..0000000
--- a/src/server.ts
+++ /dev/null
@@ -1,1029 +0,0 @@
-/* src/server.ts
- * LICENCED DASL-1.0 (c) Clove Twilight
- */
-
-import { Hono, type Context } from "hono";
-import { getCookie, setCookie, deleteCookie } from "hono/cookie";
-import { join, resolve, sep } from "node:path";
-import { config, oidcEnabled } from "./config.ts";
-import {
- SESSION_COOKIE,
- OAUTH_COOKIE,
- sessionUser,
- startLogin,
- finishLogin,
- logout,
- oidcIssuer,
- authenticateGit,
- gitActor,
- sessionSlug,
- type SessionUser,
-} from "./auth.ts";
-import { SESSION_TTL, purgeExpiredSessions } from "./sessions.ts";
-import { listTokens, createToken, revokeToken } from "./tokens.ts";
-import { findUserBySlug } from "./users.ts";
-import {
- accessFor,
- canRead,
- canWrite,
- isLevel,
- listCollaborators,
- setCollaborator,
- removeCollaborator,
- sharedWith,
- type Access,
-} from "./access.ts";
-import { clearRepoMetadata } from "./repometa.ts";
-import { notifyRepoCreated, notifyRepoDeleted, notifyPush } from "./notify.ts";
-import { getSettings, setDiscordWebhook, setPrefs } from "./settings.ts";
-import {
- discordWebhookUrl,
- mirrorUrl,
- mirrorHost,
- MIRROR_KINDS,
- type MirrorKind,
-} from "./urls.ts";
-import {
- getStatuses,
- checkAllMirrors,
- needsCheck,
- markStale,
- dropMirrorStatusKind,
-} from "./mirror.ts";
-import {
- PROFILE_REPO,
- PROFILE_REPOS_PATH,
- isProfileRepo,
- headReadme,
- safeRef,
- refDir,
- refSlug,
- repoExists,
- initBareRepo,
- createRepo,
- importRepo,
- type CreateResult,
- trashRepo,
- listTrash,
- restoreFromTrash,
- purgeFromTrash,
- purgeExpired,
- purgeAllExpired,
- trashHasName,
- isRepoPublic,
- setRepoPublic,
- listRepos,
- listRefs,
- resolveRev,
- log,
- tree,
- blob,
- commit,
- readme,
- description,
- setDescription,
- readLinks,
- setLinks,
- localMirrorRefs,
- type MirrorLink,
- type Readme,
- type RepoRef,
- type RepoSummary,
- type RefList,
-} from "./git.ts";
-import {
- advertiseResponse,
- serviceRpc,
- type GitService,
-} from "./smart-http.ts";
-import * as view from "./views.ts";
-
-type Env = { Variables: { user: SessionUser | null } };
-const app = new Hono<Env>({ strict: false });
-
-const SITE_ORIGIN = new URL(config.baseUrl).origin;
-
-function fail(
- c: Context<Env>,
- title: string,
- message: string,
- status: 400 | 403 | 404 | 409 | 501 = 400,
-) {
- return c.html(view.messagePage({ title, message, user: c.get("user") }), status);
-}
-
-// The signed-in user, on routes behind the login guard
-function me(c: Context<Env>): SessionUser {
- return c.get("user")!;
-}
-
-const GIT_RPC = /\/(?:git-upload-pack|git-receive-pack)$/;
-
-app.use("*", async (c, next) => {
- // Static files and git transport never look at the browser session, and
- // skipping them keeps SSO re-checks off those hot paths.
- if (c.req.path.startsWith("/static/") || GIT_RPC.test(c.req.path) || c.req.path.endsWith("/info/refs")) {
- c.set("user", null);
- return next();
- }
- const token = getCookie(c, SESSION_COOKIE);
- const user = await sessionUser(token);
- if (token && !user) deleteCookie(c, SESSION_COOKIE, { path: "/" });
- c.set("user", user);
- await next();
-});
-
-// Logging out POSTs to /auth/logout, which redirects on to the SSO's logout,
-// and browsers check form-action against that redirect too.
-const SSO_ORIGIN = config.oidc.issuer ? new URL(config.oidc.issuer).origin : "";
-
-const CSP = [
- "default-src 'self'",
- "script-src 'self'",
- "style-src 'self'",
- "img-src 'self' data: https:",
- "font-src 'self'",
- "connect-src 'self'",
- `form-action 'self'${SSO_ORIGIN ? ` ${SSO_ORIGIN}` : ""}`,
- "frame-ancestors 'none'",
- "base-uri 'none'",
- "object-src 'none'",
-].join("; ");
-
-app.use("*", async (c, next) => {
- await next();
- if (GIT_RPC.test(c.req.path) || c.req.path.endsWith("/info/refs")) return;
- c.header("Content-Security-Policy", CSP);
- c.header("X-Content-Type-Options", "nosniff");
- c.header("Referrer-Policy", "same-origin");
- c.header("X-Frame-Options", "DENY");
- if (SITE_ORIGIN.startsWith("https://")) {
- c.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
- }
-});
-
-function sameOrigin(origin: string | undefined, referer: string | undefined): boolean {
- if (origin) return origin === SITE_ORIGIN;
- if (referer) {
- try {
- return new URL(referer).origin === SITE_ORIGIN;
- } catch {
- return false;
- }
- }
- return false;
-}
-
-app.use("*", async (c, next) => {
- const method = c.req.method;
- const unsafe = method !== "GET" && method !== "HEAD" && method !== "OPTIONS";
- if (unsafe && !GIT_RPC.test(c.req.path)) {
- if (!sameOrigin(c.req.header("origin"), c.req.header("referer"))) {
- return c.text("cross-site request refused\n", 403);
- }
- }
- await next();
-});
-
-const STATIC_ROOT = resolve(config.staticDir);
-
-app.get("/static/*", async (c) => {
- let rel: string;
- try {
- rel = decodeURIComponent(c.req.path.replace(/^\/static\//, ""));
- } catch {
- return c.notFound();
- }
- if (rel.includes("\0")) return c.notFound();
-
- const full = resolve(join(STATIC_ROOT, rel));
- if (full !== STATIC_ROOT && !full.startsWith(STATIC_ROOT + sep)) {
- return c.notFound();
- }
- // Bun.file picks the Content-Type from the extension
- const file = Bun.file(full);
- if (!(await file.exists())) return c.notFound();
-
- return new Response(file, {
- headers: {
- "Cache-Control": "public, max-age=3600",
- },
- });
-});
-
-app.get("/auth/login", async (c) => {
- if (!oidcEnabled) {
- return fail(c, "login unavailable", "Single sign-on (OIDC) is not configured on this instance.", 501);
- }
- const { redirectUrl, txCookie } = await startLogin();
- setCookie(c, OAUTH_COOKIE, txCookie, {
- httpOnly: true,
- secure: config.baseUrl.startsWith("https"),
- sameSite: "Lax",
- path: "/",
- maxAge: 600,
- });
- return c.redirect(redirectUrl);
-});
-
-app.get("/auth/callback", async (c) => {
- const tx = getCookie(c, OAUTH_COOKIE);
- deleteCookie(c, OAUTH_COOKIE, { path: "/" });
-
- const idpError = c.req.query("error");
- if (idpError) {
- console.error(
- `[auth] provider returned error=${idpError} ${c.req.query("error_description") ?? ""}`,
- );
- }
- if (!tx) {
- console.error(
- "[auth] no oauth transaction cookie on callback — likely a cookie issue " +
- "(MINIGIT_BASE_URL scheme vs how you're actually reaching the site, or a " +
- "host mismatch between /auth/login and /auth/callback).",
- );
- }
-
- const currentUrl = `${config.baseUrl}/auth/callback${new URL(c.req.url).search}`;
-
- let session: string | null = null;
- try {
- session = await finishLogin(currentUrl, tx);
- } catch (err) {
- const e = err as {
- error?: string;
- error_description?: string;
- message?: string;
- };
- console.error(
- "[auth] callback failed:",
- e?.error ? `error=${e.error}` : "",
- e?.error_description ? `desc=${e.error_description}` : "",
- err instanceof Error ? e.message : err,
- );
- }
- if (!session) {
- const message =
- idpError === "access_denied"
- ? "Your SSO account isn't allowed to use this instance. Ask an SSO admin to add you to its allowed groups."
- : "Could not complete sign-in. Please try again.";
- return fail(c, "login failed", message, 403);
- }
- setCookie(c, SESSION_COOKIE, session, {
- httpOnly: true,
- secure: config.baseUrl.startsWith("https"),
- sameSite: "Lax",
- path: "/",
- maxAge: SESSION_TTL,
- });
- return c.redirect("/");
-});
-
-// POST so a stray link or image can't sign anyone out; the same-origin check
-// above covers the form.
-app.post("/auth/logout", async (c) => {
- const target = await logout(getCookie(c, SESSION_COOKIE));
- deleteCookie(c, SESSION_COOKIE, { path: "/" });
- return c.redirect(target);
-});
-
-app.get("/auth/logout", (c) => c.redirect("/"));
-
-// Settings and repo creation need a signed-in user
-for (const path of ["/settings", "/settings/*", "/new", "/new/*"]) {
- app.use(path, async (c, next) => {
- if (c.get("user")) return next();
- return c.req.method === "GET" ? c.redirect("/auth/login") : c.text("forbidden\n", 403);
- });
-}
-
-app.get("/settings", (c) => {
- const user = me(c);
- return c.html(
- view.settingsPage({
- user,
- settings: getSettings(sessionSlug(user)),
- saved: Boolean(c.req.query("saved")),
- }),
- );
-});
-
-app.post("/settings/discord", async (c) => {
- const form = await c.req.formData();
- const raw = String(form.get("url") ?? "").trim();
-
- // Blank clears the webhook; anything else must be a real Discord one
- const url = raw ? discordWebhookUrl(raw) : null;
- if (raw && !url) {
- return fail(
- c,
- "not a discord webhook",
- "That doesn't look like a Discord webhook URL. It should start with " +
- "https://discord.com/api/webhooks/ — nothing else is accepted.",
- );
- }
- setDiscordWebhook(sessionSlug(me(c)), url);
- return c.redirect("/settings?saved=1");
-});
-
-app.post("/settings/prefs", async (c) => {
- const form = await c.req.formData();
- setPrefs(sessionSlug(me(c)), {
- defaultPrivate: form.get("default_private") != null,
- discordPrivate: form.get("discord_private") != null,
- mirrorAuto: form.get("mirror_auto") != null,
- });
- return c.redirect("/settings?saved=1");
-});
-
-app.get("/settings/tokens", (c) => {
- const user = me(c);
- return c.html(
- view.tokensPage({
- tokens: listTokens(sessionSlug(user)),
- user,
- }),
- );
-});
-
-app.post("/settings/tokens", async (c) => {
- const user = me(c);
- const owner = sessionSlug(user);
- const form = await c.req.formData();
- const newToken = createToken(String(form.get("label") ?? ""), owner, user.sub);
- return c.html(
- view.tokensPage({
- tokens: listTokens(owner),
- user,
- newToken,
- }),
- );
-});
-
-app.post("/settings/tokens/:id/revoke", (c) => {
- revokeToken(c.req.param("id"), sessionSlug(me(c)));
- return c.redirect("/settings/tokens");
-});
-
-app.get("/tokens", (c) => c.redirect("/settings/tokens", 301));
-
-app.get("/settings/deleted", async (c) => {
- const user = me(c);
- const owner = sessionSlug(user);
-
- for (const gone of await purgeExpired(owner)) {
- clearRepoMetadata({ owner, name: gone.name });
- console.log(`[trash] purged ${owner}/${gone.name} past retention`);
- }
-
- return c.html(
- view.deletedPage({
- user,
- entries: await listTrash(owner),
- retentionDays: config.trashDays,
- }),
- );
-});
-
-app.post("/settings/deleted/restore", async (c) => {
- const owner = sessionSlug(me(c));
- const form = await c.req.formData();
-
- const result = await restoreFromTrash(owner, String(form.get("entry") ?? ""));
- if (!result.ok || !result.meta) {
- return fail(c, "could not restore", result.error ?? "unknown error");
- }
-
- const ref = { owner, name: result.meta.name };
- for (const grant of result.meta.grants) {
- if (!isLevel(grant.level)) continue;
- if (!findUserBySlug(grant.slug)) {
- console.warn(`[trash] restoring ${refSlug(ref)}: dropping grant for unknown user ${grant.slug}`);
- continue;
- }
- setCollaborator(ref, grant.slug, grant.level);
- }
-
- console.log(`[trash] restored ${refSlug(ref)}`);
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-app.post("/settings/deleted/purge", async (c) => {
- const owner = sessionSlug(me(c));
- const form = await c.req.formData();
- const entry = String(form.get("entry") ?? "");
-
- const found = (await listTrash(owner)).find((e) => e.entry === entry);
- if (await purgeFromTrash(owner, entry)) {
- if (found) clearRepoMetadata({ owner, name: found.name });
- console.log(`[trash] purged ${owner}/${found?.name ?? entry}`);
- }
- return c.redirect("/settings/deleted");
-});
-
-app.get("/new", (c) => c.html(view.newRepoPage(me(c))));
-
-// Shared tail of "create empty" and "import": metadata, visibility, notify
-async function finishCreate(c: Context<Env>, result: CreateResult, verb: string) {
- if (!result.ok || !result.ref) {
- const title = result.reserved ? "that name is still reserved" : `could not ${verb} repo`;
- return fail(c, title, result.error ?? "unknown error", result.reserved ? 409 : 400);
- }
-
- const owner = sessionSlug(me(c));
- clearRepoMetadata(result.ref);
- const startsPublic = !getSettings(owner).defaultPrivate;
- if (startsPublic) await setRepoPublic(result.ref, true);
- notifyRepoCreated(result.ref, owner, startsPublic);
- return c.redirect(`/${result.ref.owner}/${result.ref.name}/`);
-}
-
-app.post("/new", async (c) => {
- const form = await c.req.formData();
- const result = await createRepo(sessionSlug(me(c)), String(form.get("name") ?? ""));
- return finishCreate(c, result, "create");
-});
-
-app.post("/new/import", async (c) => {
- const form = await c.req.formData();
- const url = String(form.get("url") ?? "");
- const name = String(form.get("name") ?? "");
- const result = await importRepo(sessionSlug(me(c)), name, url);
- if (result.ref) console.log(`[import] ${refSlug(result.ref)} from ${url}`);
- return finishCreate(c, result, "import");
-});
-
-function refFromPath(c: Context<Env>, nameParam: "name" | "repo"): RepoRef | null {
- const owner = c.req.param("owner");
- const name = c.req.param(nameParam);
- if (!owner || !name) return null;
- return safeRef(owner, name);
-}
-
-const GIT_SERVICES: GitService[] = ["git-upload-pack", "git-receive-pack"];
-
-function authChallenge(message = "authentication required"): Response {
- return new Response(`${message}\n`, {
- status: 401,
- headers: { "WWW-Authenticate": 'Basic realm="dough-git"' },
- });
-}
-
-interface GitGate {
- response: Response | null;
- actor: string | null;
-}
-
-const ALLOW = (actor: string | null): GitGate => ({ response: null, actor });
-const DENY = (response: Response): GitGate => ({ response, actor: null });
-
-async function gitGate(
- c: { req: { header: (n: string) => string | undefined } },
- ref: RepoRef,
- needPush: boolean,
-): Promise<GitGate> {
- const auth = authenticateGit(c.req.header("authorization"));
- const actor = gitActor(auth);
- const exists = await repoExists(ref);
-
- if (auth.kind === "rejected") {
- console.warn(`[git] denied ${refSlug(ref)}: ${auth.message}`);
- return DENY(new Response(`${auth.message}\n`, { status: 403 }));
- }
-
- if (needPush) {
- if (!actor) return DENY(authChallenge());
-
- if (!exists) {
- if (actor !== ref.owner) {
- console.warn(`[git] denied create of ${refSlug(ref)} by ${actor}`);
- return DENY(
- new Response(`${actor} can only create repositories under ${actor}/\n`, {
- status: 403,
- }),
- );
- }
- if (await trashHasName(ref.owner, ref.name)) {
- console.warn(`[git] refused auto-create of trashed ${refSlug(ref)}`);
- return DENY(
- new Response(
- `${refSlug(ref)} is in Recently Deleted. Restore it, or delete it ` +
- `permanently, before pushing to that name again.\n`,
- { status: 409 },
- ),
- );
- }
- if (!config.autoCreate) {
- return DENY(new Response("repository not found\n", { status: 404 }));
- }
- await initBareRepo(ref);
- clearRepoMetadata(ref);
- console.log(`[git] auto-created ${refSlug(ref)}.git on first push`);
- notifyRepoCreated(ref, actor, false);
- return ALLOW(actor);
- }
-
- const isPublic = await isRepoPublic(ref);
- if (!canWrite({ ref, isPublic, viewer: actor })) {
- console.warn(`[git] denied push to ${refSlug(ref)} by ${actor}`);
- return DENY(
- new Response(`${actor} does not have write access to ${refSlug(ref)}\n`, {
- status: 403,
- }),
- );
- }
- return ALLOW(actor);
- }
-
- if (exists) {
- const isPublic = await isRepoPublic(ref);
- if (canRead({ ref, isPublic, viewer: actor })) return ALLOW(actor);
- }
- if (auth.kind === "anonymous") return DENY(authChallenge());
- return DENY(new Response("repository not found\n", { status: 404 }));
-}
-
-app.get("/:owner/:repo/info/refs", async (c) => {
- const ref = safeRef(c.req.param("owner"), c.req.param("repo"));
- const service = c.req.query("service") as GitService | undefined;
- if (!ref || !service || !GIT_SERVICES.includes(service)) {
- return c.text("only smart HTTP is supported\n", 400);
- }
- const gate = await gitGate(c, ref, service === "git-receive-pack");
- if (gate.response) return gate.response;
- return advertiseResponse(refDir(ref), service);
-});
-
-async function rpcHandler(c: Context<Env>, service: GitService): Promise<Response> {
- const ref = refFromPath(c, "repo");
- if (!ref) return c.text("bad repo\n", 400);
- const gate = await gitGate(c, ref, service === "git-receive-pack");
- if (gate.response) return gate.response;
-
- const isPush = service === "git-receive-pack";
- const before = isPush ? await localMirrorRefs(ref) : new Map<string, string>();
- const actor = gate.actor;
- const isPublic = isPush ? await isRepoPublic(ref) : false;
-
- return serviceRpc({
- repoDir: refDir(ref),
- service,
- body: c.req.raw.body,
- gzip: c.req.header("content-encoding") === "gzip",
- onDone: isPush
- ? (code) => {
- if (code !== 0) {
- console.warn(`[git] receive-pack for ${refSlug(ref)} exited ${code}`);
- return;
- }
- void (async () => {
- try {
- const after = await localMirrorRefs(ref);
- markStale(ref);
- notifyPush(ref, actor ?? "unknown", isPublic, before, after);
- } catch (err) {
- console.warn(`[git] post-push processing failed for ${refSlug(ref)}:`, err);
- }
- })();
- }
- : undefined,
- });
-}
-
-app.post("/:owner/:repo/git-upload-pack", (c) => rpcHandler(c, "git-upload-pack"));
-app.post("/:owner/:repo/git-receive-pack", (c) => rpcHandler(c, "git-receive-pack"));
-
-function viewerOf(c: { get: (k: "user") => SessionUser | null }): string | null {
- const user = c.get("user");
- return user ? sessionSlug(user) : null;
-}
-
-function readable(all: RepoSummary[], viewer: string | null): RepoSummary[] {
- return all.filter((r) =>
- canRead({
- ref: { owner: r.owner, name: r.name },
- isPublic: r.isPublic,
- viewer,
- }),
- );
-}
-
-app.get("/", async (c) => {
- const user = c.get("user");
- const viewer = viewerOf(c);
- const all = (await listRepos()).filter((r) => !isProfileRepo(r.name));
- const shared = viewer ? new Set(sharedWith(viewer).map((r) => `${r.owner}/${r.name}`)) : null;
- return c.html(view.repoListPage(readable(all, viewer), user, shared));
-});
-
-function notFound(c: Context<Env>) {
- return fail(c, "not found", "No such repository, or you don't have access.", 404);
-}
-
-interface ViewableRepo {
- ref: RepoRef;
- isPublic: boolean;
- access: Access;
- refs: RefList;
- rev: string;
-}
-
-async function viewable(c: Context<Env>): Promise<ViewableRepo | null> {
- const ref = refFromPath(c, "name");
- if (!ref || !(await repoExists(ref))) return null;
-
- const isPublic = await isRepoPublic(ref);
- const access = accessFor({ ref, isPublic, viewer: viewerOf(c) });
- if (access === "none") return null;
-
- const refs = await listRefs(ref);
- const rev = await resolveRev(ref, c.req.query("h"), refs);
- return { ref, isPublic, access, refs, rev };
-}
-
-app.get("/:owner/:name/log", async (c) => {
- const found = await viewable(c);
- if (!found) return notFound(c);
- const commits = await log(found.ref, found.rev, 100);
- return c.html(
- view.logPage({
- ...found.ref,
- commits,
- refs: found.refs,
- rev: found.rev,
- user: c.get("user"),
- }),
- );
-});
-
-app.get("/:owner/:name/tree", (c) => renderTree(c, ""));
-app.get("/:owner/:name/tree/:path{.*}", (c) => renderTree(c, c.req.param("path")));
-
-async function renderTree(c: Context<Env>, path: string) {
- const found = await viewable(c);
- if (!found) return notFound(c);
- const entries = await tree(found.ref, found.rev, path);
- return c.html(
- view.treePage({
- ...found.ref,
- path,
- entries,
- refs: found.refs,
- rev: found.rev,
- user: c.get("user"),
- }),
- );
-}
-
-app.get("/:owner/:name/blob/:path{.*}", async (c) => {
- const found = await viewable(c);
- if (!found) return notFound(c);
- const path = c.req.param("path");
- const b = await blob(found.ref, found.rev, path);
- if (!b) return notFound(c);
- return c.html(
- view.blobPage({
- ...found.ref,
- path,
- binary: b.binary,
- text: b.text,
- truncated: b.truncated,
- bytes: b.bytes,
- refs: found.refs,
- rev: found.rev,
- user: c.get("user"),
- }),
- );
-});
-
-app.get("/:owner/:name/commit/:sha", async (c) => {
- const found = await viewable(c);
- if (!found) return notFound(c);
- const detail = await commit(found.ref, c.req.param("sha"));
- if (!detail) return notFound(c);
- return c.html(
- view.commitPage({
- ...found.ref,
- commit: detail,
- rev: found.rev,
- user: c.get("user"),
- }),
- );
-});
-
-async function ownedRef(c: Context<Env>): Promise<RepoRef | null> {
- const user = c.get("user");
- if (!user) return null;
- const ref = refFromPath(c, "name");
- if (!ref || ref.owner !== sessionSlug(user)) return null;
- return (await repoExists(ref)) ? ref : null;
-}
-
-async function writableRef(c: Context<Env>): Promise<RepoRef | null> {
- const ref = refFromPath(c, "name");
- if (!ref || !(await repoExists(ref))) return null;
- const isPublic = await isRepoPublic(ref);
- return canWrite({ ref, isPublic, viewer: viewerOf(c) }) ? ref : null;
-}
-
-app.post("/:owner/:name/description", async (c) => {
- const ref = await writableRef(c);
- if (!ref) return notFound(c);
- const form = await c.req.formData();
- await setDescription(ref, String(form.get("description") ?? ""));
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-app.post("/:owner/:name/visibility", async (c) => {
- const ref = await ownedRef(c);
- if (!ref) return notFound(c);
- const form = await c.req.formData();
- await setRepoPublic(ref, form.get("public") === "on");
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-app.post("/:owner/:name/delete", async (c) => {
- const ref = await ownedRef(c);
- if (!ref) return notFound(c);
- const user = c.get("user")!;
- const wasPublic = await isRepoPublic(ref);
-
- const result = await trashRepo(ref, {
- deletedAt: Math.floor(Date.now() / 1000),
- deletedBy: sessionSlug(user),
- grants: listCollaborators(ref).map((g) => ({
- slug: g.slug,
- level: g.level,
- })),
- });
- if (!result.ok) return fail(c, "could not delete", result.error ?? "unknown error");
-
- clearRepoMetadata(ref);
- notifyRepoDeleted(ref, sessionSlug(user), wasPublic);
- return c.redirect("/settings/deleted");
-});
-
-app.post("/:owner/:name/collaborators", async (c) => {
- const ref = await ownedRef(c);
- if (!ref) return notFound(c);
-
- const form = await c.req.formData();
- const slug = String(form.get("slug") ?? "").trim().toLowerCase();
- const levelRaw = String(form.get("level") ?? "read");
- const level = isLevel(levelRaw) ? levelRaw : "read";
-
- const invited = findUserBySlug(slug);
- if (!invited) {
- return fail(
- c,
- "no such user",
- `Nobody on this instance goes by "${slug}". They have to sign in ` +
- `to this instance once before they can be added.`,
- );
- }
- if (invited.slug === ref.owner) {
- return fail(c, "already the owner", "You can't add yourself as a collaborator on your own repo.");
- }
-
- setCollaborator(ref, invited.slug, level);
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-app.post("/:owner/:name/collaborators/remove", async (c) => {
- const ref = await ownedRef(c);
- if (!ref) return notFound(c);
- const form = await c.req.formData();
- removeCollaborator(ref, String(form.get("slug") ?? ""));
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-async function profileReadme(
- owner: string,
- viewer: string | null,
-): Promise<Readme | null> {
- const ref = safeRef(owner, PROFILE_REPO);
- if (!ref || !(await repoExists(ref))) return null;
- const isPublic = await isRepoPublic(ref);
- if (!canRead({ ref, isPublic, viewer })) return null;
- return headReadme(ref);
-}
-
-function ownedRepos(all: RepoSummary[], owner: string): RepoSummary[] {
- return all.filter((r) => r.owner === owner && !isProfileRepo(r.name));
-}
-
-app.get("/:owner", async (c) => {
- const owner = c.req.param("owner");
- if (!safeRef(owner, "x")) return notFound(c);
-
- const user = c.get("user");
- const viewer = viewerOf(c);
- const all = await listRepos();
- const owned = all.filter((r) => r.owner === owner);
- const repos = readable(ownedRepos(all, owner), viewer);
- const profile = findUserBySlug(owner);
-
- if (!profile && owned.length === 0) return notFound(c);
-
- return c.html(
- view.profilePage({
- owner,
- profile,
- repos,
- readme: await profileReadme(owner, viewer),
- hasProfileRepo: owned.some((r) => isProfileRepo(r.name)),
- isOwn: viewer === owner,
- user,
- }),
- );
-});
-
-app.get(`/:owner/${PROFILE_REPOS_PATH}`, async (c) => {
- const owner = c.req.param("owner");
- if (!safeRef(owner, "x")) return notFound(c);
-
- const viewer = viewerOf(c);
- const all = await listRepos();
- const profile = findUserBySlug(owner);
- if (!profile && !all.some((r) => r.owner === owner)) return notFound(c);
-
- return c.html(
- view.reposPage({
- owner,
- profile,
- repos: readable(ownedRepos(all, owner), viewer),
- user: c.get("user"),
- }),
- );
-});
-
-app.get("/:owner/:name", async (c) => {
- if (c.req.param("name") === PROFILE_REPOS_PATH) {
- return c.redirect(`/${c.req.param("owner")}/${PROFILE_REPOS_PATH}`, 301);
- }
-
- const found = await viewable(c);
- if (!found) return notFound(c);
- const { ref, isPublic, access, refs, rev } = found;
-
- const [commits, desc, links] = await Promise.all([
- log(ref, rev, 1),
- description(ref),
- readLinks(ref),
- ]);
- const readmeFile = commits.length ? await readme(ref, rev) : null;
-
- const user = c.get("user");
- const isOwner = user != null && sessionSlug(user) === ref.owner;
- const canPush = access === "write";
-
- const statuses = getStatuses(ref);
- let localSha: string | null = null;
- if (links.length > 0) {
- const localRefs = await localMirrorRefs(ref);
- localSha = localRefs.get(`refs/heads/${refs.head}`) ?? null;
-
- if (canPush && getSettings(ref.owner).mirrorAuto) {
- const due = links.filter((l) => !l.isPrivate && needsCheck(statuses.get(l.kind)));
- if (due.length > 0) {
- void checkAllMirrors(ref, due).catch((err) => {
- console.warn(`[mirror] background check failed for ${refSlug(ref)}:`, err);
- });
- }
- }
- }
-
- return c.html(
- view.summaryPage({
- ...ref,
- isPublic,
- empty: refs.branches.length === 0,
- readme: readmeFile,
- rawDescription: desc,
- description: view.repoDescription({
- ...ref,
- description: desc,
- readme: readmeFile,
- }),
- canPush,
- collaborators: isOwner ? listCollaborators(ref) : null,
- links,
- mirrorStatuses: statuses,
- localSha,
- refs,
- rev,
- user,
- }),
- );
-});
-
-app.post("/:owner/:name/mirrors", async (c) => {
- const ref = await ownedRef(c);
- if (!ref) return notFound(c);
- const form = await c.req.formData();
-
- const links: MirrorLink[] = [];
- const rejected: string[] = [];
- for (const kind of MIRROR_KINDS) {
- const raw = String(form.get(kind) ?? "").trim();
- if (!raw) continue;
- const url = mirrorUrl(kind, raw);
- if (!url) {
- rejected.push(kind);
- continue;
- }
- links.push({
- kind,
- url,
- isPrivate: form.get(`${kind}_private`) != null,
- });
- }
-
- if (rejected.length > 0) {
- return fail(
- c,
- "that isn't a mirror URL",
- `The ${rejected.join(" and ")} link was refused. Give the repository as ` +
- `owner/repo — for example doughmination/dough-git — and it is looked up on ` +
- `${mirrorHost(rejected[0] as MirrorKind)}.`,
- );
- }
-
- const before = await readLinks(ref);
- await setLinks(ref, links);
- for (const old of before) {
- const still = links.find((l) => l.kind === old.kind && l.url === old.url);
- if (!still) dropMirrorStatusKind(ref, old.kind);
- }
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-app.post("/:owner/:name/mirrors/check", async (c) => {
- const ref = await writableRef(c);
- if (!ref) return notFound(c);
- const links = await readLinks(ref);
- await checkAllMirrors(ref, links);
- return c.redirect(`/${ref.owner}/${ref.name}/`);
-});
-
-const SWEEP_INTERVAL_MS = 6 * 60 * 60 * 1000;
-
-function sweepSessions(): void {
- try {
- const purged = purgeExpiredSessions();
- if (purged) console.log(`[auth] purged ${purged} expired sessions`);
- } catch (err) {
- console.warn("[auth] session sweep failed:", err);
- }
-}
-
-async function sweepTrash(): Promise<void> {
- try {
- const purged = await purgeAllExpired();
- for (const gone of purged) {
- clearRepoMetadata({ owner: gone.owner, name: gone.name });
- console.log(`[trash] expired ${gone.owner}/${gone.name}`);
- }
- } catch (err) {
- console.warn("[trash] scheduled sweep failed:", err);
- }
-}
-
-Bun.serve({
- fetch: app.fetch,
- port: config.port,
- hostname: config.host,
- // Big pushes and imports can sit quiet for minutes; never cut them off
- idleTimeout: 0,
-});
-
-void (async () => {
- console.log(`dough-git listening on http://${config.host}:${config.port}`);
- console.log(` repos root: ${config.reposRoot}`);
- console.log(` static dir: ${config.staticDir}`);
- console.log(` base url: ${config.baseUrl}`);
- console.log(` oidc: ${oidcEnabled ? "enabled" : "disabled"}`);
- console.log(
- ` trash: ${config.trashDays > 0 ? `${config.trashDays}d, swept every 6h` : "kept forever"}`,
- );
- console.log(` logins: accounts on ${config.oidc.issuer || "(no issuer)"} (limit with the client's allowed groups)`);
- if (oidcEnabled) {
- try {
- const iss = await oidcIssuer();
- console.log(` oidc issuer (must equal the callback's iss): ${iss}`);
- console.log(` oidc redirect_uri: ${config.baseUrl}/auth/callback`);
- } catch (err) {
- console.error(
- " oidc discovery FAILED (check OIDC_ISSUER):",
- err instanceof Error ? err.message : err,
- );
- }
- }
-
- void sweepTrash();
- sweepSessions();
- setInterval(() => {
- void sweepTrash();
- sweepSessions();
- }, SWEEP_INTERVAL_MS).unref();
-})();
diff --git a/src/views.ts b/src/views.ts
deleted file mode 100644
index 92d8909..0000000
--- a/src/views.ts
+++ /dev/null
@@ -1,1073 +0,0 @@
-/* src/views.ts
- * LICENCED DASL-1.0 (c) Clove Twilight
- */
-
-import { config } from "./config.ts";
-import { icon } from "./icons.ts";
-import { escapeHtml as esc, renderMarkdown, plainSummary } from "./markdown.ts";
-import { accountUrl, sessionSlug, type SessionUser } from "./auth.ts";
-import { maskWebhook, mirrorHost, mirrorSlug, MIRROR_KINDS, type MirrorKind } from "./urls.ts";
-import type { CollaboratorRow } from "./access.ts";
-import type { TokenRow } from "./tokens.ts";
-import type { UserRow } from "./users.ts";
-import type { Settings } from "./settings.ts";
-import { PROFILE_REPO, PROFILE_REPOS_PATH } from "./git.ts";
-import type {
- RepoSummary,
- Commit,
- TreeEntry,
- CommitDetail,
- Readme,
- RefList,
- TrashEntry,
- MirrorLink,
-} from "./git.ts";
-import type { MirrorStatus } from "./mirror.ts";
-
-function fmtDate(unix: number | null): string {
- if (!unix) return "";
- return new Date(unix * 1000).toISOString().slice(0, 16).replace("T", " ");
-}
-
-function base(owner: string, name: string): string {
- return `/${esc(owner)}/${esc(name)}`;
-}
-
-function cloneUrl(owner: string, name: string): string {
- return `${config.baseUrl}/${owner}/${name}.git`;
-}
-
-function revQuery(rev: string, head: string): string {
- return rev === head ? "" : `?h=${encodeURIComponent(rev)}`;
-}
-
-function visibility(isPublic: boolean): string {
- return `<span class="with-icon">${icon(isPublic ? "lock-open" : "lock", 13)}${isPublic ? "public" : "private"}</span>`;
-}
-
-// [id, label, icon, href] rows rendered as a tab strip
-function tabs(active: string, items: [string, string, string, string][]): string {
- const links = items.map(
- ([id, label, glyph, href]) =>
- `<a class="tab${id === active ? " active" : ""}" href="${href}">${icon(glyph)}${label}</a>`,
- );
- return ` <nav class="tabs">${links.join("")}</nav>`;
-}
-
-function revPicker(refs: RefList, rev: string): string {
- const all = [...refs.branches, ...refs.tags];
- if (all.length === 0 || (all.length < 2 && all.includes(rev))) return "";
-
- const options = (names: string[], label: string): string => {
- if (names.length === 0) return "";
- const items = names
- .map((name) => `<option value="${esc(name)}"${name === rev ? " selected" : ""}>${esc(name)}</option>`)
- .join("");
- return `<optgroup label="${label}">${items}</optgroup>`;
- };
-
- const detached = all.includes(rev)
- ? ""
- : `<option value="${esc(rev)}" selected>${esc(rev.slice(0, 10))}</option>`;
-
- return `<form method="get" class="row rev-picker">
- <label class="label with-icon" for="rev-picker">${icon("git-branch")}revision</label>
- <select id="rev-picker" name="h" data-autosubmit>
- ${detached}${options(refs.branches, "branches")}${options(refs.tags, "tags")}
- </select>
- <button type="submit">${icon("arrow-right")}go</button>
- </form>`;
-}
-
-function metaText(s: string, max = 200): string {
- const flat = s.replace(/\s+/g, " ").trim();
- const clipped =
- flat.length > max ? flat.slice(0, max - 1).replace(/\s+\S*$/, "") + "…" : flat;
- return esc(clipped);
-}
-
-interface Profile {
- name: string | null;
- username: string | null;
- picture: string | null;
-}
-
-function displayName(p: Profile & { sub?: string }): string {
- return p.name ?? p.username ?? p.sub ?? "user";
-}
-
-function avatar(p: Profile, size: "sm" | "lg"): string {
- const initial = esc(displayName(p).trim().slice(0, 1).toUpperCase() || "?");
- const img = p.picture ? `<img src="${esc(p.picture)}" alt="" loading="lazy" data-avatar>` : "";
- return `<span class="avatar avatar-${size}">${initial}${img}</span>`;
-}
-
-function layout(opts: {
- title: string;
- user: SessionUser | null;
- body: string;
- description?: string;
- path?: string;
- noindex?: boolean;
-}): string {
- const whoami = opts.user
- ? `<a class="user" href="/${esc(sessionSlug(opts.user))}">${avatar(opts.user, "sm")}${esc(displayName(opts.user))}</a>`
- : "";
- const nav = opts.user
- ? `<a class="nav-link" href="/new">${icon("plus")}new</a>
- <a class="nav-link" href="/settings">${icon("settings")}settings</a>
- <form method="post" action="/auth/logout" class="nav-form">
- <button type="submit" class="nav-link nav-button">${icon("log-out")}logout</button>
- </form>`
- : `<a class="nav-link" href="/auth/login">${icon("log-in")}login</a>`;
-
- const description = metaText(opts.description || config.description);
- const url = esc(config.baseUrl + (opts.path ?? ""));
- const faviconUrl = esc(config.favicon);
- const logo = config.favicon
- ? `<img class="site-logo" src="${faviconUrl}" alt="" width="24" height="24">`
- : icon("git-branch", 20);
-
- return `<!doctype html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>${esc(opts.title)}</title>
- <meta name="description" content="${description}">
- <meta name="theme-color" content="${esc(config.themeColor)}">
- <meta name="generator" content="dough-git">
- ${opts.noindex ? `<meta name="robots" content="noindex, nofollow">` : `<link rel="canonical" href="${url}">`}
- <meta property="og:type" content="website">
- <meta property="og:site_name" content="${esc(config.title)}">
- <meta property="og:title" content="${esc(opts.title)}">
- <meta property="og:description" content="${description}">
- <meta property="og:url" content="${url}">
- <meta property="og:image" content="${faviconUrl}">
- <meta name="twitter:card" content="summary">
- <link rel="icon" href="${faviconUrl}">
- <link rel="apple-touch-icon" href="${faviconUrl}">
- <link rel="stylesheet" href="/static/style.css">
- <script src="/static/app.js" defer></script>
-</head>
-<body>
- <header class="site-header">
- <a class="site-title" href="/">${logo}${esc(config.title)}</a>
- <div class="site-who">${whoami}</div>
- <nav class="site-nav">${nav}</nav>
- </header>
- <main class="content">
-${opts.body}
- </main>
- <footer class="site-footer">
- <span class="with-icon">${icon("git-merge")}dough-git · a minimal git mirror</span>
- </footer>
-</body>
-</html>`;
-}
-
-// A table with a header row, or one full-width "empty" cell
-function table(headers: string[], rows: string[], empty: string): string {
- const head = headers.length
- ? `<thead><tr>${headers.map((h) => `<th>${h}</th>`).join("")}</tr></thead>`
- : "";
- const span = Math.max(1, headers.length);
- const body = rows.join("\n") || `<tr><td colspan="${span}" class="empty">${esc(empty)}</td></tr>`;
- return `<table>${head}
- <tbody>
-${body}
- </tbody>
- </table>`;
-}
-
-function repoTable(
- repos: RepoSummary[],
- opts: {
- showOwner: boolean;
- empty: string;
- sharedSlugs?: Set<string> | null;
- },
-): string {
- const rows = repos.map((r) => {
- const owner = opts.showOwner
- ? `<a class="muted" href="/${esc(r.owner)}">${esc(r.owner)}</a>/`
- : "";
- const shared = opts.sharedSlugs?.has(`${r.owner}/${r.name}`)
- ? `<span class="badge">${icon("users", 11)}shared</span>`
- : "";
- return ` <tr>
- <td class="repo-name">${icon("git-branch")} ${owner}<a href="${base(r.owner, r.name)}/">${esc(r.name)}</a>${shared}</td>
- <td class="muted">${esc(r.description)}</td>
- <td class="mono">${visibility(r.isPublic)}</td>
- <td class="mono">${fmtDate(r.lastCommit)}</td>
- </tr>`;
- });
- return table(["repository", "description", "visibility", "updated"], rows, opts.empty);
-}
-
-export function repoListPage(
- repos: RepoSummary[],
- user: SessionUser | null,
- sharedSlugs: Set<string> | null,
-): string {
- const body = ` <h1 class="page-title">repositories</h1>
- ${repoTable(repos, {
- showOwner: true,
- empty: "no repositories visible",
- sharedSlugs,
- })}`;
- return layout({
- title: config.title,
- user,
- body,
- path: "/",
- });
-}
-
-export function newRepoPage(user: SessionUser): string {
- const owner = esc(sessionSlug(user));
- const body = ` <h1 class="page-title">new repository</h1>
-
- <h2 class="section-title">${icon("folder-plus")}empty repository</h2>
- <form method="post" action="/new" class="box row">
- <span class="mono">${owner}/</span>
- <input class="grow" type="text" name="name" placeholder="my-project" pattern="[A-Za-z0-9._-]+" required>
- <button type="submit">${icon("plus")}create</button>
- </form>
-
- <h2 class="section-title">${icon("download")}import from another forge</h2>
- <p class="muted">Copies every branch and tag from a public repository on GitHub, Codeberg,
- GitLab, or any other forge. The import is a one-off copy, not a live mirror.</p>
- <form method="post" action="/new/import" class="box">
- <p class="row">
- <label class="label with-icon" for="import-url">${icon("link")}clone url</label>
- <input id="import-url" class="grow" type="url" name="url" required
- placeholder="https://codeberg.org/owner/repo.git" autocapitalize="off" spellcheck="false">
- </p>
- <p class="row">
- <label class="label with-icon" for="import-name">${icon("tag")}name</label>
- <span class="mono">${owner}/</span>
- <input id="import-name" class="grow" type="text" name="name" pattern="[A-Za-z0-9._-]+"
- placeholder="leave blank to use the source name">
- </p>
- <button type="submit">${icon("download")}import</button>
- </form>`;
- return layout({
- title: "new repository",
- user,
- body,
- noindex: true,
- });
-}
-
-const PROFILE_PREVIEW = 6;
-
-function ownerName(owner: string, profile: UserRow | null): string {
- return profile ? displayName(profile) : owner;
-}
-
-function ownerHead(owner: string, profile: UserRow | null): string {
- const handle =
- profile?.username && profile.username !== profile.slug ? profile.username : null;
-
- const known = profile
- ? `<p class="muted">@${esc(profile.slug)}${handle ? ` · ${esc(handle)}` : ""} · joined ${fmtDate(profile.created_at).slice(0, 10)}</p>`
- : `<p class="muted">@${esc(owner)} · no account on this instance</p>`;
-
- const fallback = {
- name: owner,
- username: null,
- picture: null,
- };
-
- return ` <section class="profile-head">
- ${avatar(profile ?? fallback, "lg")}
- <div>
- <h1 class="profile-name">${esc(ownerName(owner, profile))}</h1>
- ${known}
- </div>
- </section>`;
-}
-
-function ownerTabs(owner: string, active: "profile" | "repos"): string {
- return tabs(active, [
- ["profile", "profile", "user", `/${esc(owner)}`],
- ["repos", "repositories", "git-branch", `/${esc(owner)}/${PROFILE_REPOS_PATH}`],
- ]);
-}
-
-export function profilePage(opts: {
- owner: string;
- profile: UserRow | null;
- repos: RepoSummary[];
- readme: Readme | null;
- hasProfileRepo: boolean;
- isOwn: boolean;
- user: SessionUser | null;
-}): string {
- const name = ownerName(opts.owner, opts.profile);
- const preview = opts.repos.slice(0, PROFILE_PREVIEW);
- const profileHref = `/${esc(opts.owner)}/${esc(PROFILE_REPO)}/`;
-
- let readmeSection = "";
- if (opts.readme) {
- readmeSection = ` <article class="readme">
-${renderMarkdown(opts.readme.text)}
- </article>`;
- if (opts.isOwn) {
- readmeSection += `\n <p class="muted"><a href="${profileHref}">${esc(PROFILE_REPO)}/${esc(opts.readme.path)}</a></p>`;
- }
- } else if (opts.isOwn && opts.hasProfileRepo) {
- readmeSection = ` <p class="box muted">${icon("file")} <a href="${profileHref}">${esc(PROFILE_REPO)}</a> has no <code>README.md</code> yet. Push one and it shows up here.</p>`;
- } else if (opts.isOwn) {
- readmeSection = ` <form method="post" action="/new" class="box row">
- <input type="hidden" name="name" value="${esc(PROFILE_REPO)}">
- <label class="label with-icon">${icon("file")}profile readme</label>
- <span class="muted">Create <code>${esc(PROFILE_REPO)}</code> and its README.md shows up here.</span>
- <button type="submit">${icon("plus")}create</button>
- </form>`;
- }
-
- const moreLink =
- opts.repos.length > preview.length
- ? ` <p class="muted"><a href="/${esc(opts.owner)}/${PROFILE_REPOS_PATH}">all ${opts.repos.length} repositories →</a></p>`
- : "";
-
- const body = `${ownerHead(opts.owner, opts.profile)}
-${ownerTabs(opts.owner, "profile")}
-${readmeSection}
- <h2 class="section-title">repositories</h2>
- ${repoTable(preview, { showOwner: false, empty: "nothing here yet" })}
-${moreLink}`;
-
- return layout({
- title: name,
- user: opts.user,
- body,
- description: opts.readme
- ? metaText(plainSummary(opts.readme.text))
- : `${name} (@${opts.owner}) on ${config.title}.`,
- path: `/${opts.owner}`,
- noindex: !opts.repos.some((r) => r.isPublic) && !opts.readme,
- });
-}
-
-export function reposPage(opts: {
- owner: string;
- profile: UserRow | null;
- repos: RepoSummary[];
- user: SessionUser | null;
-}): string {
- const name = ownerName(opts.owner, opts.profile);
-
- const body = `${ownerHead(opts.owner, opts.profile)}
-${ownerTabs(opts.owner, "repos")}
- <h2 class="section-title">repositories</h2>
- ${repoTable(opts.repos, { showOwner: false, empty: "nothing here yet" })}`;
-
- return layout({
- title: `${name} repositories`,
- user: opts.user,
- body,
- description: `Repositories owned by ${name} (@${opts.owner}) on ${config.title}.`,
- path: `/${opts.owner}/${PROFILE_REPOS_PATH}`,
- noindex: !opts.repos.some((r) => r.isPublic),
- });
-}
-
-function repoNav(owner: string, name: string, active: string, q: string): string {
- const b = base(owner, name);
- return tabs(active, [
- ["summary", "summary", "newspaper", `${b}/${q}`],
- ["log", "log", "git-commit-horizontal", `${b}/log${q}`],
- ["tree", "tree", "folder", `${b}/tree${q}`],
- ]);
-}
-
-export function summaryPage(opts: {
- owner: string;
- name: string;
- isPublic: boolean;
- empty: boolean;
- readme: Readme | null;
- description: string;
- rawDescription: string;
- canPush: boolean;
- collaborators: CollaboratorRow[] | null;
- refs: RefList;
- rev: string;
- user: SessionUser | null;
- links: MirrorLink[];
- mirrorStatuses: Map<string, MirrorStatus>;
- localSha: string | null;
-}): string {
- const title = `${opts.owner}/${opts.name}`;
- const b = base(opts.owner, opts.name);
- const q = revQuery(opts.rev, opts.refs.head);
- const pusher = opts.user ? sessionSlug(opts.user) : opts.owner;
- const isOwner = opts.collaborators !== null;
-
- let pushHint = "";
- if (opts.empty && opts.canPush) {
- pushHint = ` <section class="box">
- <p><strong>This repository is empty.</strong> Push to get started:</p>
- <code>git remote add mirror ${esc(cloneUrl(opts.owner, opts.name))}<br>git push --mirror mirror</code>
- <p class="muted">When prompted, the <strong>username</strong> is <code>${esc(pusher)}</code> and the <strong>password</strong> is a token from <a href="/settings/tokens">settings</a>.</p>
- </section>`;
- } else if (opts.empty) {
- pushHint = ` <p class="box empty">This repository is empty.</p>`;
- }
-
- let readmeSection = "";
- if (opts.readme) {
- readmeSection = ` <h2 class="section-title">${icon("file-text")}${esc(opts.readme.path)}</h2>
- <article class="readme">
-${renderMarkdown(opts.readme.text)}
- </article>`;
- } else if (!opts.empty) {
- readmeSection = ` <h2 class="section-title">${icon("file-text")}readme</h2>
- <p class="empty">No ReadMe was found, commit one to add a summary</p>`;
- }
-
- const manage = isOwner
- ? ` <h2 class="section-title">${icon("settings")}manage</h2>
- <div class="tabs">
- <form method="post" action="${b}/visibility">
- <input type="hidden" name="public" value="${opts.isPublic ? "" : "on"}">
- <button type="submit">${icon(opts.isPublic ? "lock" : "lock-open")}make ${opts.isPublic ? "private" : "public"}</button>
- </form>
- <form method="post" action="${b}/delete" data-confirm="Delete ${esc(title)}? It moves to Recently Deleted.">
- <button type="submit">${icon("trash-2")}delete repository</button>
- </form>
- </div>
-${collaboratorSection(b, opts.collaborators ?? [])}`
- : "";
-
- let descriptionForm = "";
- if (opts.canPush) {
- descriptionForm = ` <form method="post" action="${b}/description" class="box row">
- <label class="label with-icon" for="repo-description">${icon("sticky-note")}description</label>
- <input id="repo-description" class="grow" type="text" name="description" maxlength="300"
- value="${esc(opts.rawDescription)}" placeholder="what this repository is for">
- <button type="submit">${icon("save")}save</button>
- </form>`;
- } else if (opts.rawDescription) {
- descriptionForm = ` <p class="muted">${esc(opts.rawDescription)}</p>`;
- }
-
- const pushBadge =
- opts.canPush && !isOwner ? `<span class="badge">${icon("upload", 11)}you can push</span>` : "";
-
- const body = ` <h1 class="repo-title"><a class="muted" href="/${esc(opts.owner)}">${esc(opts.owner)}</a>/${esc(opts.name)}</h1>
- <p class="muted">${visibility(opts.isPublic)}${pushBadge}</p>
-${repoNav(opts.owner, opts.name, "summary", q)}
-${descriptionForm}
- ${revPicker(opts.refs, opts.rev)}
- <section class="box">
- <span class="label with-icon">${icon("download")}clone</span>
- <code>git clone ${esc(cloneUrl(opts.owner, opts.name))}</code>
- </section>
-${pushHint}
-${mirrorSection(b, opts.links, opts.mirrorStatuses, opts.localSha, isOwner, opts.canPush)}
-${readmeSection}
-${manage}`;
-
- return layout({
- title,
- user: opts.user,
- body,
- description: opts.description,
- path: `/${opts.owner}/${opts.name}`,
- noindex: !opts.isPublic,
- });
-}
-
-function kindIcon(kind: MirrorKind): string {
- return icon(kind === "github" ? "globe" : "git-branch");
-}
-
-function mirrorSection(
- b: string,
- links: MirrorLink[],
- statuses: Map<string, MirrorStatus>,
- localSha: string | null,
- isOwner: boolean,
- canCheck: boolean,
-): string {
- if (links.length === 0 && !isOwner) return "";
-
- const nowSec = Math.floor(Date.now() / 1000);
-
- const rows = links.map((link) => {
- const view = describeMirror(link, statuses.get(link.kind) ?? null, nowSec);
- const note = view.note ? `\n <p class="${view.noteCls}">${esc(view.note)}</p>` : "";
- return ` <div class="mirror-row">
- <span class="mirror-kind"><a class="with-icon" href="${esc(link.url)}" rel="nofollow noopener noreferrer">${kindIcon(link.kind)}${esc(mirrorSlug(link.kind, link.url))}</a></span>
- <span class="${view.cls} with-icon">${icon(view.glyph)}${esc(view.label)}</span>
- <span class="mono">${esc(view.sha)}</span>
- <span class="muted">${esc(view.detail)}</span>
- </div>${note}`;
- });
-
- if (localSha) {
- rows.push(` <div class="mirror-row">
- <span class="mirror-kind with-icon">${icon("house")}local</span>
- <span class="empty">this repository</span>
- <span class="mono">${esc(localSha.slice(0, 7))}</span>
- <span></span>
- </div>`);
- }
-
- if (canCheck && links.some((l) => !l.isPrivate)) {
- rows.push(` <form method="post" action="${b}/mirrors/check">
- <button type="submit">${icon("refresh-cw")}check now</button>
- </form>`);
- }
-
- const list =
- links.length > 0
- ? ` <section class="box">
-${rows.join("\n")}
- </section>`
- : ` <p class="empty">No mirrors configured.</p>`;
-
- const field = (kind: MirrorKind) => {
- const existing = links.find((l) => l.kind === kind);
- return ` <div class="row">
- <label class="label with-icon" for="mirror-${kind}">${kindIcon(kind)}${kind}</label>
- <input id="mirror-${kind}" class="grow" type="text" name="${kind}"
- value="${esc(existing ? mirrorSlug(kind, existing.url) : "")}"
- placeholder="user/repo" pattern="[^\\s/]+/[^\\s/]+/?" autocapitalize="off" spellcheck="false">
- <label><input type="checkbox" name="${kind}_private"${existing?.isPrivate ? " checked" : ""}> private</label>
- </div>`;
- };
-
- const form = isOwner
- ? ` <form method="post" action="${b}/mirrors" class="box">
-${MIRROR_KINDS.map(field).join("\n")}
- <p class="muted">Give the <code>user/repo</code> on ${esc(MIRROR_KINDS.map(mirrorHost).join(" or "))} — not a full URL.
- Mark a mirror <em>private</em> to skip status checks — they are anonymous, so a private
- mirror would otherwise always look unreachable. Clear a field to remove it.</p>
- <button type="submit">${icon("save")}save mirrors</button>
- </form>`
- : "";
-
- return ` <h2 class="section-title">${icon("hard-drive")}external mirrors</h2>
-${list}
-${form}`;
-}
-
-const MIRROR_LABELS: Record<string, { label: string; glyph: string; cls: string }> = {
- synced: { label: "Up to date", glyph: "check", cls: "good" },
- ahead: { label: "Mirror behind", glyph: "arrow-up", cls: "warn" },
- behind: { label: "Local behind", glyph: "arrow-down", cls: "warn" },
- diverged: { label: "Diverged", glyph: "triangle-alert", cls: "bad" },
- out_of_sync: { label: "Out of sync", glyph: "triangle-alert", cls: "bad" },
- denied: { label: "Private or missing", glyph: "lock", cls: "warn" },
- missing: { label: "Repository missing", glyph: "x", cls: "bad" },
-};
-
-const UNKNOWN_STATE = {
- label: "Unavailable",
- glyph: "circle-help",
- cls: "bad",
-};
-
-// A verified state older than this is flagged as stale
-const STALE_AFTER = 24 * 3600;
-
-function describeMirror(link: MirrorLink, status: MirrorStatus | null, nowSec: number) {
- const idle = {
- glyph: "hourglass",
- cls: "empty",
- sha: "",
- note: "",
- noteCls: "muted",
- };
-
- if (link.isPrivate) {
- return {
- ...idle,
- label: "Not checked (private)",
- glyph: "lock",
- detail: "status checks are anonymous",
- };
- }
- if (!status || (!status.state && !status.error)) {
- return {
- ...idle,
- label: "not checked yet",
- detail: "",
- };
- }
-
- const known = (status.state && MIRROR_LABELS[status.state]) || UNKNOWN_STATE;
- const sha = status.remoteSha ? status.remoteSha.slice(0, 7) : "";
- const verifiedAgo = status.okAt !== null ? nowSec - status.okAt : null;
- const stale = verifiedAgo !== null && verifiedAgo > STALE_AFTER;
-
- if (status.error) {
- let note = `${link.kind}: check failed ${ago(nowSec - status.checkedAt)} ago (${status.error})`;
- if (verifiedAgo !== null) {
- note += stale
- ? ` — NOT VERIFIED for ${ago(verifiedAgo)}`
- : ` — showing last verified state from ${ago(verifiedAgo)} ago`;
- }
- return {
- ...known,
- cls: status.state ? "empty" : "bad",
- sha,
- detail: verifiedAgo !== null ? `last verified ${ago(verifiedAgo)} ago` : "never verified",
- note,
- noteCls: stale || verifiedAgo === null ? "bad" : "warn",
- };
- }
-
- return {
- ...known,
- sha,
- detail: [status.detail, verifiedAgo !== null ? `checked ${ago(verifiedAgo)} ago` : ""]
- .filter(Boolean)
- .join(" · "),
- note: stale ? `${link.kind}: not verified for ${ago(verifiedAgo!)}` : "",
- noteCls: "bad",
- };
-}
-
-function ago(seconds: number): string {
- if (seconds < 90) return `${Math.max(0, Math.round(seconds))}s`;
- if (seconds < 5400) return `${Math.round(seconds / 60)}m`;
- if (seconds < 172800) return `${Math.round(seconds / 3600)}h`;
- return `${Math.round(seconds / 86400)}d`;
-}
-
-function collaboratorSection(b: string, collaborators: CollaboratorRow[]): string {
- const action = `${b}/collaborators`;
-
- const rows = collaborators.map(
- (person) => ` <tr>
- <td>${icon("user", 13)} <a href="/${esc(person.slug)}">${esc(person.slug)}</a></td>
- <td class="mono">${esc(person.level)}</td>
- <td class="mono">${fmtDate(person.added_at)}</td>
- <td>
- <form method="post" action="${action}/remove">
- <input type="hidden" name="slug" value="${esc(person.slug)}">
- <button type="submit">${icon("user-minus")}remove</button>
- </form>
- </td>
- </tr>`,
- );
-
- return ` <h2 class="section-title">${icon("users")}collaborators</h2>
- <p class="muted">People here can see this repository even while it is
- private. <code>write</code> also lets them push to it.</p>
- <form method="post" action="${action}" class="box row">
- <label class="label with-icon" for="collab-slug">${icon("user")}username</label>
- <input id="collab-slug" type="text" name="slug" placeholder="their handle" pattern="[A-Za-z0-9._-]+" required>
- <select name="level" aria-label="access level">
- <option value="read">read</option>
- <option value="write">write</option>
- </select>
- <button type="submit">${icon("user-plus")}add</button>
- </form>
- ${table(["user", "access", "added", ""], rows, "nobody else has access")}`;
-}
-
-export function repoDescription(opts: {
- owner: string;
- name: string;
- description: string;
- readme: Readme | null;
-}): string {
- if (opts.description.trim()) return opts.description;
- const fromReadme = opts.readme ? plainSummary(opts.readme.text) : "";
- return fromReadme || `${opts.owner}/${opts.name} — a git repository on ${config.title}.`;
-}
-
-export function logPage(opts: {
- owner: string;
- name: string;
- commits: Commit[];
- refs: RefList;
- rev: string;
- user: SessionUser | null;
-}): string {
- const title = `${opts.owner}/${opts.name}`;
- const b = base(opts.owner, opts.name);
- const q = revQuery(opts.rev, opts.refs.head);
-
- const rows = opts.commits.map(
- (cm) => ` <tr>
- <td class="mono">${fmtDate(cm.time)}</td>
- <td>${icon("git-commit-horizontal", 13)} <a href="${b}/commit/${esc(cm.hash)}${q}">${esc(cm.subject)}</a></td>
- <td class="muted">${esc(cm.author)}</td>
- <td class="mono">${esc(cm.hash.slice(0, 10))}</td>
- </tr>`,
- );
-
- const body = ` <h1 class="repo-title">${esc(title)} · log</h1>
-${repoNav(opts.owner, opts.name, "log", q)}
- ${revPicker(opts.refs, opts.rev)}
- ${table([], rows, "no commits")}`;
-
- return layout({
- title: `${title} log`,
- user: opts.user,
- body,
- description: `Commit history for ${title} on ${opts.rev}.`,
- path: `/${opts.owner}/${opts.name}/log`,
- });
-}
-
-export function treePage(opts: {
- owner: string;
- name: string;
- path: string;
- entries: TreeEntry[];
- refs: RefList;
- rev: string;
- user: SessionUser | null;
-}): string {
- const b = base(opts.owner, opts.name);
- const q = revQuery(opts.rev, opts.refs.head);
- const crumb = opts.path ? ` /${esc(opts.path)}` : "";
-
- const row = (mode: string, glyph: string, href: string, label: string, size: string) =>
- ` <tr>
- <td class="mono">${esc(mode)}</td>
- <td>${icon(glyph, 13)} <a href="${href}">${label}</a></td>
- <td class="mono right">${esc(size)}</td>
- </tr>`;
-
- const rows = opts.entries.map((e) => {
- const childPath = esc(opts.path ? `${opts.path}/${e.name}` : e.name);
- const isDir = e.type === "tree";
- return row(
- e.mode,
- isDir ? "folder" : "file-text",
- `${b}/${isDir ? "tree" : "blob"}/${childPath}${q}`,
- `${esc(e.name)}${isDir ? "/" : ""}`,
- e.size,
- );
- });
-
- if (opts.path) {
- const up = esc(opts.path.split("/").slice(0, -1).join("/"));
- rows.unshift(row("", "arrow-up", `${b}/tree/${up}${q}`, "../", ""));
- }
-
- const body = ` <h1 class="repo-title">${esc(opts.owner)}/${esc(opts.name)} · tree${crumb}</h1>
-${repoNav(opts.owner, opts.name, "tree", q)}
- ${revPicker(opts.refs, opts.rev)}
- ${table([], rows, "empty")}`;
-
- return layout({
- title: `${opts.owner}/${opts.name} tree`,
- user: opts.user,
- body,
- description: `Files in ${opts.owner}/${opts.name}${opts.path ? ` at ${opts.path}` : ""}.`,
- path: `${b}/tree${opts.path ? `/${opts.path}` : ""}`,
- });
-}
-
-function fmtBytes(bytes: number): string {
- if (bytes < 1024) return `${bytes} B`;
- if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
-}
-
-export function blobPage(opts: {
- owner: string;
- name: string;
- path: string;
- binary: boolean;
- text: string;
- truncated: boolean;
- bytes: number;
- refs: RefList;
- rev: string;
- user: SessionUser | null;
-}): string {
- const b = base(opts.owner, opts.name);
- const size = esc(fmtBytes(opts.bytes));
- const cut = opts.truncated
- ? `<p class="muted">Showing the first part of a ${size} file. Clone the repository to read all of it.</p>`
- : "";
- const content = opts.binary
- ? `<p class="muted">binary file not shown (${size})</p>`
- : `${cut}<pre class="code"><code>${esc(opts.text)}</code></pre>`;
- const q = revQuery(opts.rev, opts.refs.head);
- const upPath = opts.path.split("/").slice(0, -1).join("/");
-
- const body = ` <h1 class="repo-title">${esc(opts.owner)}/${esc(opts.name)} · ${esc(opts.path)}</h1>
-${repoNav(opts.owner, opts.name, "tree", q)}
- <p class="muted"><a class="with-icon" href="${b}/tree/${esc(upPath)}${q}">${icon("arrow-left")}back to ${esc(upPath || "tree")}</a></p>
- ${content}`;
-
- return layout({
- title: opts.path,
- user: opts.user,
- body,
- description: `${opts.path} in ${opts.owner}/${opts.name}.`,
- path: `${b}/blob/${opts.path}`,
- });
-}
-
-export function commitPage(opts: {
- owner: string;
- name: string;
- commit: CommitDetail;
- rev: string;
- user: SessionUser | null;
-}): string {
- const cm = opts.commit;
- const q = `?h=${encodeURIComponent(opts.rev)}`;
- const tooBig = cm.diffTruncated
- ? `<p class="muted">This diff is too large to show in full. Clone the repository to read all of it.</p>`
- : "";
-
- const body = ` <h1 class="page-title">${esc(cm.subject)}</h1>
-${repoNav(opts.owner, opts.name, "log", q)}
- <dl class="commit-meta">
- <dt class="with-icon">${icon("git-commit-horizontal", 13)}commit</dt><dd class="mono">${esc(cm.hash)}</dd>
- <dt class="with-icon">${icon("user", 13)}author</dt><dd>${esc(cm.author)} <${esc(cm.email)}></dd>
- <dt class="with-icon">${icon("clock", 13)}date</dt><dd>${fmtDate(cm.time)}</dd>
- </dl>
- ${cm.body ? `<pre class="code">${esc(cm.body)}</pre>` : ""}
- ${tooBig}
- <pre class="code"><code>${esc(cm.diff)}</code></pre>`;
-
- return layout({
- title: cm.subject,
- user: opts.user,
- body,
- description: `${cm.subject} — ${cm.author} in ${opts.owner}/${opts.name}.`,
- path: `${base(opts.owner, opts.name)}/commit/${cm.hash}`,
- });
-}
-
-function settingsLayout(opts: {
- active: string;
- title: string;
- description: string;
- user: SessionUser;
- body: string;
-}): string {
- const nav = tabs(opts.active, [
- ["account", "account", "user", "/settings"],
- ["tokens", "tokens", "key", "/settings/tokens"],
- ["deleted", "recently deleted", "trash-2", "/settings/deleted"],
- ]);
- return layout({
- title: opts.title,
- user: opts.user,
- body: ` <h1 class="page-title">settings</h1>
-${nav}
-${opts.body}`,
- description: opts.description,
- noindex: true,
- });
-}
-
-export function tokensPage(opts: {
- tokens: TokenRow[];
- user: SessionUser;
- newToken?: string | null;
-}): string {
- const authUser = esc(sessionSlug(opts.user));
-
- const rows = opts.tokens.map(
- (t) => ` <tr>
- <td>${esc(t.label)}</td>
- <td class="mono">${esc(t.id)}</td>
- <td class="mono">${fmtDate(t.created_at)}</td>
- <td class="mono">${t.last_used ? fmtDate(t.last_used) : "never"}</td>
- <td>
- <form method="post" action="/settings/tokens/${esc(t.id)}/revoke">
- <button type="submit">${icon("x")}revoke</button>
- </form>
- </td>
- </tr>`,
- );
-
- const created = opts.newToken
- ? ` <section class="box">
- <p><strong>New token — copy it now, it won't be shown again:</strong></p>
- <code>${esc(opts.newToken)}</code>
- <p class="muted">Ready-to-use remote:<br>
- <code>git remote add mirror ${esc(config.baseUrl.replace("://", `://${sessionSlug(opts.user)}:${opts.newToken}@`))}/${authUser}/<repo>.git</code></p>
- </section>`
- : "";
-
- const body = ` <h2 class="section-title">${icon("key")}access tokens</h2>
- <p class="muted">These tokens act as <code>${authUser}</code>: use that as the git
- <strong>username</strong> and the token as the <strong>password</strong>. They can only push to
- repositories under <code>${authUser}/</code>.</p>
-${created}
- <form method="post" action="/settings/tokens" class="box row">
- <label class="label with-icon" for="token-label">${icon("tag")}label</label>
- <input id="token-label" type="text" name="label" placeholder="laptop, backup cron, ...">
- <button type="submit">${icon("plus")}create token</button>
- </form>
- ${table(["label", "id", "created", "last used", ""], rows, "no tokens yet")}`;
-
- return settingsLayout({
- active: "tokens",
- title: "access tokens",
- description: "Manage git access tokens.",
- user: opts.user,
- body,
- });
-}
-
-export function settingsPage(opts: {
- user: SessionUser;
- settings: Settings;
- saved: boolean;
-}): string {
- const s = opts.settings;
- const on = (v: boolean) => (v ? " checked" : "");
-
- const webhookState = s.discordWebhook
- ? ` <p class="muted">configured · <code>${esc(maskWebhook(s.discordWebhook))}</code></p>`
- : ` <p class="empty">not configured — repository events are not announced anywhere.</p>`;
-
- const webhookError =
- s.discordWebhook && s.webhookError
- ? ` <p class="bad">last delivery failed${s.webhookErrorAt ? ` at ${fmtDate(s.webhookErrorAt)}` : ""}: ${esc(s.webhookError)}</p>`
- : "";
-
- const clear = s.discordWebhook
- ? ` <form method="post" action="/settings/discord" data-confirm="Remove the Discord webhook? Events will stop being announced.">
- <input type="hidden" name="url" value="">
- <button type="submit">${icon("trash-2")}remove webhook</button>
- </form>`
- : "";
-
- const account = accountUrl();
- const accountLink = account
- ? ` — change them on <a href="${esc(account)}">your SSO account page</a>`
- : "";
-
- const body = `${opts.saved ? ` <p class="good">saved.</p>` : ""}
-
- <h2 class="section-title">${icon("message-circle")}discord notifications</h2>
- <p class="muted">Announces repositories being created and deleted, and commits being
- pushed. Only repositories you own are announced, and only to this webhook.</p>
- <section class="box">
-${webhookState}
-${webhookError}
- <form method="post" action="/settings/discord" class="row">
- <label class="label with-icon" for="discord-url">${icon("link")}webhook</label>
- <input id="discord-url" class="grow" type="url" name="url" autocomplete="off"
- placeholder="https://discord.com/api/webhooks/…">
- <button type="submit">${icon("save")}save</button>
- </form>
-${clear}
- </section>
-
- <h2 class="section-title">${icon("sliders-horizontal")}preferences</h2>
- <form method="post" action="/settings/prefs" class="box">
- <p><label><input type="checkbox" name="default_private"${on(s.defaultPrivate)}>
- New repositories start private</label></p>
- <p><label><input type="checkbox" name="discord_private"${on(s.discordPrivate)}>
- Announce activity on private repositories</label>
- <br><span class="muted">Off by default: commit subjects and repository names
- would otherwise leave a private repo for a Discord channel.</span></p>
- <p><label><input type="checkbox" name="mirror_auto"${on(s.mirrorAuto)}>
- Check mirror status automatically when viewing a repository</label>
- <br><span class="muted">Off means mirrors are only checked when you press
- <em>check now</em>.</span></p>
- <button type="submit">${icon("save")}save preferences</button>
- </form>
-
- <h2 class="section-title">${icon("user")}account</h2>
- <p class="muted">Your name and avatar come from your SSO account and refresh
- automatically, so there is nothing to edit here${accountLink}. Your owner namespace is
- <code>${esc(sessionSlug(opts.user))}</code> and never changes.</p>`;
-
- return settingsLayout({
- active: "account",
- title: "settings",
- description: "Account settings.",
- user: opts.user,
- body,
- });
-}
-
-export function deletedPage(opts: {
- user: SessionUser;
- entries: TrashEntry[];
- retentionDays: number;
-}): string {
- const nowSec = Math.floor(Date.now() / 1000);
-
- const lifeLabel = (deletedAt: number): string => {
- if (opts.retentionDays <= 0) return `<span class="empty">kept until purged</span>`;
- const left = Math.ceil((deletedAt + opts.retentionDays * 86400 - nowSec) / 86400);
- if (left <= 0) return `<span class="bad">purged on next visit</span>`;
- return `<span class="${left <= 3 ? "bad" : "empty"}">${left}d left</span>`;
- };
-
- const rows = opts.entries.map((e) => {
- let note = "";
- if (e.degraded) {
- note = `<br><span class="warn">recovery metadata unreadable — restorable, but collaborators will need re-adding</span>`;
- } else if (e.grants.length) {
- note = `<br><span class="muted">${e.grants.length} collaborator${e.grants.length === 1 ? "" : "s"} will be restored</span>`;
- }
-
- return ` <tr>
- <td class="repo-name">${icon("git-branch", 13)} ${esc(e.name)}${note}</td>
- <td class="mono">${fmtDate(e.deletedAt)}</td>
- <td class="muted">${esc(e.deletedBy)}</td>
- <td>${lifeLabel(e.deletedAt)}</td>
- <td>
- <form method="post" action="/settings/deleted/restore">
- <input type="hidden" name="entry" value="${esc(e.entry)}">
- <button type="submit">${icon("rotate-ccw")}restore</button>
- </form>
- </td>
- <td>
- <form method="post" action="/settings/deleted/purge" data-confirm="Permanently delete ${esc(e.name)}? This destroys the git data and cannot be undone.">
- <input type="hidden" name="entry" value="${esc(e.entry)}">
- <button type="submit">${icon("trash-2")}delete permanently</button>
- </form>
- </td>
- </tr>`;
- });
-
- const retention =
- opts.retentionDays > 0
- ? `Deleted repositories are kept for ${opts.retentionDays} days, then purged the next time you open this page.`
- : `Deleted repositories are kept indefinitely — nothing is purged unless you do it here.`;
-
- const body = ` <h2 class="section-title">${icon("trash-2")}recently deleted</h2>
- <p class="muted">${esc(retention)} A deleted repository keeps its name reserved, so
- nothing new can take it until it is restored or purged.</p>
- ${table(["repository", "deleted", "by", "retention", "", ""], rows, "nothing deleted")}`;
-
- return settingsLayout({
- active: "deleted",
- title: "recently deleted",
- description: "Recover deleted repositories.",
- user: opts.user,
- body,
- });
-}
-
-export function messagePage(opts: {
- title: string;
- message: string;
- user: SessionUser | null;
-}): string {
- const body = ` <h1 class="page-title">${esc(opts.title)}</h1>
- <p class="muted">${esc(opts.message)}</p>`;
- return layout({
- title: opts.title,
- user: opts.user,
- body,
- description: opts.message,
- noindex: true,
- });
-}
diff --git a/static/background.avif b/static/background.avif
new file mode 100644
index 0000000..b286ce8
Binary files /dev/null and b/static/background.avif differ
diff --git a/test/access.test.mjs b/test/access.test.mjs
index b26e1fb..e8865f1 100644
--- a/test/access.test.mjs
+++ b/test/access.test.mjs
@@ -20,9 +20,9 @@ const {
collaboratorLevel,
dropRepoAccess,
sharedWith,
-} = await import("../src/access.ts");
+} = await import("../src/lib/server/access.ts");
-const { safeRef, safeObjectId } = await import("../src/git.ts");
+const { safeRef, safeObjectId } = await import("../src/lib/server/git.ts");
let failures = 0;
function check(label, cond) {
diff --git a/test/icons.test.mjs b/test/icons.test.mjs
deleted file mode 100644
index 967731d..0000000
--- a/test/icons.test.mjs
+++ /dev/null
@@ -1,113 +0,0 @@
-/* test/icons.test.mjs
- * LICENCED DASL-1.0 (c) Clove Twilight
- */
-
-import { icon } from "../src/icons.ts";
-
-let failures = 0;
-function check(label, cond) {
- console.log(`${cond ? "PASS" : "FAIL"} ${label}`);
- if (!cond) failures++;
-}
-
-const names = [
- "git-branch",
- "git-commit-horizontal",
- "git-merge",
- "folder",
- "folder-plus",
- "file",
- "file-text",
- "newspaper",
- "sticky-note",
- "tag",
- "lock",
- "lock-open",
- "user",
- "users",
- "user-plus",
- "user-minus",
- "key",
- "settings",
- "sliders-horizontal",
- "log-in",
- "log-out",
- "house",
- "link",
- "message-circle",
- "globe",
- "hard-drive",
- "download",
- "upload",
- "refresh-cw",
- "rotate-ccw",
- "save",
- "trash-2",
- "plus",
- "x",
- "check",
- "clock",
- "hourglass",
- "triangle-alert",
- "octagon-alert",
- "circle-help",
- "info",
- "lightbulb",
- "flag",
- "snowflake",
- "wind",
- "arrow-up",
- "arrow-down",
- "arrow-left",
- "arrow-right",
-];
-
-for (const name of names) {
- const svg = icon(name);
- check(`${name} renders one svg`, (svg.match(/<svg /g) ?? []).length === 1);
- check(`${name} has a drawable shape`, /<(path|circle|rect|line|polyline|polygon|ellipse) /.test(svg));
-}
-
-check(
- "default size is 16",
- icon("folder").includes('width="16"') && icon("folder").includes('height="16"'),
-);
-check(
- "an explicit size is honoured",
- icon("lock", 24).includes('width="24"'),
-);
-check(
- "the 24x24 grid is carried through",
- names.every((name) => icon(name).includes('viewBox="0 0 24 24"')),
-);
-check(
- "icons carry the .icon class for styling",
- icon("user").includes('class="icon"'),
-);
-check(
- "icons are decorative to screen readers",
- icon("user").includes('aria-hidden="true"'),
-);
-check(
- "colour is inherited, not hard-coded",
- icon("git-branch").includes('stroke="currentColor"') && !/#[0-9a-f]{3,6}/i.test(icon("git-branch")),
-);
-check(
- "stroke width is 2.25px at the default size",
- icon("folder").includes('stroke-width="3.375"'),
-);
-check(
- "stroke width stays 2.25px at other sizes",
- icon("folder", 24).includes('stroke-width="2.25"') && icon("folder", 12).includes('stroke-width="4.5"'),
-);
-
-let threw = false;
-try {
- icon("definitely-not-an-icon");
-} catch {
- threw = true;
-}
-check("an unknown name throws rather than rendering nothing", threw);
-
-console.log(failures === 0 ? "\nALL PASSED" : `\n${failures} FAILED`);
-process.exit(failures === 0 ? 0 : 1);
diff --git a/test/lifecycle.test.mjs b/test/lifecycle.test.mjs
index 86e871f..bbaab44 100644
--- a/test/lifecycle.test.mjs
+++ b/test/lifecycle.test.mjs
@@ -36,11 +36,11 @@ const {
purgeExpired,
purgeAllExpired,
DELETED_META,
-} = await import("../src/git.ts");
+} = await import("../src/lib/server/git.ts");
const { setCollaborator, listCollaborators, collaboratorLevel } = await import(
- "../src/access.ts"
+ "../src/lib/server/access.ts"
);
-const { clearRepoMetadata } = await import("../src/repometa.ts");
+const { clearRepoMetadata } = await import("../src/lib/server/repometa.ts");
let failures = 0;
function check(label, cond) {
diff --git a/test/markdown.test.mjs b/test/markdown.test.mjs
index 33df0dc..4803a6e 100644
--- a/test/markdown.test.mjs
+++ b/test/markdown.test.mjs
@@ -2,7 +2,7 @@
* LICENCED DASL-1.0 (c) Clove Twilight
*/
-import { renderMarkdown, plainSummary } from "../src/markdown.ts";
+import { renderMarkdown, plainSummary } from "../src/lib/server/markdown.ts";
let failures = 0;
function check(label, cond) {
@@ -74,7 +74,7 @@ check(
);
check(
"note alert includes an inline icon",
- has("> [!NOTE]\n> Heads up.", 'class="icon"'),
+ has("> [!NOTE]\n> Heads up.", '<iconsax-icon name="info-circle"'),
);
check(
"tip alert",
diff --git a/test/mirror.test.mjs b/test/mirror.test.mjs
index f24edcf..50b167a 100644
--- a/test/mirror.test.mjs
+++ b/test/mirror.test.mjs
@@ -25,9 +25,9 @@ const {
needsCheck,
describeMismatch,
mismatchReasons,
-} = await import("../src/mirror.ts");
+} = await import("../src/lib/server/mirror.ts");
const { classifyRemoteError, lsRemote, createRepo, refDir, localMirrorRefs } =
- await import("../src/git.ts");
+ await import("../src/lib/server/git.ts");
let failures = 0;
function check(label, cond) {
diff --git a/test/notify.test.mjs b/test/notify.test.mjs
index 46ff5d2..eb957a8 100644
--- a/test/notify.test.mjs
+++ b/test/notify.test.mjs
@@ -23,10 +23,10 @@ const {
notifyRepoCreated,
notifyRepoDeleted,
notifyPush,
-} = await import("../src/notify.ts");
-const { createRepo, refDir, localMirrorRefs } = await import("../src/git.ts");
+} = await import("../src/lib/server/notify.ts");
+const { createRepo, refDir, localMirrorRefs } = await import("../src/lib/server/git.ts");
const { setDiscordWebhook, setPrefs, getSettings } = await import(
- "../src/settings.ts"
+ "../src/lib/server/settings.ts"
);
let failures = 0;
diff --git a/test/ownership.test.mjs b/test/ownership.test.mjs
index df75bba..8a45a1c 100644
--- a/test/ownership.test.mjs
+++ b/test/ownership.test.mjs
@@ -10,9 +10,9 @@ const root = mkdtempSync(join(tmpdir(), "dough-own-"));
process.env.MINIGIT_REPOS_ROOT = root;
process.env.MINIGIT_DB_PATH = join(root, "test.db");
-const { rememberUser } = await import("../src/users.ts");
-const { createToken, revokeToken, listTokens } = await import("../src/tokens.ts");
-const { authenticateGit, gitActor } = await import("../src/auth.ts");
+const { rememberUser } = await import("../src/lib/server/users.ts");
+const { createToken, revokeToken, listTokens } = await import("../src/lib/server/tokens.ts");
+const { authenticateGit, gitActor } = await import("../src/lib/server/auth.ts");
let failures = 0;
function check(label, cond) {
diff --git a/test/profile.test.mjs b/test/profile.test.mjs
index e789c80..dac3bb7 100644
--- a/test/profile.test.mjs
+++ b/test/profile.test.mjs
@@ -25,7 +25,7 @@ const {
listTrash,
restoreFromTrash,
repoExists,
-} = await import("../src/git.ts");
+} = await import("../src/lib/server/git.ts");
const exec = promisify(execFile);
diff --git a/test/refs.test.mjs b/test/refs.test.mjs
index 869645f..5e55dc3 100644
--- a/test/refs.test.mjs
+++ b/test/refs.test.mjs
@@ -13,7 +13,7 @@ process.env.MINIGIT_REPOS_ROOT = root;
process.env.MINIGIT_DB_PATH = join(root, "test.db");
const { listRefs, resolveRev, refDir, setDescription, description, log } =
- await import("../src/git.ts");
+ await import("../src/lib/server/git.ts");
const exec = promisify(execFile);
diff --git a/test/sessions.test.mjs b/test/sessions.test.mjs
index e924bf6..10d3092 100644
--- a/test/sessions.test.mjs
+++ b/test/sessions.test.mjs
@@ -10,17 +10,17 @@ const root = mkdtempSync(join(tmpdir(), "dough-sessions-"));
process.env.MINIGIT_REPOS_ROOT = root;
process.env.MINIGIT_DB_PATH = join(root, "test.db");
-const { db, now } = await import("../src/db.ts");
-const { rememberUser, findUserBySlug } = await import("../src/users.ts");
-const { createToken } = await import("../src/tokens.ts");
-const { authenticateGit } = await import("../src/auth.ts");
+const { db, now } = await import("../src/lib/server/db.ts");
+const { rememberUser, findUserBySlug } = await import("../src/lib/server/users.ts");
+const { createToken } = await import("../src/lib/server/tokens.ts");
+const { authenticateGit } = await import("../src/lib/server/auth.ts");
const {
createSession,
findSession,
revalidate,
RECHECK_AFTER,
OUTAGE_GRACE,
-} = await import("../src/sessions.ts");
+} = await import("../src/lib/server/sessions.ts");
let failures = 0;
function check(label, cond) {
diff --git a/test/transport.test.mjs b/test/transport.test.mjs
index e697aa4..f884acd 100644
--- a/test/transport.test.mjs
+++ b/test/transport.test.mjs
@@ -13,7 +13,7 @@ import {
pktLine,
advertiseResponse,
serviceRpc,
-} from "../src/smart-http.ts";
+} from "../src/lib/server/smart-http.ts";
const execFileAsync = promisify(execFile);
diff --git a/test/urls.test.mjs b/test/urls.test.mjs
index 2a36ea5..b40a81a 100644
--- a/test/urls.test.mjs
+++ b/test/urls.test.mjs
@@ -10,7 +10,7 @@ import {
maskWebhook,
isMirrorKind,
MIRROR_KINDS,
-} from "../src/urls.ts";
+} from "../src/lib/server/urls.ts";
let failures = 0;
function check(label, cond) {
diff --git a/tsconfig.json b/tsconfig.json
index 43bbbd2..5e736ab 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,15 +1,13 @@
{
+ "extends": "$app/tsconfig",
+ "include": ["src", "test", "*.ts"],
+ "exclude": ["build", "node_modules"],
"compilerOptions": {
- "lib": ["ESNext"],
- "target": "ESNext",
- "module": "ESNext",
- "moduleResolution": "bundler",
- "types": ["bun"],
+ "allowImportingTsExtensions": true,
+ "checkJs": false,
"strict": true,
"skipLibCheck": true,
"noUncheckedIndexedAccess": true,
- "allowImportingTsExtensions": true,
- "noEmit": true
- },
- "include": ["src", "test"]
+ "types": ["$app/types", "bun"]
+ }
}
diff --git a/vite.config.ts b/vite.config.ts
new file mode 100644
index 0000000..b877527
--- /dev/null
+++ b/vite.config.ts
@@ -0,0 +1,43 @@
+/* vite.config.ts
+ * LICENCED DASL-1.0 (c) Clove Twilight
+ */
+
+import adapter from "@sveltejs/adapter-node";
+import { sveltekit } from "@sveltejs/kit/vite";
+import { defineConfig } from "vite";
+
+// The build imports server modules to analyse them; keep it off the real database
+if (process.argv.includes("build")) process.env.MINIGIT_DB_PATH = ":memory:";
+
+export default defineConfig({
+ plugins: [
+ sveltekit({
+ compilerOptions: {
+ // Runes everywhere except libraries
+ runes: ({ filename }) => (filename.split(/[/\\]/).includes("node_modules") ? undefined : true),
+ },
+ // serve.ts runs the built app on Bun.serve; this adapter only produces the build
+ adapter: adapter(),
+ csp: {
+ mode: "auto",
+ directives: {
+ "default-src": ["self"],
+ "script-src": ["self"],
+ "style-src": ["self"],
+ "img-src": ["self", "data:", "https:"],
+ "font-src": ["self", "https://raw.doughmination.gay"],
+ "connect-src": ["self"],
+ // hooks.server.ts adds the SSO origin, which is only known at runtime
+ "form-action": ["self"],
+ "frame-ancestors": ["none"],
+ "base-uri": ["none"],
+ "object-src": ["none"],
+ },
+ },
+ }),
+ ],
+ // iconsax fetches its icon data relative to its own file, which pre-bundling breaks
+ optimizeDeps: {
+ exclude: ["iconsax"],
+ },
+});