diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..459b17a --- /dev/null +++ b/.air.toml @@ -0,0 +1,53 @@ +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + +[build] + args_bin = [] + bin = "./tmp/main" + cmd = "go generate ./... && go build -o ./tmp/main ./cmd/schreifuchs-ch/main.go" + delay = 1000 + exclude_dir = ["assets", "tmp", "vendor", "testdata", "node_modules", ".git", ".gitea"] + exclude_file = [] + exclude_regex = ["_test.go", "_templ.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "dlv exec ./tmp/main --listen=127.0.0.1:2345 --headless=true --api-version=2 --accept-multiclient --continue --log --" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "templ", "html", "css"] + kill_delay = "0s" + log = "build-errors.log" + poll = false + poll_interval = 0 + rerun = false + send_interrupt = false + stop_on_error = true + +[proxy] + enabled = true + proxy_port = 8888 + app_port = 8080 + app_start_timeout = 50000000 + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + main_only = false + time = false + +[misc] + clean_on_exit = false + +[env] + TEST_PW = "test" + VALKEY_ADDR = "127.0.0.1:6379" + VALKEY_PASSWORD = "valkey" + +[screen] + clear_on_rebuild = false + keep_scroll = true diff --git a/.gemini/settings.json b/.gemini/settings.json deleted file mode 100644 index 3cc6af9..0000000 --- a/.gemini/settings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/google-gemini/gemini-cli/main/schemas/settings.schema.json", - "mcpServers": { - "svelte": { - "command": "npx", - "args": [ - "-y", - "@sveltejs/mcp" - ] - } - } -} diff --git a/.gitignore b/.gitignore index 6635cf5..b65df1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ .DS_Store node_modules +/tmp +/tmp/* /build -/.svelte-kit -/package + .env .env.* !.env.example -vite.config.js.timestamp-* -vite.config.ts.timestamp-* + +/web/**/*_templ.go diff --git a/.npmrc b/.npmrc deleted file mode 100644 index b6f27f1..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..cf8b117 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Server", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/cmd/schreifuchs-ch/main.go", + "cwd": "${workspaceFolder}", + "showLog": true + }, + { + "name": "Attach to Air", + "type": "go", + "request": "attach", + "mode": "remote", + "port": 2345, + "host": "127.0.0.1" + } + ] +} diff --git a/Dockerfile b/Dockerfile index 01cb891..b2e91bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,54 @@ -# Stage 1: Build the application -FROM node:24-slim AS builder - -# Enable corepack to use pnpm -RUN corepack enable - +# Stage 1: Build frontend assets +FROM node:24-alpine AS frontend-builder WORKDIR /app -# Copy configuration files -COPY package.json pnpm-lock.yaml .npmrc ./ +# Enable pnpm via corepack +RUN corepack enable pnpm -# Install all dependencies (including devDependencies) +# Install dependencies +COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile -# Copy the rest of the application code +# Copy source and build assets COPY . . +RUN pnpm run build:css && pnpm run build:js -# Build the SvelteKit application -RUN pnpm run build - -# Stage 2: Run the application -FROM node:24-slim AS runner - -# Enable corepack to use pnpm -RUN corepack enable - +# Stage 2: Build Go binary +FROM golang:1.26-alpine AS go-builder WORKDIR /app -# Copy the build output and necessary files for production -COPY --from=builder /app/build ./build -COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml -COPY --from=builder /app/.npmrc ./.npmrc +# Install git for potential private modules (though not strictly needed here) +RUN apk add --no-cache git -# Install only production dependencies -RUN pnpm install --prod --frozen-lockfile +# Download Go modules +COPY go.mod go.sum ./ +RUN go mod download -# Expose the port the app runs on (SvelteKit defaults to 3000) -EXPOSE 3000 +# Copy source code +COPY . . -# Set environment variables -ENV NODE_ENV=production -ENV PORT=3000 +# Copy built frontend assets from the previous stage +COPY --from=frontend-builder /app/web/static/css/output.css ./web/static/css/ +COPY --from=frontend-builder /app/web/static/js/htmx.min.js ./web/static/js/ -# Run the application -CMD ["node", "build"] +# Generate templ files using the tool defined in go.mod +RUN go tool templ generate + +# Build the optimized binary +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app/server ./cmd/schreifuchs-ch + +# Stage 3: Final minimal image +FROM alpine:latest +WORKDIR /app + +# Install root certificates and timezone data +RUN apk --no-cache add ca-certificates tzdata + +# Copy the compiled binary from the builder stage +COPY --from=go-builder /app/server . + +# Expose the application port +EXPOSE 8080 + +# Set the entrypoint +ENTRYPOINT ["/app/server"] diff --git a/GEMINI.md b/GEMINI.md deleted file mode 100644 index 56f8d27..0000000 --- a/GEMINI.md +++ /dev/null @@ -1,65 +0,0 @@ -# Project Context: Schreifuchs.ch - -## Overview - -This project is a personal portfolio website for "Schreifuchs", featuring sections for Photography (Fotos), Informatics (Informatik), Music (Musig), and Video. It is currently being transitioned from a static site to a dynamic Node.js site powered by Nextcloud via WebDAV. - -## Tech Stack - -- **Framework:** Svelte 5 (using Runes) & SvelteKit -- **Language:** TypeScript -- **Styling:** Tailwind CSS (with custom text-shadow plugin) -- **Bundler:** Vite -- **Adapter:** `@sveltejs/adapter-static` (SSG) -- **Markdown:** `@ts-stack/markdown` for content rendering - -## Directory Structure - -- `src/routes/`: File-based routing. - - `src/routes/fotos`, `informatik`, `musig`, `video`: Feature-specific pages. -- `src/lib/`: Shared utilities and components. - - `src/lib/components/`: Reusable UI components (`ImageTile`, `ImageLinkTile`, `Markdown`). - - `src/lib/images/`: Local image assets imported in components. -- `static/`: Static assets served as-is. - - Contains Markdown content files (`Fotos.md`, etc.) and their associated attachments. - -## Key Conventions - -- **Svelte 5:** Use Runes (`$state`, `$derived`, `$props`, etc.) for reactivity. -- **Styling:** Use Tailwind utility classes. The font family is configured to 'Outfit'. -- **Content:** Content is largely driven by Markdown files located on Nextcloud which are fetched and parsed. - -## Development Scripts - -- `npm run dev`: Start development server. -- `npm run build`: Build for production. -- `npm run check`: Run Svelte and TypeScript checks. - ---- - -# Agent Instructions (Svelte MCP) - -You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively: - -## Available MCP Tools: - -### 1. list-sections - -Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths. -When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections. - -### 2. get-documentation - -Retrieves full documentation content for specific sections. Accepts single or multiple sections. -After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task. - -### 3. svelte-autofixer - -Analyzes Svelte code and returns issues and suggestions. -You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned. - -### 4. playground-link - -Generates a Svelte Playground link with the provided code. -After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project. - diff --git a/cmd/schreifuchs-ch/main.go b/cmd/schreifuchs-ch/main.go new file mode 100644 index 0000000..55afa10 --- /dev/null +++ b/cmd/schreifuchs-ch/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "log/slog" + "os" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/server" +) + +func main() { + server := server.NewServer() + + slog.SetLogLoggerLevel(slog.LevelDebug) + slog.Info("Server started", "addr", server.Addr) + + err := server.ListenAndServe() + if err != nil { + slog.Error("Server failed to start", "error", err) + os.Exit(1) + } +} + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e78c91a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + valkey: + image: valkey/valkey:8 + restart: always + ports: + - "6379:6379" + command: valkey-server --requirepass "valkey" + healthcheck: + test: ["CMD", "valkey-cli", "-a", "valkey", "ping"] + interval: 5s + timeout: 5s + retries: 5 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a3845f6 --- /dev/null +++ b/go.mod @@ -0,0 +1,32 @@ +module git.schreifuchs.ch/schreifuchs/schreifuchs.ch + +go 1.26 + +tool github.com/a-h/templ/cmd/templ + +require ( + github.com/a-h/templ v0.3.977 + github.com/alicebob/miniredis/v2 v2.36.1 + github.com/gomarkdown/markdown v0.0.0-20260217112301-37c66b85d6ab + github.com/studio-b12/gowebdav v0.12.0 + github.com/valkey-io/valkey-go v1.0.72 + golang.org/x/image v0.36.0 +) + +require ( + github.com/a-h/parse v0.0.0-20250122154542-74294addb73e // indirect + github.com/andybalholm/brotli v1.1.0 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cli/browser v1.3.0 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/natefinch/atomic v1.0.1 // indirect + github.com/yuin/gopher-lua v1.1.1 // indirect + golang.org/x/mod v0.26.0 // indirect + golang.org/x/net v0.48.0 // indirect + golang.org/x/sync v0.16.0 // indirect + golang.org/x/sys v0.39.0 // indirect + golang.org/x/tools v0.35.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e285c29 --- /dev/null +++ b/go.sum @@ -0,0 +1,61 @@ +github.com/a-h/parse v0.0.0-20250122154542-74294addb73e h1:HjVbSQHy+dnlS6C3XajZ69NYAb5jbGNfHanvm1+iYlo= +github.com/a-h/parse v0.0.0-20250122154542-74294addb73e/go.mod h1:3mnrkvGpurZ4ZrTDbYU84xhwXW2TjTKShSwjRi2ihfQ= +github.com/a-h/templ v0.3.977 h1:kiKAPXTZE2Iaf8JbtM21r54A8bCNsncrfnokZZSrSDg= +github.com/a-h/templ v0.3.977/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo= +github.com/alicebob/miniredis/v2 v2.36.1 h1:Dvc5oAnNOr7BIfPn7tF269U8DvRW1dBG2D5n0WrfYMI= +github.com/alicebob/miniredis/v2 v2.36.1/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= +github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/gomarkdown/markdown v0.0.0-20260217112301-37c66b85d6ab h1:VYNivV7P8IRHUam2swVUNkhIdp0LRRFKe4hXNnoZKTc= +github.com/gomarkdown/markdown v0.0.0-20260217112301-37c66b85d6ab/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A= +github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM= +github.com/onsi/gomega v1.38.3 h1:eTX+W6dobAYfFeGC2PV6RwXRu/MyT+cQguijutvkpSM= +github.com/onsi/gomega v1.38.3/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/studio-b12/gowebdav v0.12.0 h1:kFRtQECt8jmVAvA6RHBz3geXUGJHUZA6/IKpOVUs5kM= +github.com/studio-b12/gowebdav v0.12.0/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE= +github.com/valkey-io/valkey-go v1.0.72 h1:iRWt1hJyOchcEgbHSkRY3aKkcBudxvMaVMsmxuYxuxE= +github.com/valkey-io/valkey-go v1.0.72/go.mod h1:VGhZ6fs68Qrn2+OhH+6waZH27bjpgQOiLyUQyXuYK5k= +github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= +github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/image v0.36.0 h1:Iknbfm1afbgtwPTmHnS2gTM/6PPZfH+z2EFuOkSbqwc= +golang.org/x/image v0.36.0/go.mod h1:YsWD2TyyGKiIX1kZlu9QfKIsQ4nAAK9bdgdrIsE7xy4= +golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= +golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= +golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= +golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0= +golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/components/images/controller.go b/internal/components/images/controller.go new file mode 100644 index 0000000..0d6724d --- /dev/null +++ b/internal/components/images/controller.go @@ -0,0 +1,118 @@ +package images + +import ( + "bytes" + "context" + "encoding/base64" + "encoding/binary" + "errors" + "fmt" + "hash/fnv" + "image" + "image/jpeg" + _ "image/jpeg" + _ "image/png" + "io" + "strings" + "time" + + "github.com/valkey-io/valkey-go" +) + +var ErrNotAnImage = errors.New("not an image") + +func (s *Service) getMime(path string) (mimeType string, err error) { + info, err := s.fs.Stat(path) + if err != nil { + err = fmt.Errorf("image file info could not be fetched: %w", err) + } + + if mimer, ok := info.(interface{ ContentType() string }); ok { + mimeType = mimer.ContentType() + } + + return +} + +func (s *Service) getImage(uid string) (file []byte, mimeType string, err error) { + path, err := PathFromUID(uid) + if err != nil { + err = fmt.Errorf("could not get path: %w", err) + return + } + mimeType, err = s.getMime(path) + if err != nil { + return + } + + if !strings.HasPrefix(mimeType, "image") { + err = ErrNotAnImage + return + } + + file, err = s.fs.Read(path) + if err != nil { + err = fmt.Errorf("image file could not be fetched") + } + + return +} + +func (s *Service) GetImage(ctx context.Context, uid string, options Options) (img io.Reader, mimeType string, err error) { + rawImage, mimeType, err := s.getImage(uid) + if err != nil { + return + } + + hash, err := hash(rawImage, options) + if err != nil { + return + } + + if imgBytes, err := s.cache.Do(ctx, s.cache.B().Get().Key("img:"+hash).Build()).AsBytes(); err == nil { + return bytes.NewBuffer(imgBytes), mimeType, err + } + + decImage, _, err := image.Decode(bytes.NewBuffer(rawImage)) + if err != nil { + return + } + + decImage = scale(decImage, options) + outBuff := bytes.NewBuffer(make([]byte, 0, 1024)) + + if options.Quality == 0 { + options.Quality = 80 + } + + err = jpeg.Encode(outBuff, decImage, &jpeg.Options{Quality: options.Quality}) + if err != nil { + return + } + if err = s.cache.Do(ctx, s.cache.B().Set().Key("img:"+hash).Value(valkey.BinaryString(outBuff.Bytes())).Ex(time.Hour*48).Build()).Error(); err == nil { + return outBuff, "image/jpeg", err + } + + return outBuff, "image/jpeg", err +} + +func hash(bytes []byte, options Options) (hash string, err error) { + h := fnv.New128() + + if _, err = h.Write(bytes); err != nil { + return + } + if err = binary.Write(h, binary.LittleEndian, int64(options.Height)); err != nil { + return + } + if err = binary.Write(h, binary.LittleEndian, int64(options.Width)); err != nil { + return + } + if err = binary.Write(h, binary.LittleEndian, int64(options.Quality)); err != nil { + return + } + + res := h.Sum(make([]byte, 0, 128/8)) + + return base64.RawStdEncoding.EncodeToString(res), nil +} diff --git a/internal/components/images/helpers.go b/internal/components/images/helpers.go new file mode 100644 index 0000000..7afce25 --- /dev/null +++ b/internal/components/images/helpers.go @@ -0,0 +1,68 @@ +package images + +import ( + "bytes" + "compress/flate" + "encoding/base64" + "fmt" + "io" + "strings" +) + +func UIDFromPath(path string) (uid string, err error) { + var b bytes.Buffer + // NewWriter with NoDict (nil) creates a raw DEFLATE compressor + zw, _ := flate.NewWriter(&b, flate.BestCompression) + + _, err = zw.Write([]byte(path)) + if err != nil { + return + } + err = zw.Close() // Essential to flush the final bits + if err != nil { + return + } + + return base64.RawURLEncoding.EncodeToString(b.Bytes()), nil +} + +func URLFromPath(path string) (url string, err error) { + uid, err := UIDFromPath(path) + url = "/images/" + uid + return +} + +func PathFromUID(uid string) (string, error) { + // 1. Decode the Base64 string back to compressed bytes + compressedBytes, err := base64.RawURLEncoding.DecodeString(uid) + if err != nil { + return "", err + } + + // 2. Create a flate reader (NoDict/nil since you used nil in the writer) + // flate.NewReader returns an io.ReadCloser + reader := flate.NewReader(bytes.NewReader(compressedBytes)) + defer reader.Close() + + // 3. Read the decompressed data into a buffer + var out bytes.Buffer + _, err = io.Copy(&out, reader) + if err != nil { + return "", err + } + + return out.String(), nil +} + +func SourceSet(src string) string { + sb := strings.Builder{} + + for i := range 19 { + sb.WriteString(fmt.Sprintf("%s?w=%d %dw, ", src, 100*(i+1), 100*(i+1))) + } + + i := 20 + sb.WriteString(fmt.Sprintf("%s?w=%d %dw", src, 100*(i+1), 100*(i+1))) + + return sb.String() +} diff --git a/internal/components/images/resorce.go b/internal/components/images/resorce.go new file mode 100644 index 0000000..98d36e8 --- /dev/null +++ b/internal/components/images/resorce.go @@ -0,0 +1,30 @@ +package images + +import ( + "os" + + "github.com/valkey-io/valkey-go" +) + +type Options struct { + Width int // max width, 0 is unlimited + Height int // max Height, 0 is unlimited + Quality int // quality of the output jpeg +} + +type Service struct { + fs fileSystem + cache valkey.Client +} + +func New(fs fileSystem, cache valkey.Client) *Service { + return &Service{ + fs: fs, + cache: cache, + } +} + +type fileSystem interface { + Read(path string) ([]byte, error) + Stat(path string) (os.FileInfo, error) +} diff --git a/internal/components/images/scaling.go b/internal/components/images/scaling.go new file mode 100644 index 0000000..1244c27 --- /dev/null +++ b/internal/components/images/scaling.go @@ -0,0 +1,55 @@ +package images + +import ( + "image" + "math" + + "golang.org/x/image/draw" +) + +func scale(src image.Image, options Options) image.Image { + // Set the expected size that you want: + dst := image.NewRGBA( + calculateFit(src.Bounds(), options), + ) + + // Resize: + draw.BiLinear.Scale(dst, dst.Rect, src, src.Bounds(), draw.Over, nil) + + // Encode to `output`: + return dst +} + +// calculateFit returns the new dimensions (width, height) that fit within the +// provided Options without upscaling and while maintaining the aspect ratio. +func calculateFit(bounds image.Rectangle, opt Options) image.Rectangle { + // If no limits are set, or the image is already smaller than the limits, + // return original dimensions (No Upscaling). + if (opt.Width == 0 || bounds.Max.X <= opt.Width) && (opt.Height == 0 || bounds.Max.Y <= opt.Height) { + return bounds + } + + // Calculate ratios for width and height + ratioW := float64(opt.Width) / float64(bounds.Max.X) + ratioH := float64(opt.Height) / float64(bounds.Max.Y) + + // Determine the scale factor + var scale float64 + if opt.Width > 0 && opt.Height > 0 { + // Use the smaller ratio to ensure it fits in both bounds + scale = math.Min(ratioW, ratioH) + } else if opt.Width > 0 { + scale = ratioW + } else if opt.Height > 0 { + scale = ratioH + } else { + return bounds + } + + return image.Rect( + 0, + 0, + int(math.Round(float64(bounds.Max.X)*scale)), + int(math.Round(float64(bounds.Max.Y)*scale)), + ) +} diff --git a/internal/components/page/controller.go b/internal/components/page/controller.go new file mode 100644 index 0000000..188f986 --- /dev/null +++ b/internal/components/page/controller.go @@ -0,0 +1,59 @@ +package page + +import ( + "context" + "log/slog" + "strings" +) + +type PageHeader struct { + UID string + Title string + CoverImageUID string + md []byte // markdown of the page //markdown of the page +} + +type Page struct { + PageHeader + Content string +} + +func (s *Service) GetPages(ctx context.Context) (pages []PageHeader, err error) { + paths, err := s.fs.ReadDir("/") + if err != nil { + return + } + + for _, path := range paths { + if strings.HasPrefix(path.Name(), ".") || // hidden files + strings.HasPrefix(path.Name(), "_") { // hidden pages + continue + } + page, err := s.getPageHeaders(ctx, path.Name()) + if err != nil { // just ignore missing pages + slog.Error("could not open path", "path", path.Name(), "err", err) + continue + } + pages = append(pages, page) + } + + return +} + +func (s *Service) GetPage(ctx context.Context, uid string) (page Page, err error) { + p, err := s.getPageHeaders(ctx, uid) + if err != nil { + return + } + + html, err := s.getHTML(ctx, p) + if err != nil { + return + } + + page = Page{ + PageHeader: p, + Content: string(html), + } + return +} diff --git a/internal/components/page/html.go b/internal/components/page/html.go new file mode 100644 index 0000000..c1d97fc --- /dev/null +++ b/internal/components/page/html.go @@ -0,0 +1,69 @@ +package page + +import ( + "context" + "io" + "log/slog" + "net/url" + "strings" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images" + "github.com/gomarkdown/markdown" + "github.com/gomarkdown/markdown/ast" + "github.com/gomarkdown/markdown/html" + "github.com/gomarkdown/markdown/parser" +) + +func (s *Service) getHTML(ctx context.Context, page PageHeader) (out []byte, err error) { + extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock + p := parser.NewWithExtensions(extensions) + + doc := p.Parse(page.md) + + // create HTML renderer with extensions + htmlFlags := html.CommonFlags | html.HrefTargetBlank + opts := html.RendererOptions{ + Flags: htmlFlags, + RenderNodeHook: imageMiddleware(page), + } + renderer := html.NewRenderer(opts) + + out = markdown.Render(doc, renderer) + return +} + +func imageMiddleware(page PageHeader) func(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool) { + return func(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool) { + if !entering { + return ast.GoToNext, false + } + img, ok := node.(*ast.Image) + if !ok { + return ast.GoToNext, false + } + src := string(img.Destination) + if strings.HasPrefix(src, ".attachments") { + imgPath, err := url.PathUnescape(src) + if err != nil { + slog.Error("could not unescape path", "err", err) + return ast.GoToNext, false + } + src, err = images.URLFromPath(page.UID + "/" + imgPath) + if err != nil { + slog.Error("could not get image url", "err", err) + return ast.GoToNext, false + } + + img.Attribute = &ast.Attribute{Attrs: map[string][]byte{ + "srcset": []byte(images.SourceSet(src)), + "src": []byte(src), + }} + // // img.Attrs["srcset"] = + + } + + img.Destination = []byte(src) + + return ast.GoToNext, false + } +} diff --git a/internal/components/page/page.go b/internal/components/page/page.go new file mode 100644 index 0000000..d7315db --- /dev/null +++ b/internal/components/page/page.go @@ -0,0 +1,80 @@ +package page + +import ( + "context" + "errors" + "fmt" + "log/slog" + "regexp" + "strings" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/translate" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/filesystem" + "github.com/studio-b12/gowebdav" +) + +var titleRGX = regexp.MustCompile(`(?m)^#\s+(.+)$`) + +var ( + ErrMalFormedInput = errors.New("mal formed input") + ErrNotFound = errors.New("not found") +) + +func (s *Service) getPageHeaders(ctx context.Context, uid string) (page PageHeader, err error) { + info, err := s.fs.ReadDir(uid) + if gowebdav.IsErrNotFound(err) { // try private + err = ErrNotFound + } + if err != nil { + return + } + + lang := translate.Language(ctx) + + var coverImage filesystem.FileInfo + var contentMD filesystem.FileInfo + + for _, f := range info { + file, ok := f.(filesystem.FileInfo) + if !ok { + continue + } + + if strings.HasPrefix(file.ContentType(), "image/") { + coverImage = file + } + + parts := strings.Split(file.Name(), ".") + + // fallback content + if contentMD == nil && len(parts) == 2 && parts[1] == "md" { + contentMD = file + } + // language content + if len(parts) == 3 && parts[1] == lang && parts[2] == "md" { + contentMD = file + } + } + + slog.Debug("loaded page infos", "cover", coverImage, "content", contentMD) + + page.md, err = s.fs.Read(contentMD.Path()) + if err != nil { + return + } + + title := titleRGX.FindStringSubmatch(string(page.md)) + if len(title) < 2 { + err = fmt.Errorf("%w: no matches for title", ErrMalFormedInput) + return + } + + page.UID = uid + page.Title = title[1] + if coverImage != nil { + page.CoverImageUID, err = images.UIDFromPath(coverImage.Path()) + } + + return +} diff --git a/internal/components/page/resource.go b/internal/components/page/resource.go new file mode 100644 index 0000000..9c9780e --- /dev/null +++ b/internal/components/page/resource.go @@ -0,0 +1,15 @@ +package page + +import ( + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/filesystem" +) + +type Service struct { + fs filesystem.FS +} + +func New(fs filesystem.FS) *Service { + return &Service{ + fs: fs, + } +} diff --git a/internal/components/translate/context.go b/internal/components/translate/context.go new file mode 100644 index 0000000..c9a3750 --- /dev/null +++ b/internal/components/translate/context.go @@ -0,0 +1,81 @@ +package translate + +import ( + "context" + "log/slog" + "path" +) + +type contextKey string + +const ( + serviceKey contextKey = "translationService" + langKey contextKey = "language" +) + +func Language(ctx context.Context) string { + lang, ok := ctx.Value(langKey).(string) + if !ok { + return "" + } + return lang +} + +func SupportedLanguages(ctx context.Context) []string { + s, ok := ctx.Value(serviceKey).(*Service) + if !ok { + slog.Error("could not extract translation service from context for getting supported languages") + } + return s.SupportedLanguages() +} + +func T(ctx context.Context, key string) string { + s, ok := ctx.Value(serviceKey).(*Service) + if !ok { + slog.Error("could not extract translation service from context", "ctx", ctx, "key", key) + return key + } + + lang := Language(ctx) + + translation, ok := s.translations[lang][key] + if !ok { + slog.Warn("could not translate", "key", key, "language", lang) + return key + } + + return translation +} + +func Path(ctx context.Context, pp ...string) string { + return PathForLang(ctx, Language(ctx), pp...) +} + +func PathForLang(ctx context.Context, lang string, pp ...string) string { + slog.Info("path for lang", "path", pp) + s, ok := ctx.Value(serviceKey).(*Service) + if !ok { + slog.Error("could not extract translation service from context for translating path", "ctx", ctx, "path", pp) + return path.Join(pp...) + } + + if len(pp) > 0 { + if _, ok := s.translations[pp[0]]; ok { + pp = pp[1:] + } + } + + return path.Join(append([]string{lang}, pp...)...) +} + +func (s *Service) SupportedLanguages() (languages []string) { + for lang := range s.translations { + languages = append(languages, lang) + } + + return +} + +func (s *Service) DefaultLanguage() string { + return s.defaultLanguage +} diff --git a/internal/components/translate/middleware.go b/internal/components/translate/middleware.go new file mode 100644 index 0000000..bae5a5d --- /dev/null +++ b/internal/components/translate/middleware.go @@ -0,0 +1,87 @@ +package translate + +import ( + "context" + "log/slog" + "net/http" + "strings" +) + +func (s *Service) Middleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + path := r.URL.Path + segments := []string{} + for segment := range strings.SplitSeq(path, "/") { + if segment != "" { + segments = append(segments, segment) + } + } + + // 1. Check if the first segment is a supported language. + var currentLang string + if len(segments) >= 1 { + potentialLang := segments[0] + if _, ok := s.translations[potentialLang]; ok { + currentLang = potentialLang + } + } + + if currentLang != "" { + // CASE A: Language is present in the URL. + // Remove the language from the path so the router sees the clean path. + newPath := "/" + strings.Join(segments[1:], "/") + if newPath == "" { + newPath = "/" + } + + // Update the request URL path. + r.URL.Path = newPath + + // Inject translator into context. + ctx := context.WithValue(r.Context(), serviceKey, s) + ctx = context.WithValue(ctx, langKey, currentLang) + + // Pass control to the next handler with the modified request. + next.ServeHTTP(w, r.WithContext(ctx)) + return + } + + // CASE B: Language is NOT in the URL. + // Detect best language from Accept-Language header. + detectedLang := s.detectLanguage(r.Header.Get("Accept-Language")) + + // Redirect to the URL with the language prefix. + targetURL := "/" + detectedLang + path + if r.URL.RawQuery != "" { + targetURL += "?" + r.URL.RawQuery + } + + slog.Debug("redirecting for translated url", "old", path, "new", targetURL) + http.Redirect(w, r, targetURL, http.StatusFound) + }) +} + +// detectLanguage parses the Accept-Language header and returns the best matching supported language. +func (s *Service) detectLanguage(header string) string { + if header == "" { + return s.defaultLanguage + } + + // Simple parser for Accept-Language: en-US,en;q=0.9,de;q=0.8 + // We only care about the first match for simplicity here, or we could rank them. + parts := strings.Split(header, ",") + for _, part := range parts { + tag := strings.Split(strings.TrimSpace(part), ";")[0] + // Check for exact match (e.g., "en-US") + if _, ok := s.translations[tag]; ok { + return tag + } + // Check for base match (e.g., "en" from "en-US") + base := strings.Split(tag, "-")[0] + if _, ok := s.translations[base]; ok { + return base + } + } + + return s.defaultLanguage +} diff --git a/internal/components/translate/resource.go b/internal/components/translate/resource.go new file mode 100644 index 0000000..b9eae2f --- /dev/null +++ b/internal/components/translate/resource.go @@ -0,0 +1,22 @@ +package translate + +type Translations map[string]string // key -> translation + +type Service struct { + translations map[string]Translations // language -> translations + defaultLanguage string +} + +func New() *Service { + return &Service{ + defaultLanguage: "de", + translations: map[string]Translations{ + "de": { + "home": "Startseite", + }, + "en": { + "home": "Home", + }, + }, + } +} diff --git a/internal/filesystem/cache.go b/internal/filesystem/cache.go new file mode 100644 index 0000000..022e346 --- /dev/null +++ b/internal/filesystem/cache.go @@ -0,0 +1,70 @@ +package filesystem + +import ( + "context" + "log/slog" + "sync/atomic" + "time" + + "github.com/valkey-io/valkey-go" +) + +const keyStat = "webdav:stat:" + +// CachedClient wraps a FileSystem implementation with Valkey caching. +type CachedClient struct { + impl FS + cache valkey.Client + ttl time.Duration + hits atomic.Int64 + misses atomic.Int64 + readDirHits atomic.Int64 + readHits atomic.Int64 +} + +// NewCachedClient creates a new CachedClient. +func NewCachedClient(impl FS, client valkey.Client, refreshtime time.Duration) *CachedClient { + c := &CachedClient{ + impl: impl, + cache: client, + ttl: refreshtime * 5, + } + + go func() { + t := time.NewTicker(refreshtime) + for { + <-t.C + c.revalidate(context.Background()) + } + }() + + return c +} + +func (c *CachedClient) revalidate(ctx context.Context) { + go c.revalidateReadDir(ctx) + go c.revalidateRead(ctx) + go c.revalidateStat(ctx) +} + +func (c *CachedClient) scanAndProcess(ctx context.Context, match string, process func(key string) error) { + cursor := uint64(0) + for { + res, err := c.cache.Do(ctx, c.cache.B().Scan().Cursor(cursor).Match(match).Build()).AsScanEntry() + if err != nil { + slog.Error("scan failed", "match", match, "err", err) + return + } + + for _, key := range res.Elements { + if err := process(key); err != nil { + slog.Debug("process failed", "key", key, "err", err) + } + } + + cursor = res.Cursor + if cursor == 0 { + break + } + } +} diff --git a/internal/filesystem/cache_test.go b/internal/filesystem/cache_test.go new file mode 100644 index 0000000..0fee7b9 --- /dev/null +++ b/internal/filesystem/cache_test.go @@ -0,0 +1,58 @@ +package filesystem + +import ( + "encoding/json" + "os" + "testing" + "time" +) + +func TestCachedFile_Serialization(t *testing.T) { + now := time.Now().Truncate(time.Second) // JSON marshal of time might lose precision + cf := File{ + name: "test.md", + size: 123, + mode: 0o644, + modTime: now, + isDir: false, + contentType: "text/markdown", + path: "/test.md", + } + + data, err := json.Marshal(cf) + if err != nil { + t.Fatalf("Marshal failed: %v", err) + } + + var cf2 File + if err := json.Unmarshal(data, &cf2); err != nil { + t.Fatalf("Unmarshal failed: %v", err) + } + + if cf.name != cf2.name { + t.Errorf("Name mismatch: %s != %s", cf.name, cf2.name) + } + if cf.size != cf2.size { + t.Errorf("Size mismatch: %d != %d", cf.size, cf2.size) + } + if cf.mode != cf2.mode { + t.Errorf("Mode mismatch: %v != %v", cf.mode, cf2.mode) + } + if !cf.modTime.Equal(cf2.modTime) { + t.Errorf("ModTime mismatch: %v != %v", cf.modTime, cf2.modTime) + } + if cf.isDir != cf2.isDir { + t.Errorf("IsDir mismatch: %v != %v", cf.isDir, cf2.isDir) + } + if cf.contentType != cf2.contentType { + t.Errorf("ContentType mismatch: %s != %s", cf.contentType, cf2.contentType) + } + if cf.path != cf2.path { + t.Errorf("Path mismatch: %s != %s", cf.path, cf2.path) + } +} + +func TestCachedFile_Interface(t *testing.T) { + // Verify CachedFile implements os.FileInfo + var _ os.FileInfo = File{} +} diff --git a/internal/filesystem/cached_client_test.go b/internal/filesystem/cached_client_test.go new file mode 100644 index 0000000..2a22a57 --- /dev/null +++ b/internal/filesystem/cached_client_test.go @@ -0,0 +1,464 @@ +package filesystem + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/alicebob/miniredis/v2" + "github.com/valkey-io/valkey-go" +) + +// MockFS implements filesystem.FS interface for testing. +type MockFS struct { + files map[string]*MockFile +} + +// MockFile implements FileInfo and holds content. +type MockFile struct { + name string + content []byte + mode os.FileMode + modTime time.Time + isDir bool + contentType string + path string +} + +func (f *MockFile) Name() string { return f.name } +func (f *MockFile) Size() int64 { return int64(len(f.content)) } +func (f *MockFile) Mode() os.FileMode { return f.mode } +func (f *MockFile) ModTime() time.Time { return f.modTime } +func (f *MockFile) IsDir() bool { return f.isDir } +func (f *MockFile) Sys() any { return nil } +func (f *MockFile) ContentType() string { return f.contentType } +func (f *MockFile) Path() string { return f.path } + +func NewMockFS() *MockFS { + return &MockFS{ + files: make(map[string]*MockFile), + } +} + +func (m *MockFS) AddFile(path string, content []byte) { + m.files[path] = &MockFile{ + name: path, + content: content, + mode: 0o644, + modTime: time.Now().Truncate(time.Second), + isDir: false, + contentType: "text/plain", + path: path, + } +} + +func (m *MockFS) AddDir(path string) { + m.files[path] = &MockFile{ + name: path, + mode: 0o755, + modTime: time.Now().Truncate(time.Second), + isDir: true, + path: path, + } +} + +func (m *MockFS) Read(path string) ([]byte, error) { + f, ok := m.files[path] + if !ok { + return nil, os.ErrNotExist + } + if f.isDir { + return nil, errors.New("is a directory") + } + return f.content, nil +} + +func (m *MockFS) ReadDir(path string) ([]os.FileInfo, error) { + // Simple implementation: return files that start with path + "/" + // For deeper nesting, simulate direct children only. + // Assume flat structure for simplicity or specific test setup. + var infos []os.FileInfo + for p, f := range m.files { + // Just check if it's logically "inside" the directory + // e.g. path="/foo", file="/foo/bar" -> yes + // file="/foo/bar/baz" -> no (if strict direct children) + // file="/other" -> no + if p == path { + continue // self + } + // Check prefix + // if path is root "/", check if p has no other slashes? + // if path is "/foo", check if p starts with "/foo/" and has no further slashes + // This logic is simple but sufficient for tests. + // Let's assume absolute paths. + // If path does not end with /, append it for prefix check + prefix := path + if len(prefix) > 0 && prefix[len(prefix)-1] != '/' { + prefix += "/" + } + + if len(p) > len(prefix) && p[:len(prefix)] == prefix { + // Ensure direct child (no more slashes) + rel := p[len(prefix):] + // Count slashes in rel. If 0, it's a direct child. + slashCount := 0 + for _, c := range rel { + if c == '/' { + slashCount++ + } + } + if slashCount == 0 { + infos = append(infos, f) + } + } + } + if len(infos) == 0 { + // Check if directory exists at all + if _, ok := m.files[path]; !ok { + return nil, os.ErrNotExist + } + } + return infos, nil +} + +func (m *MockFS) Stat(path string) (os.FileInfo, error) { + f, ok := m.files[path] + if !ok { + return nil, os.ErrNotExist + } + return f, nil +} + +func TestCachedClient_Stat(t *testing.T) { + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("failed to start miniredis: %v", err) + } + defer mr.Close() + + client, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{mr.Addr()}, + DisableCache: true, + }) + if err != nil { + t.Fatalf("failed to create valkey client: %v", err) + } + defer client.Close() + + mockFS := NewMockFS() + mockFS.AddFile("/test.txt", []byte("hello")) + + c := NewCachedClient(mockFS, client, time.Hour) + + // First call: Cache miss + info, err := c.Stat("/test.txt") + if err != nil { + t.Fatalf("Stat failed: %v", err) + } + if info.Name() != "/test.txt" { + t.Errorf("expected name /test.txt, got %s", info.Name()) + } + if c.misses.Load() != 1 { + t.Errorf("expected 1 miss, got %d", c.misses.Load()) + } + if c.hits.Load() != 0 { + t.Errorf("expected 0 hits, got %d", c.hits.Load()) + } + + // Second call: Cache hit + info2, err := c.Stat("/test.txt") + if err != nil { + t.Fatalf("Stat failed: %v", err) + } + if info2.Size() != info.Size() { + t.Errorf("size mismatch") + } + if c.misses.Load() != 1 { + t.Errorf("expected 1 miss, got %d", c.misses.Load()) + } + if c.hits.Load() != 1 { + t.Errorf("expected 1 hit, got %d", c.hits.Load()) + } + + // Verify valkey content + keys := mr.Keys() + if len(keys) != 1 { + t.Errorf("expected 1 key in redis, got %d", len(keys)) + } +} + +func TestCachedClient_Read(t *testing.T) { + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("failed to start miniredis: %v", err) + } + defer mr.Close() + + client, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{mr.Addr()}, + DisableCache: true, + }) + if err != nil { + t.Fatalf("failed to create valkey client: %v", err) + } + defer client.Close() + + mockFS := NewMockFS() + content := []byte("hello world") + mockFS.AddFile("/read.txt", content) + + c := NewCachedClient(mockFS, client, time.Hour) + + // First call: Miss + data, err := c.Read("/read.txt") + if err != nil { + t.Fatalf("Read failed: %v", err) + } + if string(data) != string(content) { + t.Errorf("content mismatch") + } + if c.misses.Load() != 1 { + t.Errorf("expected 1 miss, got %d", c.misses.Load()) + } + + // Second call: Hit + data2, err := c.Read("/read.txt") + if err != nil { + t.Fatalf("Read failed: %v", err) + } + if string(data2) != string(content) { + t.Errorf("content mismatch") + } + if c.hits.Load() != 1 { + t.Errorf("expected 1 hit, got %d", c.hits.Load()) + } +} + +func TestCachedClient_ReadDir(t *testing.T) { + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("failed to start miniredis: %v", err) + } + defer mr.Close() + + client, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{mr.Addr()}, + DisableCache: true, + }) + if err != nil { + t.Fatalf("failed to create valkey client: %v", err) + } + defer client.Close() + + mockFS := NewMockFS() + mockFS.AddDir("/dir") + mockFS.AddFile("/dir/f1.txt", []byte("1")) + mockFS.AddFile("/dir/f2.txt", []byte("2")) + + c := NewCachedClient(mockFS, client, time.Hour) + + // First call: Miss + infos, err := c.ReadDir("/dir") + if err != nil { + t.Fatalf("ReadDir failed: %v", err) + } + if len(infos) != 2 { + t.Errorf("expected 2 files, got %d", len(infos)) + } + if c.misses.Load() != 1 { + t.Errorf("expected 1 miss, got %d", c.misses.Load()) + } + + // Second call: Hit + infos2, err := c.ReadDir("/dir") + if err != nil { + t.Fatalf("ReadDir failed: %v", err) + } + if len(infos2) != 2 { + t.Errorf("expected 2 files, got %d", len(infos2)) + } + if c.hits.Load() != 1 { + t.Errorf("expected 1 hit, got %d", c.hits.Load()) + } +} + +func TestCachedClient_RevalidateStat(t *testing.T) { + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("failed to start miniredis: %v", err) + } + defer mr.Close() + + client, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{mr.Addr()}, + DisableCache: true, + }) + if err != nil { + t.Fatalf("failed to create valkey client: %v", err) + } + defer client.Close() + + mockFS := NewMockFS() + mockFS.AddFile("/reval.txt", []byte("initial")) + + c := NewCachedClient(mockFS, client, time.Hour) + + // Populate cache + _, _ = c.Stat("/reval.txt") + + // Update mock file (simulate external change) + // For simplicity, just update size + f := mockFS.files["/reval.txt"] + f.content = []byte("updated content") + // Important: update modTime to be newer than cached + f.modTime = time.Now().Add(time.Minute) + + // Run revalidation manually + // Note: revalidateStat is a private method, so we can test it directly here + // because we are in package filesystem (if using package filesystem_test we couldn't) + // But `revalidateStat` only iterates over keys in redis. So we need to ensure the key is there. + // `Stat` put it there. + + // Wait, Stat puts it there. `revalidateStat` iterates keys matching `keyStat*`. + // For each key, it checks `Stat` again. + // Wait, looking at `revalidateStat` implementation: + // It calls `c.impl.Stat(path)`. If successful, it updates cache. + // It doesn't check ModTime explicitly for `Stat` revalidation, it just blindly updates? + // Let's check `revalidateStat` implementation in `cache.go`. + + // func (c *CachedClient) revalidateStat(ctx context.Context) { ... + // info, err := c.impl.Stat(path) + // ... + // bytes, err := json.Marshal(f) + // c.client.Do(...Set...) + // } + // Yes, it blindly updates. So modification time doesn't matter for `Stat`, it just fetches fresh info. + + c.revalidateStat(context.Background()) + + // Verify cache is updated by fetching from cache again + // We can inspect redis directly or trust `Stat` returns cached value (which should be updated). + // Let's inspect redis to be sure. + // Or just call Stat again. It should be a cache HIT, but return NEW values. + + // Reset stats to check hit + c.hits.Store(0) + c.misses.Store(0) + + info, err := c.Stat("/reval.txt") + if err != nil { + t.Fatalf("Stat failed: %v", err) + } + + if info.Size() != int64(len("updated content")) { + t.Errorf("expected size %d, got %d", len("updated content"), info.Size()) + } + + // Should be a hit because revalidate updated the cache entry, so it exists and is valid. + if c.hits.Load() != 1 { + t.Errorf("expected 1 hit, got %d", c.hits.Load()) + } +} + +func TestCachedClient_RevalidateRead(t *testing.T) { + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("failed to start miniredis: %v", err) + } + defer mr.Close() + + client, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{mr.Addr()}, + DisableCache: true, + }) + if err != nil { + t.Fatalf("failed to create valkey client: %v", err) + } + defer client.Close() + + mockFS := NewMockFS() + mockFS.AddFile("/read_reval.txt", []byte("initial")) + + c := NewCachedClient(mockFS, client, time.Hour) + + // Populate cache + _, _ = c.Read("/read_reval.txt") + + // Update mock file (simulate external change) + f := mockFS.files["/read_reval.txt"] + f.content = []byte("updated content") + f.modTime = time.Now().Add(time.Minute) // Newer ModTime triggers update + + // Run revalidation manually + c.revalidateRead(context.Background()) + + // Verify cache is updated + // Reset stats + c.hits.Store(0) + c.misses.Store(0) + + data, err := c.Read("/read_reval.txt") + if err != nil { + t.Fatalf("Read failed: %v", err) + } + if string(data) != "updated content" { + t.Errorf("expected updated content, got %s", string(data)) + } + if c.hits.Load() != 1 { + t.Errorf("expected 1 hit, got %d", c.hits.Load()) + } +} + +func TestCachedClient_RevalidateReadDir(t *testing.T) { + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("failed to start miniredis: %v", err) + } + defer mr.Close() + + client, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{mr.Addr()}, + DisableCache: true, + }) + if err != nil { + t.Fatalf("failed to create valkey client: %v", err) + } + defer client.Close() + + mockFS := NewMockFS() + mockFS.AddDir("/dir_reval") + mockFS.AddFile("/dir_reval/f1.txt", []byte("1")) + + c := NewCachedClient(mockFS, client, time.Hour) + + // Populate cache + _, err = c.ReadDir("/dir_reval") + if err != nil { + t.Fatalf("ReadDir failed: %v", err) + } + + // Update mock file (simulate external change) + mockFS.AddFile("/dir_reval/f2.txt", []byte("2")) + + // Run revalidation manually + c.revalidateReadDir(context.Background()) + + // Verify cache is updated + // Reset stats + c.hits.Store(0) + c.misses.Store(0) + + infos2, err := c.ReadDir("/dir_reval") + if err != nil { + t.Fatalf("ReadDir failed: %v", err) + } + if len(infos2) != 2 { + t.Errorf("expected 2 files after revalidation, got %d", len(infos2)) + } + if c.hits.Load() != 1 { + t.Errorf("expected 1 hit, got %d", c.hits.Load()) + } +} + diff --git a/internal/filesystem/model.go b/internal/filesystem/model.go new file mode 100644 index 0000000..2a7f05b --- /dev/null +++ b/internal/filesystem/model.go @@ -0,0 +1,106 @@ +package filesystem + +import ( + "encoding/json" + "os" + "time" +) + +type FS interface { + ReadDir(path string) ([]os.FileInfo, error) + Read(path string) ([]byte, error) + Stat(path string) (os.FileInfo, error) +} + +type FileInfo interface { + os.FileInfo + ContentType() string + Path() string +} + +// File implements FileInfo +type File struct { + name string + size int64 + mode os.FileMode + modTime time.Time + isDir bool + contentType string + path string +} + +func (f File) Name() string { return f.name } +func (f File) Size() int64 { return f.size } +func (f File) Mode() os.FileMode { return f.mode } +func (f File) ModTime() time.Time { return f.modTime } +func (f File) IsDir() bool { return f.isDir } +func (f File) Sys() any { return nil } +func (f File) ContentType() string { return f.contentType } +func (f File) Path() string { return f.path } + +type serializableFile struct { + Name string `json:"name"` + Size int64 `json:"size"` + Mode os.FileMode `json:"mode"` + ModTime time.Time `json:"modTime"` + IsDir bool `json:"isDir"` + ContentType string `json:"contentType"` + Path string `json:"path"` +} + +// MarshalJSON implements json.Marshaler +func (f File) MarshalJSON() ([]byte, error) { + // Create a local shadow struct with exported fields for the JSON package + return json.Marshal(serializableFile{ + Name: f.name, + Size: f.size, + Mode: f.mode, + ModTime: f.modTime, + IsDir: f.isDir, + ContentType: f.contentType, + Path: f.path, + }) +} + +// UnmarshalJSON implements json.Unmarshaler +func (f *File) UnmarshalJSON(data []byte) error { + // Define a shadow struct to capture the incoming JSON + shadow := serializableFile{} + + if err := json.Unmarshal(data, &shadow); err != nil { + return err + } + + // Transfer values to the actual struct + f.name = shadow.Name + f.size = shadow.Size + f.mode = shadow.Mode + f.modTime = shadow.ModTime + f.isDir = shadow.IsDir + f.contentType = shadow.ContentType + f.path = shadow.Path + return nil +} + +func ParseToFile(file os.FileInfo) File { + if fi, ok := file.(FileInfo); ok { + return File{ + name: fi.Name(), + size: fi.Size(), + mode: fi.Mode(), + modTime: fi.ModTime(), + isDir: fi.IsDir(), + contentType: fi.ContentType(), + path: fi.Path(), + } + } else { + // Fallback if underlying impl returns generic os.FileInfo + return File{ + name: file.Name(), + size: file.Size(), + mode: file.Mode(), + modTime: file.ModTime(), + isDir: file.IsDir(), + } + } +} diff --git a/internal/filesystem/read.go b/internal/filesystem/read.go new file mode 100644 index 0000000..ac4b728 --- /dev/null +++ b/internal/filesystem/read.go @@ -0,0 +1,109 @@ +package filesystem + +import ( + "context" + "encoding/json" + "log/slog" + "strings" + "time" + + "github.com/valkey-io/valkey-go" +) + +const keyRead = "webdav:read:" + +type readFile struct { + Age time.Time `json:"age"` + Content []byte `json:"content"` +} + +func (c *CachedClient) Read(path string) ([]byte, error) { + key := keyRead + path + ctx := context.Background() + + // Try cache + cached, err := c.cache.Do(ctx, c.cache.B().Get().Key(key).Build()).AsBytes() + if err == nil && len(cached) > 0 { + c.readHits.Add(1) + c.hits.Add(1) + slog.Debug("cache hit", "key", key) + + var file readFile + err := json.Unmarshal(cached, &file) + if err != nil { + slog.Error("could not Unmarshal cache", "key", key, "err", err) + } else { + return file.Content, nil + } + + } + + // Cache miss + c.misses.Add(1) + slog.Debug("cache miss", "key", key) + + data, err := c.impl.Read(path) + if err != nil { + return nil, err + } + file := readFile{ + Age: time.Now(), + Content: data, + } + + cached, err = json.Marshal(file) + if err != nil { + slog.Error("could not marshal file for cache", "key", key, "err", err) + return data, nil + } + + // Cache + c.cache.Do(ctx, c.cache.B().Set().Key(key).Value(valkey.BinaryString(cached)).Ex(c.ttl).Build()) + + return data, nil +} + +func (c *CachedClient) revalidateRead(ctx context.Context) { + startTime := time.Now() + c.scanAndProcess(ctx, keyRead+"*", func(key string) error { + path := strings.TrimPrefix(key, keyRead) + cached, err := c.cache.Do(ctx, c.cache.B().Get().Key(key).Build()).AsBytes() + if err != nil { + // Key might be gone or error fetching + return nil + } + + var cachedFile readFile + err = json.Unmarshal(cached, &cachedFile) + if err != nil { + c.cache.Do(ctx, c.cache.B().Del().Key(key).Build()) + return err + } + + info, err := c.impl.Stat(path) + if err != nil { + c.cache.Do(ctx, c.cache.B().Del().Key(key).Build()) + return nil + } + + if info.ModTime().After(cachedFile.Age) { + data, err := c.impl.Read(path) + if err != nil { + return err + } + cachedFile.Age = time.Now() + cachedFile.Content = data + + newCached, err := json.Marshal(cachedFile) + if err != nil { + return err + } + + c.cache.Do(ctx, c.cache.B().Set().Key(key).Value(valkey.BinaryString(newCached)).Ex(c.ttl).Build()) + } else { + c.cache.Do(ctx, c.cache.B().Expire().Key(key).Seconds(int64(c.ttl/time.Second)).Build()) + } + return nil + }) + slog.Debug("revalidation of read complete", "duration", time.Since(startTime)) +} diff --git a/internal/filesystem/readdir.go b/internal/filesystem/readdir.go new file mode 100644 index 0000000..a9d0fc2 --- /dev/null +++ b/internal/filesystem/readdir.go @@ -0,0 +1,79 @@ +package filesystem + +import ( + "context" + "encoding/json" + "log/slog" + "os" + "strings" + "time" +) + +const keyReadDir = "webdav:readdir:" + +func (c *CachedClient) ReadDir(path string) ([]os.FileInfo, error) { + key := keyReadDir + path + ctx := context.Background() + + // Try cache + val, err := c.cache.Do(ctx, c.cache.B().Get().Key(key).Build()).ToString() + if err == nil && val != "" { + var cached []File + if err := json.Unmarshal([]byte(val), &cached); err == nil { + c.readDirHits.Add(1) + c.hits.Add(1) + slog.Debug("cache hit", "key", key) + infos := make([]os.FileInfo, len(cached)) + for i, f := range cached { + infos[i] = f + } + return infos, nil + } + } + + // Cache miss + c.misses.Add(1) + slog.Debug("cache miss", "key", key) + infos, err := c.impl.ReadDir(path) + if err != nil { + return nil, err + } + + // Serialize and cache + cached := make([]File, 0, len(infos)) + for _, info := range infos { + cached = append(cached, ParseToFile(info)) + } + + bytes, err := json.Marshal(cached) + if err == nil { + c.cache.Do(ctx, c.cache.B().Set().Key(key).Value(string(bytes)).Ex(c.ttl).Build()) + } + + return infos, nil +} + +func (c *CachedClient) revalidateReadDir(ctx context.Context) { + startTime := time.Now() + c.scanAndProcess(ctx, keyReadDir+"*", func(key string) error { + path := strings.TrimPrefix(key, keyReadDir) + infos, err := c.impl.ReadDir(path) + if err != nil { + c.cache.Do(ctx, c.cache.B().Del().Key(key).Build()) + return err + } + + // Serialize and cache + cached := make([]File, 0, len(infos)) + for _, info := range infos { + cached = append(cached, ParseToFile(info)) + } + + bytes, err := json.Marshal(cached) + if err == nil { + c.cache.Do(ctx, c.cache.B().Set().Key(key).Value(string(bytes)).Ex(c.ttl).Build()) + } + return nil + }) + slog.Debug("revalidation of readDir complete", "duration", time.Since(startTime)) +} diff --git a/internal/filesystem/stat.go b/internal/filesystem/stat.go new file mode 100644 index 0000000..05c3eba --- /dev/null +++ b/internal/filesystem/stat.go @@ -0,0 +1,67 @@ +package filesystem + +import ( + "context" + "encoding/json" + "log/slog" + "os" + "strings" + "time" +) + +func (c *CachedClient) Stat(path string) (info os.FileInfo, err error) { + key := keyStat + path + ctx := context.Background() + + // Try cache + val, err := c.cache.Do(ctx, c.cache.B().Get().Key(key).Build()).ToString() + if err == nil && val != "" { + var f File + if err := json.Unmarshal([]byte(val), &f); err == nil { + c.hits.Add(1) + slog.Debug("cache hit", "key", key) + + return f, nil + } + } + + // Cache miss + c.misses.Add(1) + slog.Debug("cache miss", "key", key) + fileInfo, err := c.impl.Stat(path) + if err != nil { + return + } + + // Serialize and cache + // Type assert to ensure we capture ContentType and Path + info = ParseToFile(fileInfo) + + bytes, err := json.Marshal(info) + if err == nil { + c.cache.Do(ctx, c.cache.B().Set().Key(key).Value(string(bytes)).Ex(c.ttl).Build()) + } + + return +} + +func (c *CachedClient) revalidateStat(ctx context.Context) { + startTime := time.Now() + c.scanAndProcess(ctx, keyStat+"*", func(key string) error { + path := strings.TrimPrefix(key, keyStat) + info, err := c.impl.Stat(path) + if err != nil { + c.cache.Do(ctx, c.cache.B().Del().Key(key).Build()) + return err + } + + // Serialize and cache + f := ParseToFile(info) + bytes, err := json.Marshal(f) + if err == nil { + c.cache.Do(ctx, c.cache.B().Set().Key(key).Value(string(bytes)).Ex(c.ttl).Build()) + } + return nil + }) + slog.Debug("revalidation of Stat complete", "duration", time.Since(startTime)) +} diff --git a/internal/handlers/resthome/controller.go b/internal/handlers/resthome/controller.go new file mode 100644 index 0000000..0c22bb2 --- /dev/null +++ b/internal/handlers/resthome/controller.go @@ -0,0 +1,30 @@ +package resthome + +import ( + "net/http" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web/layouts" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web/pages" +) + +func (h *Handler) home(w http.ResponseWriter, r *http.Request) { + pageHeaders, err := h.src.GetPages(r.Context()) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + layouts.Render(r.Context(), w, r, pages.Home(pageHeaders)) +} + +func (h *Handler) page(w http.ResponseWriter, r *http.Request) { + uid := r.PathValue("uid") + + page, err := h.src.GetPage(r.Context(), uid) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + layouts.Render(r.Context(), w, r, pages.ContentPage(page)) +} diff --git a/internal/handlers/resthome/resource.go b/internal/handlers/resthome/resource.go new file mode 100644 index 0000000..f1d0cb2 --- /dev/null +++ b/internal/handlers/resthome/resource.go @@ -0,0 +1,27 @@ +package resthome + +import ( + "context" + "net/http" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/page" +) + +type Handler struct { + src pageService +} + +func New(mux *http.ServeMux, srv pageService) *Handler { + h := &Handler{ + src: srv, + } + + mux.HandleFunc("GET /{$}", h.home) + mux.HandleFunc("GET /{uid}", h.page) + return h +} + +type pageService interface { + GetPages(ctx context.Context) ([]page.PageHeader, error) + GetPage(ctx context.Context, uid string) (page.Page, error) +} diff --git a/internal/handlers/restimage/conroller.go b/internal/handlers/restimage/conroller.go new file mode 100644 index 0000000..03645db --- /dev/null +++ b/internal/handlers/restimage/conroller.go @@ -0,0 +1,43 @@ +package restimage + +import ( + "io" + "log/slog" + "net/http" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/handlers/restutil" +) + +func (h *Handler) getImage(w http.ResponseWriter, r *http.Request) { + uid := r.PathValue("uid") + + var err error + options := images.Options{} + options.Height, err = restutil.IntParam(r, "h") + if err != nil { + restutil.SendErr(w, err) + return + } + options.Width, err = restutil.IntParam(r, "w") + if err != nil { + restutil.SendErr(w, err) + return + } + + options.Quality, err = restutil.IntParam(r, "q") + if err != nil { + restutil.SendErr(w, err) + return + } + + img, mime, err := h.img.GetImage(r.Context(), uid, options) + if err != nil { + slog.Error("error wile serving image", "err", err, "uid", uid) + w.WriteHeader(http.StatusInternalServerError) + return + } + + w.Header().Add("Content-Type", mime) + io.Copy(w, img) +} diff --git a/internal/handlers/restimage/resource.go b/internal/handlers/restimage/resource.go new file mode 100644 index 0000000..89f7b5f --- /dev/null +++ b/internal/handlers/restimage/resource.go @@ -0,0 +1,26 @@ +package restimage + +import ( + "context" + "io" + "net/http" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images" +) + +type Handler struct { + img imageService +} + +func New(mux *http.ServeMux, srv imageService) *Handler { + h := &Handler{ + img: srv, + } + + mux.HandleFunc("GET /images/{uid}", h.getImage) + return h +} + +type imageService interface { + GetImage(ctx context.Context, uid string, options images.Options) (img io.Reader, mimeType string, err error) +} diff --git a/internal/handlers/restutil/error.go b/internal/handlers/restutil/error.go new file mode 100644 index 0000000..d264e62 --- /dev/null +++ b/internal/handlers/restutil/error.go @@ -0,0 +1,68 @@ +package restutil + +import ( + "encoding/json" + "errors" + "fmt" + "log/slog" + "net/http" +) + +type ErrorType string + +const ( + ErrorTypeUndefinded = "" + ErrorTypeValidation = "VALIDATION" + ErrorTypeNotFound = "NOT_FOUND" + ErrorTypeServerError = "SERVER_ERROR" +) + +type Error struct { + Type ErrorType `json:"type"` + Message string `json:"message"` + err error +} + +func WrappErr(err error, errorType ErrorType, message string) *Error { + return &Error{ + Type: errorType, + Message: message, + err: err, + } +} + +func (e Error) Unwrap() error { + return e.err +} + +func (e Error) Error() string { + return fmt.Sprintf("%s: %s", e.Message, e.err.Error()) +} + +func (e Error) StatusCode() int { + switch e.Type { + case ErrorTypeValidation: + return http.StatusBadRequest + case ErrorTypeNotFound: + return http.StatusNotFound + default: + return http.StatusInternalServerError + } +} + +func SendErr(w http.ResponseWriter, err error) { + restErr := &Error{} + + if !errors.As(err, &restErr) { + slog.Error("internal server error", "err", err) + restErr = &Error{ + Type: ErrorTypeServerError, + } + } + + w.WriteHeader(restErr.StatusCode()) + w.Header().Add("Content-Type", "application/json") + err = json.NewEncoder(w).Encode(restErr) + + slog.Error("could not send error", "err", err) +} diff --git a/internal/handlers/restutil/params.go b/internal/handlers/restutil/params.go new file mode 100644 index 0000000..1bbf153 --- /dev/null +++ b/internal/handlers/restutil/params.go @@ -0,0 +1,24 @@ +package restutil + +import ( + "fmt" + "net/http" + "strconv" +) + +func IntParam(r *http.Request, key string) (val int, err error) { + str := r.URL.Query().Get(key) + if str == "" { + return + } + + val, err = strconv.Atoi(str) + if err != nil { + err = WrappErr( + err, + ErrorTypeValidation, + fmt.Sprintf("failed to parse query parameter '%s': not an int", key), + ) + } + return +} diff --git a/internal/server/routes.go b/internal/server/routes.go new file mode 100644 index 0000000..390f353 --- /dev/null +++ b/internal/server/routes.go @@ -0,0 +1,80 @@ +package server + +import ( + "log/slog" + "net/http" + "os" + "time" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/page" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/translate" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/filesystem" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/handlers/resthome" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/handlers/restimage" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/templer" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web" + "github.com/studio-b12/gowebdav" + "github.com/valkey-io/valkey-go" +) + +func (s *Server) RegisterRoutes() (h http.Handler) { + mux := http.NewServeMux() + + registerStatic(mux) + mux.Handle("/", registerOther()) + + h = mux + h = templer.Middleware(h) + h = s.loggingMiddleware(h) + return h +} + +func registerOther() (h http.Handler) { + mux := http.NewServeMux() + + webdavClient := gowebdav.NewClient("https://cloud.schreifuchs.ch/remote.php/dav/files/test/website", "test", os.Getenv("TEST_PW")) + if err := webdavClient.Connect(); err != nil { + slog.Error("could not connect webdavClient", "err", err, "pw", os.Getenv("TEST_PW")) + } + + var fs filesystem.FS = webdavClient + + valkeyAddr := os.Getenv("VALKEY_ADDR") + if valkeyAddr == "" { + valkeyAddr = "127.0.0.1:6379" + } + valkeyClient, err := valkey.NewClient(valkey.ClientOption{ + InitAddress: []string{valkeyAddr}, + Password: os.Getenv("VALKEY_PASSWORD"), + }) + if err != nil { + slog.Error("failed to create valkey client", "err", err) + } else { + fs = filesystem.NewCachedClient(webdavClient, valkeyClient, 5*time.Hour) + } + + _ = resthome.New(mux, page.New(fs)) + _ = restimage.New(mux, images.New(fs, valkeyClient)) + + mux.Handle("/", http.FileServer(http.FS(web.GetStaticFS()))) + + translator := translate.New() + + h = mux + h = translator.Middleware(h) + h = cacheMiddleware(time.Second * 45)(h) + return h +} + +func (s *Server) loggingMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + next.ServeHTTP(w, r) + slog.Info("request", + "method", r.Method, + "path", r.URL.Path, + "duration", time.Since(start), + ) + }) +} diff --git a/internal/server/server.go b/internal/server/server.go new file mode 100644 index 0000000..b2db09b --- /dev/null +++ b/internal/server/server.go @@ -0,0 +1,34 @@ +package server + +import ( + "fmt" + "net/http" + "os" + "strconv" + "time" +) + +type Server struct { + port int +} + +func NewServer() *http.Server { + port, _ := strconv.Atoi(os.Getenv("PORT")) + if port == 0 { + port = 8080 + } + s := &Server{ + port: port, + } + + // Declare Server config + server := &http.Server{ + Addr: fmt.Sprintf(":%d", s.port), + Handler: s.RegisterRoutes(), + IdleTimeout: time.Minute, + ReadTimeout: 10 * time.Second, + WriteTimeout: 30 * time.Second, + } + + return server +} diff --git a/internal/server/static.go b/internal/server/static.go new file mode 100644 index 0000000..e9b48db --- /dev/null +++ b/internal/server/static.go @@ -0,0 +1,51 @@ +package server + +import ( + "fmt" + "io/fs" + "log/slog" + "net/http" + "time" + + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web" +) + +// registerStatic registers all the static files. +func registerStatic(mux *http.ServeMux) { + fileSystem := web.GetStaticFS() + + // we still use go's fileServer to avoid unnecessary implementation + fileServer := cacheMiddleware(time.Hour * 24)(http.FileServer(http.FS(fileSystem))) + + err := fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() { + return nil + } + + path = "/" + path + + slog.Info("registering file", "path", path) + + mux.Handle(path, fileServer) + + return nil + }) + if err != nil { + slog.Error("could not register static files", "err", err) + panic(err) + } +} + +// cacheMiddleware adds Cache-Control headers to the response. +func cacheMiddleware(maxAge time.Duration) func(next http.Handler) http.Handler { + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%.0f", maxAge.Seconds())) + w.Header().Set("Vary", "HX-Request,Accept-Language,Accept-Encoding") + next.ServeHTTP(w, r) + }) + } +} diff --git a/internal/templer/middleware.go b/internal/templer/middleware.go new file mode 100644 index 0000000..22d429f --- /dev/null +++ b/internal/templer/middleware.go @@ -0,0 +1,34 @@ +package templer + +import ( + "context" + "log/slog" + "net/http" + "strings" +) + +type ctxKey int + +const ( + pathKey ctxKey = iota +) + +func Middleware(next http.Handler) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + ctx = context.WithValue(ctx, pathKey, r.URL.Path) + + next.ServeHTTP(w, r.WithContext(ctx)) + } +} + +// Path returns the current path without a leading slash +func Path(ctx context.Context) string { + path, ok := ctx.Value(pathKey).(string) + if !ok { + slog.Error("could not extract request path from context") + return "" + } + return strings.TrimPrefix(path, "/") +} diff --git a/messages/de.json b/messages/de.json deleted file mode 100644 index 9759149..0000000 --- a/messages/de.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://inlang.com/schema/message-format-plugin", - "hello_world": "Hallo Welt", - "pfadi": "Pfadi", - "site_title": "Schreifuchs.ch", - "site_description": "Portfolio von Schreifuchs - Fotografie, Informatik und Musik." -} - diff --git a/messages/en.json b/messages/en.json deleted file mode 100644 index a769a1b..0000000 --- a/messages/en.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://inlang.com/schema/message-format-plugin", - "hello_world": "Hello World", - "pfadi": "Scouts", - "site_title": "Schreifuchs.ch", - "site_description": "Portfolio of Schreifuchs - Photography, Informatics and Music ." -} - diff --git a/package.json b/package.json index 432f744..8d62f79 100644 --- a/package.json +++ b/package.json @@ -1,38 +1,25 @@ { - "name": "schreifuchs", - "version": "0.0.1", - "private": true, - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.5.1", - "@sveltejs/kit": "^2.5.27", - "@sveltejs/vite-plugin-svelte": "^4.0.0", - "@types/mime-types": "^3.0.1", - "@types/node": "^25.0.9", - "autoprefixer": "^10.4.19", - "postcss": "^8.4.38", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "tailwindcss": "^3.4.3", - "typescript": "^5.5.0", - "vite": "^5.4.4" - }, - "type": "module", - "dependencies": { - "@fontsource/outfit": "^5.0.13", - "@inlang/paraglide-js": "^1.11.0", - "@inlang/paraglide-sveltekit": "^0.16.1", - "@ts-stack/markdown": "^1.5.0", - "lru-cache": "^11.2.4", - "mime-types": "^3.0.2", - "svelte-preprocess": "^6.0.2", - "webdav": "^5.8.0" - } + "name": "schreifuchs.ch", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build:css": "tailwindcss -i ./web/static/css/input.css -o ./web/static/css/output.css --minify", + "watch:css": "tailwindcss -i ./web/static/css/input.css -o ./web/static/css/output.css --watch", + "build:js": "cp node_modules/htmx.org/dist/htmx.min.js web/static/js/htmx.min.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "packageManager": "pnpm@10.28.2", + "devDependencies": { + "@tailwindcss/cli": "^4.1.18", + "@tailwindcss/typography": "^0.5.19", + "autoprefixer": "^10.4.24", + "postcss": "^8.5.6", + "tailwindcss": "^4.1.18" + }, + "dependencies": { + "htmx.org": "^2.0.8" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2742813..d535497 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,7 @@ importers: .: dependencies: +<<<<<<< HEAD '@fontsource/outfit': specifier: ^5.0.13 version: 5.0.13 @@ -326,6 +327,32 @@ packages: '@jridgewell/gen-mapping@0.3.5': resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} engines: {node: '>=6.0.0'} +======= + htmx.org: + specifier: ^2.0.8 + version: 2.0.8 + devDependencies: + '@tailwindcss/cli': + specifier: ^4.1.18 + version: 4.1.18 + '@tailwindcss/typography': + specifier: ^0.5.19 + version: 0.5.19(tailwindcss@4.1.18) + autoprefixer: + specifier: ^10.4.24 + version: 10.4.24(postcss@8.5.6) + postcss: + specifier: ^8.5.6 + version: 8.5.6 + tailwindcss: + specifier: ^4.1.18 + version: 4.1.18 + +packages: + + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} +>>>>>>> cbc2a1a (feat: translation middleware) '@jridgewell/remapping@2.3.5': resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} @@ -334,6 +361,7 @@ packages: resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} +<<<<<<< HEAD '@jridgewell/set-array@1.2.1': resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} engines: {node: '>=6.0.0'} @@ -790,11 +818,208 @@ packages: autoprefixer@10.4.19: resolution: {integrity: sha512-BaENR2+zBZ8xXhM4pUaKUxlVdxZ0EZhjvbopwnXmxRUfqDmwSpC2lAi/QXvx7NRdPCo1WKEcEF6mV64si1z4Ew==} +======= + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@parcel/watcher-android-arm64@2.5.6': + resolution: {integrity: sha512-YQxSS34tPF/6ZG7r/Ih9xy+kP/WwediEUsqmtf0cuCV5TPPKw/PQHRhueUo6JdeFJaqV3pyjm0GdYjZotbRt/A==} + engines: {node: '>= 10.0.0'} + cpu: [arm64] + os: [android] + + '@parcel/watcher-darwin-arm64@2.5.6': + resolution: {integrity: sha512-Z2ZdrnwyXvvvdtRHLmM4knydIdU9adO3D4n/0cVipF3rRiwP+3/sfzpAwA/qKFL6i1ModaabkU7IbpeMBgiVEA==} + engines: {node: '>= 10.0.0'} + cpu: [arm64] + os: [darwin] + + '@parcel/watcher-darwin-x64@2.5.6': + resolution: {integrity: sha512-HgvOf3W9dhithcwOWX9uDZyn1lW9R+7tPZ4sug+NGrGIo4Rk1hAXLEbcH1TQSqxts0NYXXlOWqVpvS1SFS4fRg==} + engines: {node: '>= 10.0.0'} + cpu: [x64] + os: [darwin] + + '@parcel/watcher-freebsd-x64@2.5.6': + resolution: {integrity: sha512-vJVi8yd/qzJxEKHkeemh7w3YAn6RJCtYlE4HPMoVnCpIXEzSrxErBW5SJBgKLbXU3WdIpkjBTeUNtyBVn8TRng==} + engines: {node: '>= 10.0.0'} + cpu: [x64] + os: [freebsd] + + '@parcel/watcher-linux-arm-glibc@2.5.6': + resolution: {integrity: sha512-9JiYfB6h6BgV50CCfasfLf/uvOcJskMSwcdH1PHH9rvS1IrNy8zad6IUVPVUfmXr+u+Km9IxcfMLzgdOudz9EQ==} + engines: {node: '>= 10.0.0'} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@parcel/watcher-linux-arm-musl@2.5.6': + resolution: {integrity: sha512-Ve3gUCG57nuUUSyjBq/MAM0CzArtuIOxsBdQ+ftz6ho8n7s1i9E1Nmk/xmP323r2YL0SONs1EuwqBp2u1k5fxg==} + engines: {node: '>= 10.0.0'} + cpu: [arm] + os: [linux] + libc: [musl] + + '@parcel/watcher-linux-arm64-glibc@2.5.6': + resolution: {integrity: sha512-f2g/DT3NhGPdBmMWYoxixqYr3v/UXcmLOYy16Bx0TM20Tchduwr4EaCbmxh1321TABqPGDpS8D/ggOTaljijOA==} + engines: {node: '>= 10.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@parcel/watcher-linux-arm64-musl@2.5.6': + resolution: {integrity: sha512-qb6naMDGlbCwdhLj6hgoVKJl2odL34z2sqkC7Z6kzir8b5W65WYDpLB6R06KabvZdgoHI/zxke4b3zR0wAbDTA==} + engines: {node: '>= 10.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@parcel/watcher-linux-x64-glibc@2.5.6': + resolution: {integrity: sha512-kbT5wvNQlx7NaGjzPFu8nVIW1rWqV780O7ZtkjuWaPUgpv2NMFpjYERVi0UYj1msZNyCzGlaCWEtzc+exjMGbQ==} + engines: {node: '>= 10.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@parcel/watcher-linux-x64-musl@2.5.6': + resolution: {integrity: sha512-1JRFeC+h7RdXwldHzTsmdtYR/Ku8SylLgTU/reMuqdVD7CtLwf0VR1FqeprZ0eHQkO0vqsbvFLXUmYm/uNKJBg==} + engines: {node: '>= 10.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@parcel/watcher-win32-arm64@2.5.6': + resolution: {integrity: sha512-3ukyebjc6eGlw9yRt678DxVF7rjXatWiHvTXqphZLvo7aC5NdEgFufVwjFfY51ijYEWpXbqF5jtrK275z52D4Q==} + engines: {node: '>= 10.0.0'} + cpu: [arm64] + os: [win32] + + '@parcel/watcher-win32-ia32@2.5.6': + resolution: {integrity: sha512-k35yLp1ZMwwee3Ez/pxBi5cf4AoBKYXj00CZ80jUz5h8prpiaQsiRPKQMxoLstNuqe2vR4RNPEAEcjEFzhEz/g==} + engines: {node: '>= 10.0.0'} + cpu: [ia32] + os: [win32] + + '@parcel/watcher-win32-x64@2.5.6': + resolution: {integrity: sha512-hbQlYcCq5dlAX9Qx+kFb0FHue6vbjlf0FrNzSKdYK2APUf7tGfGxQCk2ihEREmbR6ZMc0MVAD5RIX/41gpUzTw==} + engines: {node: '>= 10.0.0'} + cpu: [x64] + os: [win32] + + '@parcel/watcher@2.5.6': + resolution: {integrity: sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==} + engines: {node: '>= 10.0.0'} + + '@tailwindcss/cli@4.1.18': + resolution: {integrity: sha512-sMZ+lZbDyxwjD2E0L7oRUjJ01Ffjtme5OtjvvnC+cV4CEDcbqzbp25TCpxHj6kWLU9+DlqJOiNgSOgctC2aZmg==} + hasBin: true + + '@tailwindcss/node@4.1.18': + resolution: {integrity: sha512-DoR7U1P7iYhw16qJ49fgXUlry1t4CpXeErJHnQ44JgTSKMaZUdf17cfn5mHchfJ4KRBZRFA/Coo+MUF5+gOaCQ==} + + '@tailwindcss/oxide-android-arm64@4.1.18': + resolution: {integrity: sha512-dJHz7+Ugr9U/diKJA0W6N/6/cjI+ZTAoxPf9Iz9BFRF2GzEX8IvXxFIi/dZBloVJX/MZGvRuFA9rqwdiIEZQ0Q==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [android] + + '@tailwindcss/oxide-darwin-arm64@4.1.18': + resolution: {integrity: sha512-Gc2q4Qhs660bhjyBSKgq6BYvwDz4G+BuyJ5H1xfhmDR3D8HnHCmT/BSkvSL0vQLy/nkMLY20PQ2OoYMO15Jd0A==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@tailwindcss/oxide-darwin-x64@4.1.18': + resolution: {integrity: sha512-FL5oxr2xQsFrc3X9o1fjHKBYBMD1QZNyc1Xzw/h5Qu4XnEBi3dZn96HcHm41c/euGV+GRiXFfh2hUCyKi/e+yw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@tailwindcss/oxide-freebsd-x64@4.1.18': + resolution: {integrity: sha512-Fj+RHgu5bDodmV1dM9yAxlfJwkkWvLiRjbhuO2LEtwtlYlBgiAT4x/j5wQr1tC3SANAgD+0YcmWVrj8R9trVMA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [freebsd] + + '@tailwindcss/oxide-linux-arm-gnueabihf@4.1.18': + resolution: {integrity: sha512-Fp+Wzk/Ws4dZn+LV2Nqx3IilnhH51YZoRaYHQsVq3RQvEl+71VGKFpkfHrLM/Li+kt5c0DJe/bHXK1eHgDmdiA==} + engines: {node: '>= 10'} + cpu: [arm] + os: [linux] + + '@tailwindcss/oxide-linux-arm64-gnu@4.1.18': + resolution: {integrity: sha512-S0n3jboLysNbh55Vrt7pk9wgpyTTPD0fdQeh7wQfMqLPM/Hrxi+dVsLsPrycQjGKEQk85Kgbx+6+QnYNiHalnw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@tailwindcss/oxide-linux-arm64-musl@4.1.18': + resolution: {integrity: sha512-1px92582HkPQlaaCkdRcio71p8bc8i/ap5807tPRDK/uw953cauQBT8c5tVGkOwrHMfc2Yh6UuxaH4vtTjGvHg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@tailwindcss/oxide-linux-x64-gnu@4.1.18': + resolution: {integrity: sha512-v3gyT0ivkfBLoZGF9LyHmts0Isc8jHZyVcbzio6Wpzifg/+5ZJpDiRiUhDLkcr7f/r38SWNe7ucxmGW3j3Kb/g==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@tailwindcss/oxide-linux-x64-musl@4.1.18': + resolution: {integrity: sha512-bhJ2y2OQNlcRwwgOAGMY0xTFStt4/wyU6pvI6LSuZpRgKQwxTec0/3Scu91O8ir7qCR3AuepQKLU/kX99FouqQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@tailwindcss/oxide-wasm32-wasi@4.1.18': + resolution: {integrity: sha512-LffYTvPjODiP6PT16oNeUQJzNVyJl1cjIebq/rWWBF+3eDst5JGEFSc5cWxyRCJ0Mxl+KyIkqRxk1XPEs9x8TA==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + bundledDependencies: + - '@napi-rs/wasm-runtime' + - '@emnapi/core' + - '@emnapi/runtime' + - '@tybys/wasm-util' + - '@emnapi/wasi-threads' + - tslib + + '@tailwindcss/oxide-win32-arm64-msvc@4.1.18': + resolution: {integrity: sha512-HjSA7mr9HmC8fu6bdsZvZ+dhjyGCLdotjVOgLA2vEqxEBZaQo9YTX4kwgEvPCpRh8o4uWc4J/wEoFzhEmjvPbA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@tailwindcss/oxide-win32-x64-msvc@4.1.18': + resolution: {integrity: sha512-bJWbyYpUlqamC8dpR7pfjA0I7vdF6t5VpUGMWRkXVE3AXgIZjYUYAK7II1GNaxR8J1SSrSrppRar8G++JekE3Q==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@tailwindcss/oxide@4.1.18': + resolution: {integrity: sha512-EgCR5tTS5bUSKQgzeMClT6iCY3ToqE1y+ZB0AKldj809QXk1Y+3jB0upOYZrn9aGIzPtUsP7sX4QQ4XtjBB95A==} + engines: {node: '>= 10'} + + '@tailwindcss/typography@0.5.19': + resolution: {integrity: sha512-w31dd8HOx3k9vPtcQh5QHP9GwKcgbMp87j58qi6xgiBnFFtKEAgCWnDw4qUT8aHwkCp8bKvb/KGKWWHedP0AAg==} + peerDependencies: + tailwindcss: '>=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1' + + autoprefixer@10.4.24: + resolution: {integrity: sha512-uHZg7N9ULTVbutaIsDRoUkoS8/h3bdsmVJYZ5l3wv8Cp/6UIIoRDm90hZ+BwxUj/hGBEzLxdHNSKuFpn8WOyZw==} +>>>>>>> cbc2a1a (feat: translation middleware) engines: {node: ^10 || ^12 || >=14} hasBin: true peerDependencies: postcss: ^8.1.0 +<<<<<<< HEAD axios@1.13.2: resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==} @@ -1170,19 +1395,65 @@ packages: is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} +======= + baseline-browser-mapping@2.9.19: + resolution: {integrity: sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==} + hasBin: true + + browserslist@4.28.1: + resolution: {integrity: sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + + caniuse-lite@1.0.30001769: + resolution: {integrity: sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==} + + cssesc@3.0.0: + resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} + engines: {node: '>=4'} + hasBin: true + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + electron-to-chromium@1.5.286: + resolution: {integrity: sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A==} + + enhanced-resolve@5.19.0: + resolution: {integrity: sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==} + engines: {node: '>=10.13.0'} + + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} + + fraction.js@5.3.4: + resolution: {integrity: sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==} + + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + htmx.org@2.0.8: + resolution: {integrity: sha512-fm297iru0iWsNJlBrjvtN7V9zjaxd+69Oqjh4F/Vq9Wwi2kFisLcrLCiv5oBX0KLfOX/zG8AUo9ROMU5XUB44Q==} +>>>>>>> cbc2a1a (feat: translation middleware) is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} +<<<<<<< HEAD is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} +======= +>>>>>>> cbc2a1a (feat: translation middleware) is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} +<<<<<<< HEAD is-module@1.0.0: resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} @@ -1278,10 +1549,90 @@ packages: magic-string@0.30.10: resolution: {integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==} +======= + jiti@2.6.1: + resolution: {integrity: sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==} + hasBin: true + + lightningcss-android-arm64@1.30.2: + resolution: {integrity: sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.30.2: + resolution: {integrity: sha512-ylTcDJBN3Hp21TdhRT5zBOIi73P6/W0qwvlFEk22fkdXchtNTOU4Qc37SkzV+EKYxLouZ6M4LG9NfZ1qkhhBWA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.30.2: + resolution: {integrity: sha512-oBZgKchomuDYxr7ilwLcyms6BCyLn0z8J0+ZZmfpjwg9fRVZIR5/GMXd7r9RH94iDhld3UmSjBM6nXWM2TfZTQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.30.2: + resolution: {integrity: sha512-c2bH6xTrf4BDpK8MoGG4Bd6zAMZDAXS569UxCAGcA7IKbHNMlhGQ89eRmvpIUGfKWNVdbhSbkQaWhEoMGmGslA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.30.2: + resolution: {integrity: sha512-eVdpxh4wYcm0PofJIZVuYuLiqBIakQ9uFZmipf6LF/HRj5Bgm0eb3qL/mr1smyXIS1twwOxNWndd8z0E374hiA==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.30.2: + resolution: {integrity: sha512-UK65WJAbwIJbiBFXpxrbTNArtfuznvxAJw4Q2ZGlU8kPeDIWEX1dg3rn2veBVUylA2Ezg89ktszWbaQnxD/e3A==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.30.2: + resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.30.2: + resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.30.2: + resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.30.2: + resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.30.2: + resolution: {integrity: sha512-5g1yc73p+iAkid5phb4oVFMB45417DkRevRbt/El/gKXJk4jid+vPFF/AXbxn05Aky8PapwzZrdJShv5C0avjw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.30.2: + resolution: {integrity: sha512-utfs7Pr5uJyyvDETitgsaqSyjCb2qNRAtuqUeWIAKztsOYdcACf2KtARYXg2pSvhkt+9NfoaNY7fxjl6nuMjIQ==} + engines: {node: '>= 12.0.0'} +>>>>>>> cbc2a1a (feat: translation middleware) magic-string@0.30.21: resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} +<<<<<<< HEAD math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -1325,10 +1676,13 @@ packages: resolution: {integrity: sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==} engines: {node: '>=16 || 14 >=14.17'} +======= +>>>>>>> cbc2a1a (feat: translation middleware) mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} +<<<<<<< HEAD mrmime@2.0.0: resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} engines: {node: '>=10'} @@ -1343,11 +1697,14 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} +======= +>>>>>>> cbc2a1a (feat: translation middleware) nanoid@3.3.11: resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true +<<<<<<< HEAD nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -1410,18 +1767,30 @@ packages: picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} +======= + node-addon-api@7.1.1: + resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} + + node-releases@2.0.27: + resolution: {integrity: sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==} +>>>>>>> cbc2a1a (feat: translation middleware) picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} +<<<<<<< HEAD picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} +======= +>>>>>>> cbc2a1a (feat: translation middleware) picomatch@4.0.3: resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} +<<<<<<< HEAD +<<<<<<< HEAD pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} @@ -1466,6 +1835,10 @@ packages: postcss-selector-parser@6.0.16: resolution: {integrity: sha512-A0RVJrX+IUkVZbW3ClroRWurercFhieevHB38sr2+l9eUClMqome3LmEmnhlNy+5Mr2EYN6B2Kaw9wYdd+VHiw==} +======= + postcss-selector-parser@6.0.10: + resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==} +>>>>>>> 6c4b219 (feat: dummy pages) engines: {node: '>=4'} postcss-value-parser@4.2.0: @@ -1475,10 +1848,16 @@ packages: resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} engines: {node: ^10 || ^12 || >=14} +======= + postcss-value-parser@4.2.0: + resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==} + +>>>>>>> cbc2a1a (feat: translation middleware) postcss@8.5.6: resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} +<<<<<<< HEAD posthog-node@3.1.3: resolution: {integrity: sha512-UaOOoWEUYTcaaDe1w0fgHW/sXvFr3RO0l7yI7RUDzkZNZCfwXNO9r3pc14d1EtNppF/SHBrV5hNiZZATpf/vUw==} engines: {node: '>=15.0.0'} @@ -1571,10 +1950,13 @@ packages: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} +======= +>>>>>>> cbc2a1a (feat: translation middleware) source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} +<<<<<<< HEAD string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -1707,10 +2089,23 @@ packages: update-browserslist-db@1.0.15: resolution: {integrity: sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==} +======= + tailwindcss@4.1.18: + resolution: {integrity: sha512-4+Z+0yiYyEtUVCScyfHCxOYP06L5Ne+JiHhY2IjR2KWMIWhJOYZKLSGZaP5HkZ8+bY0cxfzwDE5uOmzFXyIwxw==} + + tapable@2.3.0: + resolution: {integrity: sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==} + engines: {node: '>=6'} + + update-browserslist-db@1.2.3: + resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} +>>>>>>> cbc2a1a (feat: translation middleware) hasBin: true peerDependencies: browserslist: '>= 4.21.0' +<<<<<<< HEAD +<<<<<<< HEAD url-join@5.0.0: resolution: {integrity: sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2911,10 +3306,217 @@ snapshots: is-fullwidth-code-point@3.0.0: {} +======= +======= + util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + +>>>>>>> 6c4b219 (feat: dummy pages) +snapshots: + + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/remapping@2.3.5': + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/sourcemap-codec@1.5.5': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.5 + + '@parcel/watcher-android-arm64@2.5.6': + optional: true + + '@parcel/watcher-darwin-arm64@2.5.6': + optional: true + + '@parcel/watcher-darwin-x64@2.5.6': + optional: true + + '@parcel/watcher-freebsd-x64@2.5.6': + optional: true + + '@parcel/watcher-linux-arm-glibc@2.5.6': + optional: true + + '@parcel/watcher-linux-arm-musl@2.5.6': + optional: true + + '@parcel/watcher-linux-arm64-glibc@2.5.6': + optional: true + + '@parcel/watcher-linux-arm64-musl@2.5.6': + optional: true + + '@parcel/watcher-linux-x64-glibc@2.5.6': + optional: true + + '@parcel/watcher-linux-x64-musl@2.5.6': + optional: true + + '@parcel/watcher-win32-arm64@2.5.6': + optional: true + + '@parcel/watcher-win32-ia32@2.5.6': + optional: true + + '@parcel/watcher-win32-x64@2.5.6': + optional: true + + '@parcel/watcher@2.5.6': + dependencies: + detect-libc: 2.1.2 + is-glob: 4.0.3 + node-addon-api: 7.1.1 + picomatch: 4.0.3 + optionalDependencies: + '@parcel/watcher-android-arm64': 2.5.6 + '@parcel/watcher-darwin-arm64': 2.5.6 + '@parcel/watcher-darwin-x64': 2.5.6 + '@parcel/watcher-freebsd-x64': 2.5.6 + '@parcel/watcher-linux-arm-glibc': 2.5.6 + '@parcel/watcher-linux-arm-musl': 2.5.6 + '@parcel/watcher-linux-arm64-glibc': 2.5.6 + '@parcel/watcher-linux-arm64-musl': 2.5.6 + '@parcel/watcher-linux-x64-glibc': 2.5.6 + '@parcel/watcher-linux-x64-musl': 2.5.6 + '@parcel/watcher-win32-arm64': 2.5.6 + '@parcel/watcher-win32-ia32': 2.5.6 + '@parcel/watcher-win32-x64': 2.5.6 + + '@tailwindcss/cli@4.1.18': + dependencies: + '@parcel/watcher': 2.5.6 + '@tailwindcss/node': 4.1.18 + '@tailwindcss/oxide': 4.1.18 + enhanced-resolve: 5.19.0 + mri: 1.2.0 + picocolors: 1.1.1 + tailwindcss: 4.1.18 + + '@tailwindcss/node@4.1.18': + dependencies: + '@jridgewell/remapping': 2.3.5 + enhanced-resolve: 5.19.0 + jiti: 2.6.1 + lightningcss: 1.30.2 + magic-string: 0.30.21 + source-map-js: 1.2.1 + tailwindcss: 4.1.18 + + '@tailwindcss/oxide-android-arm64@4.1.18': + optional: true + + '@tailwindcss/oxide-darwin-arm64@4.1.18': + optional: true + + '@tailwindcss/oxide-darwin-x64@4.1.18': + optional: true + + '@tailwindcss/oxide-freebsd-x64@4.1.18': + optional: true + + '@tailwindcss/oxide-linux-arm-gnueabihf@4.1.18': + optional: true + + '@tailwindcss/oxide-linux-arm64-gnu@4.1.18': + optional: true + + '@tailwindcss/oxide-linux-arm64-musl@4.1.18': + optional: true + + '@tailwindcss/oxide-linux-x64-gnu@4.1.18': + optional: true + + '@tailwindcss/oxide-linux-x64-musl@4.1.18': + optional: true + + '@tailwindcss/oxide-wasm32-wasi@4.1.18': + optional: true + + '@tailwindcss/oxide-win32-arm64-msvc@4.1.18': + optional: true + + '@tailwindcss/oxide-win32-x64-msvc@4.1.18': + optional: true + + '@tailwindcss/oxide@4.1.18': + optionalDependencies: + '@tailwindcss/oxide-android-arm64': 4.1.18 + '@tailwindcss/oxide-darwin-arm64': 4.1.18 + '@tailwindcss/oxide-darwin-x64': 4.1.18 + '@tailwindcss/oxide-freebsd-x64': 4.1.18 + '@tailwindcss/oxide-linux-arm-gnueabihf': 4.1.18 + '@tailwindcss/oxide-linux-arm64-gnu': 4.1.18 + '@tailwindcss/oxide-linux-arm64-musl': 4.1.18 + '@tailwindcss/oxide-linux-x64-gnu': 4.1.18 + '@tailwindcss/oxide-linux-x64-musl': 4.1.18 + '@tailwindcss/oxide-wasm32-wasi': 4.1.18 + '@tailwindcss/oxide-win32-arm64-msvc': 4.1.18 + '@tailwindcss/oxide-win32-x64-msvc': 4.1.18 + + '@tailwindcss/typography@0.5.19(tailwindcss@4.1.18)': + dependencies: + postcss-selector-parser: 6.0.10 + tailwindcss: 4.1.18 + + autoprefixer@10.4.24(postcss@8.5.6): + dependencies: + browserslist: 4.28.1 + caniuse-lite: 1.0.30001769 + fraction.js: 5.3.4 + picocolors: 1.1.1 + postcss: 8.5.6 + postcss-value-parser: 4.2.0 + + baseline-browser-mapping@2.9.19: {} + + browserslist@4.28.1: + dependencies: + baseline-browser-mapping: 2.9.19 + caniuse-lite: 1.0.30001769 + electron-to-chromium: 1.5.286 + node-releases: 2.0.27 + update-browserslist-db: 1.2.3(browserslist@4.28.1) + + caniuse-lite@1.0.30001769: {} + + cssesc@3.0.0: {} + + detect-libc@2.1.2: {} + + electron-to-chromium@1.5.286: {} + + enhanced-resolve@5.19.0: + dependencies: + graceful-fs: 4.2.11 + tapable: 2.3.0 + + escalade@3.2.0: {} + + fraction.js@5.3.4: {} + + graceful-fs@4.2.11: {} + + htmx.org@2.0.8: {} + + is-extglob@2.1.1: {} + +>>>>>>> cbc2a1a (feat: translation middleware) is-glob@4.0.3: dependencies: is-extglob: 2.1.1 +<<<<<<< HEAD is-module@1.0.0: {} is-number@7.0.0: {} @@ -3000,11 +3602,64 @@ snapshots: magic-string@0.30.10: dependencies: '@jridgewell/sourcemap-codec': 1.4.15 +======= + jiti@2.6.1: {} + + lightningcss-android-arm64@1.30.2: + optional: true + + lightningcss-darwin-arm64@1.30.2: + optional: true + + lightningcss-darwin-x64@1.30.2: + optional: true + + lightningcss-freebsd-x64@1.30.2: + optional: true + + lightningcss-linux-arm-gnueabihf@1.30.2: + optional: true + + lightningcss-linux-arm64-gnu@1.30.2: + optional: true + + lightningcss-linux-arm64-musl@1.30.2: + optional: true + + lightningcss-linux-x64-gnu@1.30.2: + optional: true + + lightningcss-linux-x64-musl@1.30.2: + optional: true + + lightningcss-win32-arm64-msvc@1.30.2: + optional: true + + lightningcss-win32-x64-msvc@1.30.2: + optional: true + + lightningcss@1.30.2: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.30.2 + lightningcss-darwin-arm64: 1.30.2 + lightningcss-darwin-x64: 1.30.2 + lightningcss-freebsd-x64: 1.30.2 + lightningcss-linux-arm-gnueabihf: 1.30.2 + lightningcss-linux-arm64-gnu: 1.30.2 + lightningcss-linux-arm64-musl: 1.30.2 + lightningcss-linux-x64-gnu: 1.30.2 + lightningcss-linux-x64-musl: 1.30.2 + lightningcss-win32-arm64-msvc: 1.30.2 + lightningcss-win32-x64-msvc: 1.30.2 +>>>>>>> cbc2a1a (feat: translation middleware) magic-string@0.30.21: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 +<<<<<<< HEAD math-intrinsics@1.1.0: {} md5@2.3.0: @@ -3161,12 +3816,34 @@ snapshots: picocolors: 1.0.0 source-map-js: 1.2.0 +======= + mri@1.2.0: {} + + nanoid@3.3.11: {} + + node-addon-api@7.1.1: {} + + node-releases@2.0.27: {} + + picocolors@1.1.1: {} + + picomatch@4.0.3: {} + + postcss-selector-parser@6.0.10: + dependencies: + cssesc: 3.0.0 + util-deprecate: 1.0.2 + + postcss-value-parser@4.2.0: {} + +>>>>>>> cbc2a1a (feat: translation middleware) postcss@8.5.6: dependencies: nanoid: 3.3.11 picocolors: 1.1.1 source-map-js: 1.2.1 +<<<<<<< HEAD posthog-node@3.1.3: dependencies: axios: 1.13.2 @@ -3487,3 +4164,21 @@ snapshots: yaml@2.4.2: {} zimmerframe@1.1.4: {} +======= + source-map-js@1.2.1: {} + + tailwindcss@4.1.18: {} + + tapable@2.3.0: {} + + update-browserslist-db@1.2.3(browserslist@4.28.1): + dependencies: + browserslist: 4.28.1 + escalade: 3.2.0 + picocolors: 1.1.1 +<<<<<<< HEAD +>>>>>>> cbc2a1a (feat: translation middleware) +======= + + util-deprecate@1.0.2: {} +>>>>>>> 6c4b219 (feat: dummy pages) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml deleted file mode 100644 index efc037a..0000000 --- a/pnpm-workspace.yaml +++ /dev/null @@ -1,2 +0,0 @@ -onlyBuiltDependencies: - - esbuild diff --git a/postcss.config.js b/postcss.config.js deleted file mode 100644 index 2e7af2b..0000000 --- a/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -} diff --git a/project.inlang/.gitignore b/project.inlang/.gitignore deleted file mode 100644 index 5e46596..0000000 --- a/project.inlang/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cache \ No newline at end of file diff --git a/project.inlang/project_id b/project.inlang/project_id deleted file mode 100644 index 136ed81..0000000 --- a/project.inlang/project_id +++ /dev/null @@ -1 +0,0 @@ -aa922b989658d017b7a6296093cef3dac23a39ddc1afa6cf7ea24c049a284b56 \ No newline at end of file diff --git a/project.inlang/settings.json b/project.inlang/settings.json deleted file mode 100644 index dcca6d2..0000000 --- a/project.inlang/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "https://inlang.com/schema/project-settings", - "telemetry": "off", - "sourceLanguageTag": "de", - "languageTags": ["de", "en"], - "modules": [ - "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js" - ], - "plugin.inlang.messageFormat": { - "pathPattern": "./messages/{languageTag}.json" - } -} - diff --git a/src/app.css b/src/app.css deleted file mode 100644 index 909c436..0000000 --- a/src/app.css +++ /dev/null @@ -1,5 +0,0 @@ -@import "@fontsource/outfit"; - -@tailwind base; -@tailwind components; -@tailwind utilities; diff --git a/src/app.d.ts b/src/app.d.ts deleted file mode 100644 index 743f07b..0000000 --- a/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/src/app.html b/src/app.html deleted file mode 100644 index 6c747a3..0000000 --- a/src/app.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - schreifuchs.ch - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/src/hooks.server.ts b/src/hooks.server.ts deleted file mode 100644 index bd99bae..0000000 --- a/src/hooks.server.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { i18n } from "$lib/i18n" - -export const handle = i18n.handle() \ No newline at end of file diff --git a/src/lib/components/ImageLinkTile.svelte b/src/lib/components/ImageLinkTile.svelte deleted file mode 100644 index c917f15..0000000 --- a/src/lib/components/ImageLinkTile.svelte +++ /dev/null @@ -1,27 +0,0 @@ - - -
- - - {@render children?.()} - - -
diff --git a/src/lib/components/ImageTile.svelte b/src/lib/components/ImageTile.svelte deleted file mode 100644 index dfe8c74..0000000 --- a/src/lib/components/ImageTile.svelte +++ /dev/null @@ -1,50 +0,0 @@ - - -
- { - const img = e.currentTarget as HTMLImageElement; - img.src = placeholder; - // Clear srcset on error to avoid loading broken thumbnails - img.srcset = ""; - }} - /> -
- {@render children?.()} -
-
diff --git a/src/lib/components/Markdown.svelte b/src/lib/components/Markdown.svelte deleted file mode 100644 index ab1b8a2..0000000 --- a/src/lib/components/Markdown.svelte +++ /dev/null @@ -1,99 +0,0 @@ - - -
- {@html html} -
- - diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts deleted file mode 100644 index 809c9f8..0000000 --- a/src/lib/i18n.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { createI18n } from "@inlang/paraglide-sveltekit" -import * as runtime from "$lib/paraglide/runtime" - -export const i18n = createI18n(runtime, { - pathnames: { - "/about": { - en: "/about", - de: "/ueber-uns" - } - } -}) \ No newline at end of file diff --git a/src/lib/images/fotos/sunne_untergang.webp b/src/lib/images/fotos/sunne_untergang.webp deleted file mode 100644 index e2ade43..0000000 Binary files a/src/lib/images/fotos/sunne_untergang.webp and /dev/null differ diff --git a/src/lib/images/home/console.webp b/src/lib/images/home/console.webp deleted file mode 100644 index 7dec489..0000000 Binary files a/src/lib/images/home/console.webp and /dev/null differ diff --git a/src/lib/images/home/drummachine.webp b/src/lib/images/home/drummachine.webp deleted file mode 100644 index 64386c5..0000000 Binary files a/src/lib/images/home/drummachine.webp and /dev/null differ diff --git a/src/lib/images/home/lauch.webp b/src/lib/images/home/lauch.webp deleted file mode 100644 index c75260f..0000000 Binary files a/src/lib/images/home/lauch.webp and /dev/null differ diff --git a/src/lib/images/home/mouse.webp b/src/lib/images/home/mouse.webp deleted file mode 100644 index 937c70f..0000000 Binary files a/src/lib/images/home/mouse.webp and /dev/null differ diff --git a/src/lib/images/home/scouts.webp b/src/lib/images/home/scouts.webp deleted file mode 100644 index 1fe68d9..0000000 Binary files a/src/lib/images/home/scouts.webp and /dev/null differ diff --git a/src/lib/images/informatik/monitor.webp b/src/lib/images/informatik/monitor.webp deleted file mode 100644 index 461300c..0000000 Binary files a/src/lib/images/informatik/monitor.webp and /dev/null differ diff --git a/src/lib/images/musig/plattespiler.webp b/src/lib/images/musig/plattespiler.webp deleted file mode 100644 index cc3f680..0000000 Binary files a/src/lib/images/musig/plattespiler.webp and /dev/null differ diff --git a/src/lib/images/niklas_nacht_pfadi.webp b/src/lib/images/niklas_nacht_pfadi.webp deleted file mode 100644 index 6e45b39..0000000 Binary files a/src/lib/images/niklas_nacht_pfadi.webp and /dev/null differ diff --git a/src/lib/images/video/jochen.webp b/src/lib/images/video/jochen.webp deleted file mode 100644 index d0d6734..0000000 Binary files a/src/lib/images/video/jochen.webp and /dev/null differ diff --git a/src/lib/images/video/niklas_bw.webp b/src/lib/images/video/niklas_bw.webp deleted file mode 100644 index e2be9a9..0000000 Binary files a/src/lib/images/video/niklas_bw.webp and /dev/null differ diff --git a/src/lib/index.ts b/src/lib/index.ts deleted file mode 100644 index 856f2b6..0000000 --- a/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/src/lib/server/cache.ts b/src/lib/server/cache.ts deleted file mode 100644 index 11c4b69..0000000 --- a/src/lib/server/cache.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { LRUCache } from "lru-cache"; - -// const cache = new Map(); -const DEFAULT_TTL = 1000 * 60 * 15; // 15 minutes default TTL -const MAX_CACHE_SIZE = 1000 * 1000 * 750; // 750 MB - -const cache = new LRUCache({ - max: 100, - // Maximum allowed size (in bytes) - maxSize: MAX_CACHE_SIZE, - - // IMPORTANT: We must teach the cache how to calculate the size of an item. - // We check for your specific image structure, generic buffers, or fallback to JSON length. - sizeCalculation: (value) => { - // 1. Check if it's our specific image object { buffer: ArrayBuffer, ... } - if (value && typeof value === "object") { - const obj = value as Record; - if (obj.buffer instanceof ArrayBuffer) { - return obj.buffer.byteLength; - } - } - - // 2. Handle raw ArrayBuffers or Node.js Buffers - if (value instanceof ArrayBuffer) { - return value.byteLength; - } - - if (Buffer.isBuffer(value)) { - return value.length; - } - - // 3. Fallback for strings or JSON metadata - try { - const str = JSON.stringify(value); - return str ? str.length : 1; - } catch { - return 1; - } - }, - ttl: DEFAULT_TTL, -}); - -/** - * Caches the result of a promise-returning function. - * @param key Unique key for the cache entry. - * @param fetcher Function that returns a promise with the data to cache. - * @param ttl Time to live in milliseconds. Defaults to 15 minutes. - */ -export async function withCache( - key: string, - fetcher: () => Promise, - ttl = DEFAULT_TTL, -): Promise { - const entry = cache.get(key); - - if (entry) { - return entry as T; - } - - try { - const data = await fetcher(); - if (data) { - cache.set(key, data, { ttl: ttl }); - } - return data; - } catch (error) { - console.error(`Error fetching data for key ${key}:`, error); - // If fetch fails but we have stale data, return it? - // For now, let's bubble the error up so the page handles it (e.g. 404), - // or maybe just re-throw. - throw error; - } -} - -/** - * Manually clears a specific cache key. - */ -export function clearCache(key: string) { - cache.delete(key); -} - -/** - * Clears the entire cache. - */ -export function clearAllCache() { - cache.clear(); -} diff --git a/src/lib/server/nextcloud.ts b/src/lib/server/nextcloud.ts deleted file mode 100644 index 4e57c6c..0000000 --- a/src/lib/server/nextcloud.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { createClient } from "webdav"; -import { env } from "$env/dynamic/private"; -import { withCache } from "./cache"; - -if (!env.NEXTCLOUD_URL || !env.NEXTCLOUD_USER || !env.NEXTCLOUD_PASSWORD) { - console.warn( - "Nextcloud environment variables are not fully set. WebDAV client might not work correctly.", - ); -} - -// Construct the standard Nextcloud WebDAV URL: https://example.com/remote.php/dav/files/USERNAME/[BASE_DIR/] -const getWebdavUrl = () => { - if (!env.NEXTCLOUD_URL) return ""; - - let url = env.NEXTCLOUD_URL.endsWith("/") - ? env.NEXTCLOUD_URL - : `${env.NEXTCLOUD_URL}/`; - url += `remote.php/dav/files/${env.NEXTCLOUD_USER}/`; - - if (env.NEXTCLOUD_BASE_DIR) { - // Remove leading/trailing slashes from base dir to ensure clean concatenation - const baseDir = env.NEXTCLOUD_BASE_DIR.replace(/^\/+|\/+$/g, ""); - if (baseDir) { - url += `${baseDir}/`; - } - } - - return url; -}; - -export const client = createClient(getWebdavUrl(), { - username: env.NEXTCLOUD_USER || "", - password: env.NEXTCLOUD_PASSWORD || "", -}); - -export async function getCoverImage(slug: string): Promise { - return withCache(`cover:${slug}`, async () => { - try { - const contents = await client.getDirectoryContents("/" + slug); - if (!Array.isArray(contents)) return null; - - const cover = contents.find( - (item: any) => - item.type === "file" && - item.basename.match(/^cover\.(webp|jpg|jpeg|png)$/i), - ); - - return cover ? `/assets/${slug}/${cover.basename}` : null; - } catch (e) { - console.warn(`Failed to check cover image for ${slug}:`, e); - return null; - } - }); -} - -export async function getPages(lang: string = 'de') { - return withCache(`pages:${lang}`, async () => { - try { - const items = await client.getDirectoryContents("/"); - - if (!Array.isArray(items)) { - return []; - } - - const directories = items.filter( - (item: any) => - item.type === "directory" && - !item.basename.startsWith(".") && - !item.basename.startsWith("_"), - ); - - const pages = await Promise.all( - directories.map(async (item: any) => { - const slug = item.basename; - const baseName = slug.charAt(0).toUpperCase() + slug.slice(1); - const filename = lang === 'de' ? `${baseName}.md` : `${baseName}.${lang}.md`; - const path = `/${slug}/${filename}`; - - let title = baseName; - try { - const content = await getPageContent(path); - const headerMatch = content.match(/^#{1,6}\s+(.+)$/m); - if (headerMatch) { - title = headerMatch[1]; - } - } catch (e) { - // Fallback to German if English is missing - if (lang !== 'de') { - try { - const fallbackContent = await getPageContent(`/${slug}/${baseName}.md`); - const headerMatch = fallbackContent.match(/^#{1,6}\s+(.+)$/m); - if (headerMatch) { - title = headerMatch[1]; - } - } catch (innerE) { - console.warn(`Could not fetch fallback title for ${slug}`); - } - } - } - - const coverImage = await getCoverImage(slug); - - return { - slug, - title, - coverImage, - }; - }), - ); - - return pages; - } catch (e) { - console.error("Failed to fetch pages from Nextcloud:", e); - return []; - } - }); -} - -export async function getPageContent(path: string): Promise { - return withCache(`content:${path}`, async () => { - const content = await client.getFileContents(path, { format: "text" }); - return content as string; - }); -} diff --git a/src/params/lang.ts b/src/params/lang.ts deleted file mode 100644 index 3eefba1..0000000 --- a/src/params/lang.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { ParamMatcher } from '@sveltejs/kit'; - -export const match: ParamMatcher = (param) => { - return ['de', 'en'].includes(param); -}; diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts deleted file mode 100644 index fe36a9c..0000000 --- a/src/routes/+layout.server.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { LayoutServerLoad } from './$types'; -import { getPages } from '$lib/server/nextcloud'; - -export const load: LayoutServerLoad = async ({ params }) => { - const pages = await getPages(params.lang); - return { - pages - }; -}; \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte deleted file mode 100644 index 31b175b..0000000 --- a/src/routes/+layout.svelte +++ /dev/null @@ -1,49 +0,0 @@ - - - - {m.site_title()} - - - - -
- schreifuchs.ch - -
- {@render children?.()} -
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts deleted file mode 100644 index 9406451..0000000 --- a/src/routes/+layout.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This can be false if you're using a fallback (i.e. SPA mode) -// export const prerender = true; -// export const trailingSlash = 'always'; diff --git a/src/routes/[[lang=lang]]/+page.svelte b/src/routes/[[lang=lang]]/+page.svelte deleted file mode 100644 index 209b927..0000000 --- a/src/routes/[[lang=lang]]/+page.svelte +++ /dev/null @@ -1,50 +0,0 @@ - - -
- {#if data.pages} - {#each data.pages as page} - -

- {page.title} -

-
- {/each} - {/if} - - - -

- {m.pfadi()} -

-
-
- diff --git a/src/routes/[[lang=lang]]/[slug]/+page.server.ts b/src/routes/[[lang=lang]]/[slug]/+page.server.ts deleted file mode 100644 index dcaa1e9..0000000 --- a/src/routes/[[lang=lang]]/[slug]/+page.server.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { getCoverImage, getPageContent } from "$lib/server/nextcloud"; -import type { PageServerLoad } from "./$types"; -import { error } from "@sveltejs/kit"; - -export const load: PageServerLoad = async ({ params }) => { - const { slug, lang } = params; - const language = lang || 'de'; - - // Try both the regular slug and the hidden (_slug) folder - const slugsToTry = [slug, `_${slug}`]; - let rawContent = ""; - let finalSlug = slug; - let baseName = ""; - let filename = ""; - - for (const s of slugsToTry) { - const cleanSlug = s.startsWith('_') ? s.slice(1) : s; - baseName = cleanSlug.charAt(0).toUpperCase() + cleanSlug.slice(1); - - filename = language === 'de' ? `${baseName}.md` : `${baseName}.${language}.md`; - const path = `/${s}/${filename}`; - - try { - try { - rawContent = await getPageContent(path); - finalSlug = s; - break; // Found it! - } catch (e) { - if (language !== 'de') { - console.warn(`Localized content ${filename} not found in ${s}, falling back to German.`); - rawContent = await getPageContent(`/${s}/${baseName}.md`); - finalSlug = s; - break; // Found fallback - } else { - throw e; // Try next slug variant - } - } - } catch (e) { - if (s === slugsToTry[slugsToTry.length - 1]) { - console.error(`Error fetching page from Nextcloud for slug ${slug}`, e); - throw error(404, "Page not found"); - } - } - } - - try { - // Extract the first header (e.g., # Title or ## Title) - const headerMatch = rawContent.match(/^#{1,6}\s+(.+)$/m); - const title = headerMatch ? headerMatch[1] : (finalSlug.startsWith('_') ? finalSlug.slice(1) : finalSlug); - - // Remove the first header from content so it's not rendered twice - const content = headerMatch - ? rawContent.replace(headerMatch[0], "").trim() - : rawContent; - - const coverImage = await getCoverImage(finalSlug); - - return { - content, - title, - slug: finalSlug, - coverImage, - lang: language - }; - } catch (e) { - console.error(`Error processing content for ${finalSlug}`, e); - throw error(404, "Page not found"); - } -}; \ No newline at end of file diff --git a/src/routes/[[lang=lang]]/[slug]/+page.svelte b/src/routes/[[lang=lang]]/[slug]/+page.svelte deleted file mode 100644 index 7373213..0000000 --- a/src/routes/[[lang=lang]]/[slug]/+page.svelte +++ /dev/null @@ -1,46 +0,0 @@ - - - - {data.title} - schreifuchs.ch - - - -

- {data.title} -

-
- -
-
- -
-
\ No newline at end of file diff --git a/src/routes/assets/[...path]/+server.ts b/src/routes/assets/[...path]/+server.ts deleted file mode 100644 index c58be55..0000000 --- a/src/routes/assets/[...path]/+server.ts +++ /dev/null @@ -1,136 +0,0 @@ -// src/routes/assets/[...path]/+server.ts -import { client } from "$lib/server/nextcloud"; -import { error } from "@sveltejs/kit"; -import type { RequestHandler } from "./$types"; -import mime from "mime-types"; -import { env } from "$env/dynamic/private"; -import { withCache } from "$lib/server/cache"; - -const DEFAULT_TTL = 1000 * 60 * 15; // 15min -const EXTENDED_TTL = 1000 * 60 * 60 * 24 * 7; // 1 week - -// Define what we are storing in the cache -type CachedAsset = { - buffer: ArrayBuffer; - contentType: string; -}; - -export const GET: RequestHandler = async ({ params, url }) => { - const { path } = params; - const width = url.searchParams.get("w"); - const height = url.searchParams.get("h"); - - if (!path) { - throw error(400, "Path is required"); - } - - // 1. Create a unique cache key for this specific asset variation - const cacheKey = `asset:${path}?w=${width ?? ""}&h=${height ?? ""}`; - - const ttl = path.toString().includes("cover") ? DEFAULT_TTL : EXTENDED_TTL; - - try { - // 2. Use withCache to wrap the fetching logic - const cachedData = await withCache( - cacheKey, - async () => { - // --- START OF FETCH LOGIC --- - // This function only runs if the data is NOT in the cache - - const pathsToTry = [path]; - if (!path.startsWith("_")) { - pathsToTry.push(`_${path}`); - } - let lastError: any = null; - - for (const currentPath of pathsToTry) { - try { - // A. Try Nextcloud Preview (Resizing) - if (width || height) { - const baseUrl = env.NEXTCLOUD_URL?.endsWith("/") - ? env.NEXTCLOUD_URL - : `${env.NEXTCLOUD_URL}/`; - - let fullPath = currentPath; - if (env.NEXTCLOUD_BASE_DIR) { - const baseDir = env.NEXTCLOUD_BASE_DIR.replace( - /^\/+|\/+$/g, - "", - ); - fullPath = baseDir ? `${baseDir}/${currentPath}` : currentPath; - } - - const isJpg = fullPath.match(/\.(jpg|jpeg)$/i); - const previewExtension = isJpg ? "jpg" : "png"; - const previewUrl = new URL( - `${baseUrl}index.php/core/preview.${previewExtension}`, - ); - - const fileParam = fullPath.startsWith("/") - ? fullPath - : `/${fullPath}`; - previewUrl.searchParams.set("file", fileParam); - if (width) previewUrl.searchParams.set("x", width); - if (height) previewUrl.searchParams.set("y", height); - previewUrl.searchParams.set("forceIcon", "0"); - - const auth = Buffer.from( - `${env.NEXTCLOUD_USER}:${env.NEXTCLOUD_PASSWORD}`, - ).toString("base64"); - - console.log( - `Fetching preview: ${previewUrl.toString()} for file: ${fullPath}`, - ); - - const ncResponse = await fetch(previewUrl.toString(), { - headers: { Authorization: `Basic ${auth}` }, - }); - - if (ncResponse.ok) { - const buffer = await ncResponse.arrayBuffer(); - const contentType = - ncResponse.headers.get("Content-Type") || "image/png"; - - // Return the raw data to be cached - return { buffer, contentType }; - } else { - console.warn( - `Nextcloud preview failed (${ncResponse.status}) for ${fullPath}.`, - ); - } - } - - // B. Try WebDAV (Original) - console.log(`Fetching original file via WebDAV: /${currentPath}`); - const data = await client.getFileContents("/" + currentPath); - const buffer = data as ArrayBuffer; - const contentType = - mime.lookup(currentPath) || "application/octet-stream"; - - // Return the raw data to be cached - return { buffer, contentType }; - } catch (e) { - lastError = e; - continue; // Try next path variant - } - } - - throw lastError || new Error("Asset not found"); - // --- END OF FETCH LOGIC --- - }, - ttl, - ); - - // 3. Construct a fresh Response using the cached data - return new Response(cachedData.buffer, { - headers: { - "Content-Type": cachedData.contentType, - "Cache-Control": "public, max-age=86400", // Browser cache - Vary: "Accept-Encoding", - }, - }); - } catch (e) { - console.error(`Error fetching asset: ${path}`, e); - throw error(404, "Asset not found"); - } -}; diff --git a/svelte.config.js b/svelte.config.js deleted file mode 100644 index 302933d..0000000 --- a/svelte.config.js +++ /dev/null @@ -1,11 +0,0 @@ -import adapter from '@sveltejs/adapter-node'; -import { sveltePreprocess } from 'svelte-preprocess'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; -/** @type {import('@sveltejs/kit').Config} */ -const config = { - kit: { - adapter: adapter() - }, - preprocess: [vitePreprocess(), sveltePreprocess({})] -}; -export default config; diff --git a/tailwind.config.js b/tailwind.config.js deleted file mode 100644 index 96955a6..0000000 --- a/tailwind.config.js +++ /dev/null @@ -1,29 +0,0 @@ -import plugin from "tailwindcss/plugin" -/** @type {import('tailwindcss').Config} */ -export default { - content: ['./src/**/*.{html,js,svelte,ts}'], - theme: { - extend: { - fontFamily: { - sans: ['Outfit', 'outfit', 'sans-serif'] - }, - textShadow: { - sm: '0 1px 2px #000', - DEFAULT: '0 2px 4px #000', - lg: '0px 0px 20px #000', - }, - }, - }, - plugins: [ - plugin(function({ matchUtilities, theme }) { - matchUtilities( - { - 'text-shadow': (value) => ({ - textShadow: value, - }), - }, - { values: theme('textShadow') } - ) - }), - ], -} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index fc93cbd..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias - // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/vite.config.js b/vite.config.js deleted file mode 100644 index e2a48e7..0000000 --- a/vite.config.js +++ /dev/null @@ -1,13 +0,0 @@ -import { paraglide } from '@inlang/paraglide-sveltekit/vite'; -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [ - paraglide({ - project: './project.inlang', - outdir: './src/lib/paraglide' - }), - sveltekit() - ] -}); diff --git a/web/components/hello.templ b/web/components/hello.templ new file mode 100644 index 0000000..e124443 --- /dev/null +++ b/web/components/hello.templ @@ -0,0 +1,5 @@ +package components + +templ Hello() { +

Hello World

+} diff --git a/web/components/imagetile.templ b/web/components/imagetile.templ new file mode 100644 index 0000000..0590c0d --- /dev/null +++ b/web/components/imagetile.templ @@ -0,0 +1,17 @@ +package components + +import "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images" + +templ ImageTile(src string) { +
+ +
+ { children... } +
+
+} diff --git a/web/layouts/base.templ b/web/layouts/base.templ new file mode 100644 index 0000000..21ca704 --- /dev/null +++ b/web/layouts/base.templ @@ -0,0 +1,42 @@ +package layouts + +import "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/translate" +import "strings" +import "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/templer" + +templ Base(title string) { + + + + + + { title } + + + + + + +
+ schreifuchs.ch + +
+
+ { children... } +
+ + +} diff --git a/web/layouts/render.go b/web/layouts/render.go new file mode 100644 index 0000000..32a208f --- /dev/null +++ b/web/layouts/render.go @@ -0,0 +1,28 @@ +package layouts + +import ( + "context" + "fmt" + "io" + "log/slog" + "net/http" + + "github.com/a-h/templ" +) + +// Render renders a page. If the query paramenter "c" is set +// the component gets rendered without the layout +func Render(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) { + withLayout := !r.URL.Query().Has("c") + fmt.Println("layout: ", withLayout) + + slog.Debug("HX-Request", "value", r.Header.Get("HX-Request")) + if r.Header.Get("HX-Request") != "true" { + ctx = templ.WithChildren(ctx, component) + component = Base("hello") + } + + if err := component.Render(ctx, w); err != nil { + slog.Error("error while rendering component", "err", err, "ctx", ctx) + } +} diff --git a/web/pages/index.templ b/web/pages/index.templ new file mode 100644 index 0000000..734bb0d --- /dev/null +++ b/web/pages/index.templ @@ -0,0 +1,21 @@ +package pages + +import ( + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/page" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/translate" + "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web/components" +) + +templ Home(pages []page.PageHeader) { + for _, page := range pages { + @components.ImageTile("/images/" + page.CoverImageUID) { + +

+ { page.Title } +

+
+ } + } +} diff --git a/web/pages/page.templ b/web/pages/page.templ new file mode 100644 index 0000000..cb2b4a1 --- /dev/null +++ b/web/pages/page.templ @@ -0,0 +1,17 @@ +package pages + +import "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/page" +import "git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web/components" + +templ ContentPage(content page.Page) { + @components.ImageTile("/images/" + content.PageHeader.CoverImageUID) { +

+ { content.Title } +

+ } +
+
+ @templ.Raw(content.Content) +
+
+} diff --git a/web/resource.go b/web/resource.go new file mode 100644 index 0000000..a5111bb --- /dev/null +++ b/web/resource.go @@ -0,0 +1,22 @@ +//go:generate go tool templ generate +package web + +import ( + "embed" + "io/fs" +) + +//go:generate pnpm run build:css +//go:generate pnpm run build:js + +//go:embed static/* +var Static embed.FS + +func GetStaticFS() fs.FS { + // fs.Sub returns an fs.FS corresponding to the subtree rooted at "static" + f, err := fs.Sub(Static, "static") + if err != nil { + panic(err) + } + return f +} diff --git a/web/static/css/input.css b/web/static/css/input.css new file mode 100644 index 0000000..cafdb7d --- /dev/null +++ b/web/static/css/input.css @@ -0,0 +1,58 @@ +@import "tailwindcss"; +@plugin "@tailwindcss/typography"; +@source "../../**/*.templ"; + +@custom-variant dark (&:where(.dark, .dark *)); + +@font-face { + font-family: "Outfit"; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url("../fonts/Outfit-LatinExt-Variable.woff2") format("woff2"); + unicode-range: + U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, + U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, + U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} + +@font-face { + font-family: "Outfit"; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url("../fonts/Outfit-Latin-Variable.woff2") format("woff2"); + unicode-range: + U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, + U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, + U+2215, U+FEFF, U+FFFD; +} + +@theme { + /* Font Family Namespace */ + --font-sans: "Outfit", "outfit", sans-serif; + + /* Text Shadow Namespace */ + /* These will automatically generate .text-shadow-sm, .text-shadow, and .text-shadow-lg */ + --text-shadow-sm: 0 1px 2px #000; + --text-shadow: 0 2px 4px #000; + --text-shadow-lg: 0px 0px 20px #000; +} + +/* + Functional Utility for arbitrary values (e.g., text-shadow-[...]) + This replaces the 'matchUtilities' logic from your JS plugin. +*/ +@utility text-shadow-* { + text-shadow: --value(--text-shadow-*, [color], [*]); +} + +@layer components { + .prose img { + margin-left: auto; + margin-right: auto; + display: block; + + max-height: 90vh; + } +} diff --git a/web/static/css/output.css b/web/static/css/output.css new file mode 100644 index 0000000..f273bb9 --- /dev/null +++ b/web/static/css/output.css @@ -0,0 +1,2 @@ +/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */ +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-text-shadow-color:initial;--tw-text-shadow-alpha:100%}}}@layer theme{:root,:host{--font-sans:"Outfit","outfit",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-6xl:72rem;--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25/1.875);--font-weight-bold:700;--text-shadow-lg:0px 0px 20px #000;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components{.prose img{max-height:90vh;margin-left:auto;margin-right:auto;display:block}}@layer utilities{.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.static{position:static}.z-50{z-index:50}.col-start-1{grid-column-start:1}.row-start-1{grid-row-start:1}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);margin-top:1.2em;margin-bottom:1.2em;font-size:1.25em;line-height:1.6}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);font-weight:500;text-decoration:underline}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:decimal}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:disc}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-counters);font-weight:400}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.25em;font-weight:600}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em;font-style:italic;font-weight:500}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:0;margin-bottom:.888889em;font-size:2.25em;font-weight:800;line-height:1.11111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:900}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:2em;margin-bottom:1em;font-size:1.5em;font-weight:700;line-height:1.33333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:800}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.6em;margin-bottom:.6em;font-size:1.25em;font-weight:600;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.5em;margin-bottom:.5em;font-weight:600;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em;display:block}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-kbd);box-shadow:0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows);padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;border-radius:.3125rem;padding-inline-start:.375em;font-family:inherit;font-size:.875em;font-weight:500}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-size:.875em;font-weight:600}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);padding-top:.857143em;padding-inline-end:1.14286em;padding-bottom:.857143em;border-radius:.375rem;margin-top:1.71429em;margin-bottom:1.71429em;padding-inline-start:1.14286em;font-size:.875em;font-weight:400;line-height:1.71429;overflow-x:auto}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit;background-color:#0000;border-width:0;border-radius:0;padding:0}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){table-layout:auto;width:100%;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.71429}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);vertical-align:bottom;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em;font-weight:600}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);margin-top:.857143em;font-size:.875em;line-height:1.42857}.prose{--tw-prose-body:oklch(37.3% .034 259.733);--tw-prose-headings:oklch(21% .034 264.665);--tw-prose-lead:oklch(44.6% .03 256.802);--tw-prose-links:oklch(21% .034 264.665);--tw-prose-bold:oklch(21% .034 264.665);--tw-prose-counters:oklch(55.1% .027 264.364);--tw-prose-bullets:oklch(87.2% .01 258.338);--tw-prose-hr:oklch(92.8% .006 264.531);--tw-prose-quotes:oklch(21% .034 264.665);--tw-prose-quote-borders:oklch(92.8% .006 264.531);--tw-prose-captions:oklch(55.1% .027 264.364);--tw-prose-kbd:oklch(21% .034 264.665);--tw-prose-kbd-shadows:oklab(21% -.00316127 -.0338527/.1);--tw-prose-code:oklch(21% .034 264.665);--tw-prose-pre-code:oklch(92.8% .006 264.531);--tw-prose-pre-bg:oklch(27.8% .033 256.848);--tw-prose-th-borders:oklch(87.2% .01 258.338);--tw-prose-td-borders:oklch(92.8% .006 264.531);--tw-prose-invert-body:oklch(87.2% .01 258.338);--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:oklch(70.7% .022 261.325);--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:oklch(70.7% .022 261.325);--tw-prose-invert-bullets:oklch(44.6% .03 256.802);--tw-prose-invert-hr:oklch(37.3% .034 259.733);--tw-prose-invert-quotes:oklch(96.7% .003 264.542);--tw-prose-invert-quote-borders:oklch(37.3% .034 259.733);--tw-prose-invert-captions:oklch(70.7% .022 261.325);--tw-prose-invert-kbd:#fff;--tw-prose-invert-kbd-shadows:#ffffff1a;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:oklch(87.2% .01 258.338);--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:oklch(44.6% .03 256.802);--tw-prose-invert-td-borders:oklch(37.3% .034 259.733);font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.571429em;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-96{height:calc(var(--spacing)*96)}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-full{width:100%}.max-w-6xl{max-width:var(--container-6xl)}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-rows-1{grid-template-rows:repeat(1,minmax(0,1fr))}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-2{gap:calc(var(--spacing)*2)}.bg-black{background-color:var(--color-black)}.object-cover{object-fit:cover}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.px-12{padding-inline:calc(var(--spacing)*12)}.pt-8{padding-top:calc(var(--spacing)*8)}.text-justify{text-align:justify}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.mix-blend-difference{mix-blend-mode:difference}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.prose-invert{--tw-prose-body:var(--tw-prose-invert-body);--tw-prose-headings:var(--tw-prose-invert-headings);--tw-prose-lead:var(--tw-prose-invert-lead);--tw-prose-links:var(--tw-prose-invert-links);--tw-prose-bold:var(--tw-prose-invert-bold);--tw-prose-counters:var(--tw-prose-invert-counters);--tw-prose-bullets:var(--tw-prose-invert-bullets);--tw-prose-hr:var(--tw-prose-invert-hr);--tw-prose-quotes:var(--tw-prose-invert-quotes);--tw-prose-quote-borders:var(--tw-prose-invert-quote-borders);--tw-prose-captions:var(--tw-prose-invert-captions);--tw-prose-kbd:var(--tw-prose-invert-kbd);--tw-prose-kbd-shadows:var(--tw-prose-invert-kbd-shadows);--tw-prose-code:var(--tw-prose-invert-code);--tw-prose-pre-code:var(--tw-prose-invert-pre-code);--tw-prose-pre-bg:var(--tw-prose-invert-pre-bg);--tw-prose-th-borders:var(--tw-prose-invert-th-borders);--tw-prose-td-borders:var(--tw-prose-invert-td-borders)}.text-shadow-lg{text-shadow:var(--text-shadow-lg)}@media (hover:hover){.hover\:underline:hover{text-decoration-line:underline}}}@font-face{font-family:Outfit;font-style:normal;font-weight:100 900;font-display:swap;src:url(../fonts/Outfit-LatinExt-Variable.woff2)format("woff2");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Outfit;font-style:normal;font-weight:100 900;font-display:swap;src:url(../fonts/Outfit-Latin-Variable.woff2)format("woff2");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-text-shadow-color{syntax:"*";inherits:false}@property --tw-text-shadow-alpha{syntax:"";inherits:false;initial-value:100%} \ No newline at end of file diff --git a/static/favicon.png b/web/static/favicon.png similarity index 100% rename from static/favicon.png rename to web/static/favicon.png diff --git a/web/static/fonts/Outfit-Latin-Variable.woff2 b/web/static/fonts/Outfit-Latin-Variable.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/web/static/fonts/Outfit-Latin-Variable.woff2 differ diff --git a/web/static/fonts/Outfit-LatinExt-Variable.woff2 b/web/static/fonts/Outfit-LatinExt-Variable.woff2 new file mode 100644 index 0000000..c54ceec Binary files /dev/null and b/web/static/fonts/Outfit-LatinExt-Variable.woff2 differ diff --git a/web/static/js/htmx.min.js b/web/static/js/htmx.min.js new file mode 100644 index 0000000..faafa3e --- /dev/null +++ b/web/static/js/htmx.min.js @@ -0,0 +1 @@ +var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=dn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true,historyRestoreAsHxRequest:true,reportValidityOfForms:false},parseInterval:null,location:location,_:null,version:"2.0.8"};Q.onLoad=V;Q.process=Ft;Q.on=xe;Q.off=be;Q.trigger=ae;Q.ajax=Ln;Q.find=f;Q.findAll=x;Q.closest=g;Q.remove=_;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=ze;Q.defineExtension=_n;Q.removeExtension=zn;Q.logAll=j;Q.logNone=$;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:se,canAccessLocalStorage:X,findThisElement:Se,filterValues:yn,swap:ze,hasAttribute:s,getAttributeValue:a,getClosestAttributeValue:ne,getClosestMatch:q,getExpressionVars:Rn,getHeaders:mn,getInputValues:dn,getInternalData:oe,getSwapSpecification:bn,getTriggerSpecs:st,getTarget:Ee,makeFragment:D,mergeObjects:le,makeSettleInfo:Sn,oobSwap:Te,querySelectorExt:ue,settleImmediately:Yt,shouldCancel:ht,triggerEvent:ae,triggerErrorEvent:fe,withExtensions:Vt};const de=["get","post","put","delete","patch"];const R=de.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function a(e,t){return ee(e,t)||ee(e,"data-"+t)}function u(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function te(){return document}function y(e,t){return e.getRootNode?e.getRootNode({composed:t}):te()}function q(e,t){while(e&&!t(e)){e=u(e)}return e||null}function o(e,t,n){const r=a(t,n);const o=a(t,"hx-disinherit");var i=a(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function ne(t,n){let r=null;q(t,function(e){return!!(r=o(t,ce(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function A(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function L(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function N(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=te().createElement("script");ie(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){H(e)}finally{e.remove()}}})}function D(e){const t=e.replace(/]*)?>[\s\S]*?<\/head>/i,"");const n=A(t);let r;if(n==="html"){r=new DocumentFragment;const i=L(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=L(t);N(r,i.body);r.title=i.title}else{const i=L('");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function re(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function P(e){return typeof e==="function"}function k(e){return t(e,"Object")}function oe(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function M(t){const n=[];if(t){for(let e=0;e=0}function se(e){return e.getRootNode({composed:true})===document}function B(e){return e.trim().split(/\s+/)}function le(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function v(e){try{return JSON.parse(e)}catch(e){H(e);return null}}function X(){const e="htmx:sessionStorageTest";try{sessionStorage.setItem(e,e);sessionStorage.removeItem(e);return true}catch(e){return false}}function U(e){const t=new URL(e,"http://x");if(t){e=t.pathname+t.search}if(e!="/"){e=e.replace(/\/+$/,"")}return e}function e(e){return On(te().body,function(){return eval(e)})}function V(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function j(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function $(){Q.logger=null}function f(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return f(te(),e)}}function x(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return x(te(),e)}}function b(){return window}function _(e,t){e=w(e);if(t){b().setTimeout(function(){_(e);e=null},t)}else{u(e).removeChild(e)}}function ce(e){return e instanceof Element?e:null}function z(e){return e instanceof HTMLElement?e:null}function J(e){return typeof e==="string"?e:null}function p(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function K(e,t,n){e=ce(w(e));if(!e){return}if(n){b().setTimeout(function(){K(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function G(e,t,n){let r=ce(w(e));if(!r){return}if(n){b().setTimeout(function(){G(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function W(e,t){e=w(e);e.classList.toggle(t)}function Z(e,t){e=w(e);ie(e.parentElement.children,function(e){G(e,t)});K(ce(e),t)}function g(e,t){e=ce(w(e));if(e){return e.closest(t)}return null}function l(e,t){return e.substring(0,t.length)===t}function Y(e,t){return e.substring(e.length-t.length)===t}function pe(e){const t=e.trim();if(l(t,"<")&&Y(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function m(t,r,n){if(r.indexOf("global ")===0){return m(t,r.slice(7),true)}t=w(t);const o=[];{let t=0;let n=0;for(let e=0;e"){t--}}if(n0){const r=pe(o.shift());let e;if(r.indexOf("closest ")===0){e=g(ce(t),pe(r.slice(8)))}else if(r.indexOf("find ")===0){e=f(p(t),pe(r.slice(5)))}else if(r==="next"||r==="nextElementSibling"){e=ce(t).nextElementSibling}else if(r.indexOf("next ")===0){e=ge(t,pe(r.slice(5)),!!n)}else if(r==="previous"||r==="previousElementSibling"){e=ce(t).previousElementSibling}else if(r.indexOf("previous ")===0){e=me(t,pe(r.slice(9)),!!n)}else if(r==="document"){e=document}else if(r==="window"){e=window}else if(r==="body"){e=document.body}else if(r==="root"){e=y(t,!!n)}else if(r==="host"){e=t.getRootNode().host}else{s.push(r)}if(e){i.push(e)}}if(s.length>0){const e=s.join(",");const c=p(y(t,!!n));i.push(...M(c.querySelectorAll(e)))}return i}var ge=function(t,e,n){const r=p(y(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function ue(e,t){if(typeof e!=="string"){return m(e,t)[0]}else{return m(te().body,e)[0]}}function w(e,t){if(typeof e==="string"){return f(p(t)||document,e)}else{return e}}function ye(e,t,n,r){if(P(t)){return{target:te().body,event:J(e),listener:t,options:n}}else{return{target:w(e),event:J(t),listener:n,options:r}}}function xe(t,n,r,o){Gn(function(){const e=ye(t,n,r,o);e.target.addEventListener(e.event,e.listener,e.options)});const e=P(n);return e?n:r}function be(t,n,r){Gn(function(){const e=ye(t,n,r);e.target.removeEventListener(e.event,e.listener)});return P(n)?n:r}const ve=te().createElement("output");function we(t,n){const e=ne(t,n);if(e){if(e==="this"){return[Se(t,n)]}else{const r=m(t,e);const o=/(^|,)(\s*)inherit(\s*)($|,)/.test(e);if(o){const i=ce(q(t,function(e){return e!==t&&s(ce(e),n)}));if(i){r.push(...we(i,n))}}if(r.length===0){H('The selector "'+e+'" on '+n+" returned no matches!");return[ve]}else{return r}}}}function Se(e,t){return ce(q(e,function(e){return a(ce(e),t)!=null}))}function Ee(e){const t=ne(e,"hx-target");if(t){if(t==="this"){return Se(e,"hx-target")}else{return ue(e,t)}}else{const n=oe(e);if(n.boosted){return te().body}else{return e}}}function Ce(e){return Q.config.attributesToSettle.includes(e)}function Oe(t,n){ie(Array.from(t.attributes),function(e){if(!n.hasAttribute(e.name)&&Ce(e.name)){t.removeAttribute(e.name)}});ie(n.attributes,function(e){if(Ce(e.name)){t.setAttribute(e.name,e.value)}})}function He(t,e){const n=Jn(e);for(let e=0;e0){s=e.substring(0,e.indexOf(":"));n=e.substring(e.indexOf(":")+1)}else{s=e}o.removeAttribute("hx-swap-oob");o.removeAttribute("data-hx-swap-oob");const r=m(t,n,false);if(r.length){ie(r,function(e){let t;const n=o.cloneNode(true);t=te().createDocumentFragment();t.appendChild(n);if(!He(s,e)){t=p(n)}const r={shouldSwap:true,target:e,fragment:t};if(!ae(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){qe(t);$e(s,e,e,t,i);Re()}ie(i.elts,function(e){ae(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);fe(te().body,"htmx:oobErrorNoTarget",{content:o})}return e}function Re(){const e=f("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=f("#"+t.id);n.parentNode.moveBefore(t,n);n.remove()}e.remove()}}function qe(e){ie(x(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=a(e,"id");const n=te().getElementById(t);if(n!=null){if(e.moveBefore){let e=f("#--htmx-preserve-pantry--");if(e==null){te().body.insertAdjacentHTML("afterend","
");e=f("#--htmx-preserve-pantry--")}e.moveBefore(n,null)}else{e.parentNode.replaceChild(n,e)}}})}function Ae(l,e,c){ie(e.querySelectorAll("[id]"),function(t){const n=ee(t,"id");if(n&&n.length>0){const r=n.replace("'","\\'");const o=t.tagName.replace(":","\\:");const e=p(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);c.tasks.push(function(){Oe(t,s)})}}})}function Le(e){return function(){G(e,Q.config.addedClass);Ft(ce(e));Ne(p(e));ae(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=z(h(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function c(e,t,n,r){Ae(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;K(ce(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Le(o))}}}function Ie(e,t){let n=0;while(n0}function ze(h,d,p,g){if(!g){g={}}let m=null;let n=null;let e=function(){re(g.beforeSwapCallback);h=w(h);const r=g.contextElement?y(g.contextElement,false):te();const e=document.activeElement;let t={};t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null};const o=Sn(h);if(p.swapStyle==="textContent"){h.textContent=d}else{let n=D(d);o.title=g.title||n.title;if(g.historyRequest){n=n.querySelector("[hx-history-elt],[data-hx-history-elt]")||n}if(g.selectOOB){const i=g.selectOOB.split(",");for(let t=0;t0){b().setTimeout(n,p.settleDelay)}else{n()}};let t=Q.config.globalViewTransitions;if(p.hasOwnProperty("transition")){t=p.transition}const r=g.contextElement||te();if(t&&ae(r,"htmx:beforeTransition",g.eventInfo)&&typeof Promise!=="undefined"&&document.startViewTransition){const o=new Promise(function(e,t){m=e;n=t});const i=e;e=function(){document.startViewTransition(function(){i();return o})}}try{if(p?.swapDelay&&p.swapDelay>0){b().setTimeout(e,p.swapDelay)}else{e()}}catch(e){fe(r,"htmx:swapError",g.eventInfo);re(n);throw e}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=v(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(k(e)){n=e.target!==undefined?e.target:n}else{e={value:e}}ae(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=On(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){fe(te().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(tt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function O(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function rt(e){let t;if(e.length>0&&Ye.test(e[0])){e.shift();t=O(e,Qe).trim();e.shift()}else{t=O(e,E)}return t}const ot="input, textarea, select";function it(e,t,n){const r=[];const o=et(t);do{O(o,C);const l=o.length;const c=O(o,/[,\[\s]/);if(c!==""){if(c==="every"){const u={trigger:"every"};O(o,C);u.pollInterval=d(O(o,/[,\[\s]/));O(o,C);var i=nt(e,o,"event");if(i){u.eventFilter=i}r.push(u)}else{const f={trigger:c};var i=nt(e,o,"event");if(i){f.eventFilter=i}O(o,C);while(o.length>0&&o[0]!==","){const a=o.shift();if(a==="changed"){f.changed=true}else if(a==="once"){f.once=true}else if(a==="consume"){f.consume=true}else if(a==="delay"&&o[0]===":"){o.shift();f.delay=d(O(o,E))}else if(a==="from"&&o[0]===":"){o.shift();if(Ye.test(o[0])){var s=rt(o)}else{var s=O(o,E);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=rt(o);if(h.length>0){s+=" "+h}}}f.from=s}else if(a==="target"&&o[0]===":"){o.shift();f.target=rt(o)}else if(a==="throttle"&&o[0]===":"){o.shift();f.throttle=d(O(o,E))}else if(a==="queue"&&o[0]===":"){o.shift();f.queue=O(o,E)}else if(a==="root"&&o[0]===":"){o.shift();f[a]=rt(o)}else if(a==="threshold"&&o[0]===":"){o.shift();f[a]=O(o,E)}else{fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}r.push(f)}}if(o.length===l){fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function st(e){const t=a(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||it(e,t,r)}if(n.length>0){return n}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,ot)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function lt(e){oe(e).cancelled=true}function ct(e,t,n){const r=oe(e);r.timeout=b().setTimeout(function(){if(se(e)&&r.cancelled!==true){if(!pt(n,e,Xt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ut(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function ft(e){return g(e,Q.config.disableSelector)}function at(t,n,e){if(t instanceof HTMLAnchorElement&&ut(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"&&String(ee(t,"method")).toLowerCase()!=="dialog"){n.boosted=true;let r,o;if(t.tagName==="A"){r="get";o=ee(t,"href")}else{const i=ee(t,"method");r=i?i.toLowerCase():"get";o=ee(t,"action");if(o==null||o===""){o=location.href}if(r==="get"&&o.includes("?")){o=o.replace(/\?[^#]+/,"")}}e.forEach(function(e){gt(t,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)},n,e,true)})}}function ht(e,t){if(e.type==="submit"&&t.tagName==="FORM"){return true}else if(e.type==="click"){const n=t.closest('input[type="submit"], button');if(n&&n.form&&n.type==="submit"){return true}const r=t.closest("a");const o=/^#.+/;if(r&&r.href&&!o.test(r.getAttribute("href"))){return true}}return false}function dt(e,t){return oe(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function pt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;fe(te().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function gt(l,c,e,u,f){const a=oe(l);let t;if(u.from){t=m(l,u.from)}else{t=[l]}if(u.changed){if(!("lastValue"in a)){a.lastValue=new WeakMap}t.forEach(function(e){if(!a.lastValue.has(u)){a.lastValue.set(u,new WeakMap)}a.lastValue.get(u).set(e,e.value)})}ie(t,function(i){const s=function(e){if(!se(l)){i.removeEventListener(u.trigger,s);return}if(dt(l,e)){return}if(f||ht(e,i)){e.preventDefault()}if(pt(u,l,e)){return}const t=oe(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(l)<0){t.handledFor.push(l);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!h(ce(e.target),u.target)){return}}if(u.once){if(a.triggeredOnce){return}else{a.triggeredOnce=true}}if(u.changed){const n=e.target;const r=n.value;const o=a.lastValue.get(u);if(o.has(n)&&o.get(n)===r){return}o.set(n,r)}if(a.delayed){clearTimeout(a.delayed)}if(a.throttle){return}if(u.throttle>0){if(!a.throttle){ae(l,"htmx:trigger");c(l,e);a.throttle=b().setTimeout(function(){a.throttle=null},u.throttle)}}else if(u.delay>0){a.delayed=b().setTimeout(function(){ae(l,"htmx:trigger");c(l,e)},u.delay)}else{ae(l,"htmx:trigger");c(l,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:s,on:i});i.addEventListener(u.trigger,s)})}let mt=false;let yt=null;function xt(){if(!yt){yt=function(){mt=true};window.addEventListener("scroll",yt);window.addEventListener("resize",yt);setInterval(function(){if(mt){mt=false;ie(te().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&F(e)){e.setAttribute("data-hx-revealed","true");const t=oe(e);if(t.initHash){ae(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){ae(e,"revealed")},{once:true})}}}function vt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;ae(e,"htmx:trigger");t(e)}};if(r>0){b().setTimeout(o,r)}else{o()}}function wt(t,n,e){let i=false;ie(de,function(r){if(s(t,"hx-"+r)){const o=a(t,"hx-"+r);i=true;n.path=o;n.verb=r;e.forEach(function(e){St(t,e,n,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){xt();gt(r,n,t,e);bt(ce(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=ue(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ce(r),n,e)}else{gt(r,n,t,e)}}function Et(e){const t=ce(e);if(!t){return false}const n=t.attributes;for(let e=0;e", "+e).join(""));return o}else{return[]}}function Rt(e){const t=At(e.target);const n=Nt(e);if(n){n.lastButtonClicked=t}}function qt(e){const t=Nt(e);if(t){t.lastButtonClicked=null}}function At(e){return g(ce(e),"button, input[type='submit']")}function Lt(e){return e.form||g(e,"form")}function Nt(e){const t=At(e.target);if(!t){return}const n=Lt(t);if(!n){return}return oe(n)}function It(e){e.addEventListener("click",Rt);e.addEventListener("focusin",Rt);e.addEventListener("focusout",qt)}function Dt(t,e,n){const r=oe(t);if(!Array.isArray(r.onHandlers)){r.onHandlers=[]}let o;const i=function(e){On(t,function(){if(ft(t)){return}if(!o){o=new Function("event",n)}o.call(t,e)})};t.addEventListener(e,i);r.onHandlers.push({event:e,listener:i})}function Pt(t){Pe(t);for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{sessionStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(te().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Jt(t){if(!X()){return null}t=U(t);const n=v(sessionStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){r.response=this.response;ae(te().body,"htmx:historyCacheMissLoad",r);ze(r.historyElt,r.response,n,{contextElement:r.historyElt,historyRequest:true});$t(r.path);ae(te().body,"htmx:historyRestore",{path:e,cacheMiss:true,serverResponse:r.response})}else{fe(te().body,"htmx:historyCacheMissLoadError",r)}};if(ae(te().body,"htmx:historyCacheMiss",r)){t.send()}}function en(e){Gt();e=e||location.pathname+location.search;const t=Jt(e);if(t){const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0,scroll:t.scroll};const r={path:e,item:t,historyElt:_t(),swapSpec:n};if(ae(te().body,"htmx:historyCacheHit",r)){ze(r.historyElt,t.content,n,{contextElement:r.historyElt,title:t.title});$t(r.path);ae(te().body,"htmx:historyRestore",r)}}else{if(Q.config.refreshOnHistoryMiss){Q.location.reload(true)}else{Qt(e)}}}function tn(e){let t=we(e,"hx-indicator");if(t==null){t=[e]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function nn(e){let t=we(e,"hx-disabled-elt");if(t==null){t=[]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","");e.setAttribute("data-disabled-by-htmx","")});return t}function rn(e,t){ie(e.concat(t),function(e){const t=oe(e);t.requestCount=(t.requestCount||1)-1});ie(e,function(e){const t=oe(e);if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});ie(t,function(e){const t=oe(e);if(t.requestCount===0){e.removeAttribute("disabled");e.removeAttribute("data-disabled-by-htmx")}})}function on(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);ie(e,e=>r.append(t,e))}}function un(e){if(e instanceof HTMLSelectElement&&e.multiple){return M(e.querySelectorAll("option:checked")).map(function(e){return e.value})}if(e instanceof HTMLInputElement&&e.files){return M(e.files)}return e.value}function fn(t,n,r,e,o){if(e==null||on(t,e)){return}else{t.push(e)}if(sn(e)){const i=ee(e,"name");ln(i,un(e),n);if(o){an(e,r)}}if(e instanceof HTMLFormElement){ie(e.elements,function(e){if(t.indexOf(e)>=0){cn(e.name,un(e),n)}else{t.push(e)}if(o){an(e,r)}});new FormData(e).forEach(function(e,t){if(e instanceof File&&e.name===""){return}ln(t,e,n)})}}function an(e,t){const n=e;if(n.willValidate){ae(n,"htmx:validation:validate");if(!n.checkValidity()){if(ae(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})&&!t.length&&Q.config.reportValidityOfForms){n.reportValidity()}t.push({elt:n,message:n.validationMessage,validity:n.validity})}}}function hn(n,e){for(const t of e.keys()){n.delete(t)}e.forEach(function(e,t){n.append(t,e)});return n}function dn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=oe(e);if(s.lastButtonClicked&&!se(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||a(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){fn(n,o,i,Lt(e),l)}fn(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const u=s.lastButtonClicked||e;const f=ee(u,"name");ln(f,u.value,o)}const c=we(e,"hx-include");ie(c,function(e){fn(n,r,i,ce(e),l);if(!h(e,"form")){ie(p(e).querySelectorAll(ot),function(e){fn(n,r,i,e,l)})}});hn(r,o);return{errors:i,formData:r,values:kn(r)}}function pn(e,t,n){if(e!==""){e+="&"}if(String(n)==="[object Object]"){n=JSON.stringify(n)}const r=encodeURIComponent(n);e+=encodeURIComponent(t)+"="+r;return e}function gn(e){e=Dn(e);let n="";e.forEach(function(e,t){n=pn(n,t,e)});return n}function mn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":a(t,"id"),"HX-Current-URL":location.href};Cn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(oe(e).boosted){r["HX-Boosted"]="true"}return r}function yn(n,e){const t=ne(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){ie(t.slice(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;ie(t.split(","),function(t){t=t.trim();if(n.has(t)){n.getAll(t).forEach(function(e){r.append(t,e)})}});return r}}else{return n}}function xn(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function bn(e,t){const n=t||ne(e,"hx-swap");const r={swapStyle:oe(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&oe(e).boosted&&!xn(e)){r.show="top"}if(n){const s=B(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=u;r.scrollTarget=i}else if(l.indexOf("show:")===0){const f=l.slice(5);var o=f.split(":");const a=o.pop();var i=o.length>0?o.join(":"):null;r.show=a;r.showTarget=i}else if(l.indexOf("focus-scroll:")===0){const h=l.slice("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{H("Unknown modifier in hx-swap: "+l)}}}}return r}function vn(e){return ne(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function wn(t,n,r){let o=null;Vt(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(vn(n)){return hn(new FormData,Dn(r))}else{return gn(r)}}}function Sn(e){return{tasks:[],elts:[e]}}function En(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ce(ue(n,t.scrollTarget))}if(t.scroll==="top"&&(n||o)){o=o||n;o.scrollTop=0}if(t.scroll==="bottom"&&(r||o)){o=o||r;o.scrollTop=o.scrollHeight}if(typeof t.scroll==="number"){b().setTimeout(function(){window.scrollTo(0,t.scroll)},0)}}if(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ce(ue(n,e))}if(t.show==="top"&&(n||o)){o=o||n;o.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(r||o)){o=o||r;o.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function Cn(r,e,o,i,s){if(i==null){i={}}if(r==null){return i}const l=a(r,e);if(l){let e=l.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.slice(11);t=true}else if(e.indexOf("js:")===0){e=e.slice(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=On(r,function(){if(s){return Function("event","return ("+e+")").call(r,s)}else{return Function("return ("+e+")").call(r)}},{})}else{n=v(e)}for(const c in n){if(n.hasOwnProperty(c)){if(i[c]==null){i[c]=n[c]}}}}return Cn(ce(u(r)),e,o,i,s)}function On(e,t,n){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return n}}function Hn(e,t,n){return Cn(e,"hx-vars",true,n,t)}function Tn(e,t,n){return Cn(e,"hx-vals",false,n,t)}function Rn(e,t){return le(Hn(e,t),Tn(e,t))}function qn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function An(t){if(t.responseURL){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(te().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function T(e,t){return t.test(e.getAllResponseHeaders())}function Ln(t,n,r){t=t.toLowerCase();if(r){if(r instanceof Element||typeof r==="string"){return he(t,n,null,null,{targetOverride:w(r)||ve,returnPromise:true})}else{let e=w(r.target);if(r.target&&!e||r.source&&!e&&!w(r.source)){e=ve}return he(t,n,w(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:e,swapOverride:r.swap,select:r.select,returnPromise:true,push:r.push,replace:r.replace,selectOOB:r.selectOOB})}}else{return he(t,n,null,null,{returnPromise:true})}}function Nn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function In(e,t,n){const r=new URL(t,location.protocol!=="about:"?location.href:window.origin);const o=location.protocol!=="about:"?location.origin:window.origin;const i=o===r.origin;if(Q.config.selfRequestsOnly){if(!i){return false}}return ae(e,"htmx:validateUrl",le({url:r,sameHost:i},n))}function Dn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(e[n]&&typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"&&!(e[n]instanceof Blob)){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Pn(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function kn(o){return new Proxy(o,{get:function(e,t){if(typeof t==="symbol"){const r=Reflect.get(e,t);if(typeof r==="function"){return function(){return r.apply(o,arguments)}}else{return r}}if(t==="toJSON"){return()=>Object.fromEntries(o)}if(t in e){if(typeof e[t]==="function"){return function(){return o[t].apply(o,arguments)}}}const n=o.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Pn(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(e&&typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else if(typeof e==="object"&&!(e instanceof Blob)){t.append(n,JSON.stringify(e))}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function he(t,n,r,o,i,k){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=te().body}const M=i.handler||Vn;const F=i.select||null;if(!se(r)){re(s);return e}const c=i.targetOverride||ce(Ee(r));if(c==null||c==ve){fe(r,"htmx:targetError",{target:ne(r,"hx-target")});re(l);return e}let u=oe(r);const f=u.lastButtonClicked;if(f){const A=ee(f,"formaction");if(A!=null){n=A}const L=ee(f,"formmethod");if(L!=null){if(de.includes(L.toLowerCase())){t=L}else{re(s);return e}}}const a=ne(r,"hx-confirm");if(k===undefined){const K=function(e){return he(t,n,r,o,i,!!e)};const G={target:c,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:a};if(ae(r,"htmx:confirm",G)===false){re(s);return e}}let h=r;let d=ne(r,"hx-sync");let p=null;let B=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Se(r,"hx-sync")}else{h=ce(ue(r,I))}d=(N[1]||"drop").trim();u=oe(h);if(d==="drop"&&u.xhr&&u.abortable!==true){re(s);return e}else if(d==="abort"){if(u.xhr){re(s);return e}else{B=true}}else if(d==="replace"){ae(h,"htmx:abort")}else if(d.indexOf("queue")===0){const W=d.split(" ");p=(W[1]||"last").trim()}}if(u.xhr){if(u.abortable){ae(h,"htmx:abort")}else{if(p==null){if(o){const D=oe(o);if(D&&D.triggerSpec&&D.triggerSpec.queue){p=D.triggerSpec.queue}}if(p==null){p="last"}}if(u.queuedRequests==null){u.queuedRequests=[]}if(p==="first"&&u.queuedRequests.length===0){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="all"){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="last"){u.queuedRequests=[];u.queuedRequests.push(function(){he(t,n,r,o,i)})}re(s);return e}}const g=new XMLHttpRequest;u.xhr=g;u.abortable=B;const m=function(){u.xhr=null;u.abortable=false;if(u.queuedRequests!=null&&u.queuedRequests.length>0){const e=u.queuedRequests.shift();e()}};const X=ne(r,"hx-prompt");if(X){var y=prompt(X);if(y===null||!ae(r,"htmx:prompt",{prompt:y,target:c})){re(s);m();return e}}if(a&&!k){if(!confirm(a)){re(s);m();return e}}let x=mn(r,c,y);if(t!=="get"&&!vn(r)){x["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){x=le(x,i.headers)}const U=dn(r,t);let b=U.errors;const V=U.formData;if(i.values){hn(V,Dn(i.values))}const j=Dn(Rn(r,o));const v=hn(V,j);let w=yn(v,r);if(Q.config.getCacheBusterParam&&t==="get"){w.set("org.htmx.cache-buster",ee(c,"id")||"true")}if(n==null||n===""){n=location.href}const S=Cn(r,"hx-request");const $=oe(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:$,useUrlParams:E,formData:w,parameters:kn(w),unfilteredFormData:v,unfilteredParameters:kn(v),headers:x,elt:r,target:c,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!ae(r,"htmx:configRequest",C)){re(s);m();return e}n=C.path;t=C.verb;x=C.headers;w=Dn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){ae(r,"htmx:validation:halted",C);re(s);m();return e}const _=n.split("#");const z=_[0];const O=_[1];let H=n;if(E){H=z;const Z=!w.keys().next().done;if(Z){if(H.indexOf("?")<0){H+="?"}else{H+="&"}H+=gn(w);if(O){H+="#"+O}}}if(!In(r,H,C)){fe(r,"htmx:invalidPath",C);re(l);m();return e}g.open(t.toUpperCase(),H,true);g.overrideMimeType("text/html");g.withCredentials=C.withCredentials;g.timeout=C.timeout;if(S.noHeaders){}else{for(const P in x){if(x.hasOwnProperty(P)){const Y=x[P];qn(g,P,Y)}}}const T={xhr:g,target:c,requestConfig:C,etc:i,boosted:$,select:F,pathInfo:{requestPath:n,finalRequestPath:H,responsePath:null,anchor:O}};g.onload=function(){try{const t=Nn(r);T.pathInfo.responsePath=An(g);M(r,T);if(T.keepIndicators!==true){rn(R,q)}ae(r,"htmx:afterRequest",T);ae(r,"htmx:afterOnLoad",T);if(!se(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(se(n)){e=n}}if(e){ae(e,"htmx:afterRequest",T);ae(e,"htmx:afterOnLoad",T)}}re(s)}catch(e){fe(r,"htmx:onLoadError",le({error:e},T));throw e}finally{m()}};g.onerror=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendError",T);re(l);m()};g.onabort=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendAbort",T);re(l);m()};g.ontimeout=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:timeout",T);re(l);m()};if(!ae(r,"htmx:beforeRequest",T)){re(s);m();return e}var R=tn(r);var q=nn(r);ie(["loadstart","loadend","progress","abort"],function(t){ie([g,g.upload],function(e){e.addEventListener(t,function(e){ae(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});ae(r,"htmx:beforeSend",T);const J=E?null:wn(g,r,w);g.send(J);return e}function Mn(e,t){const n=t.xhr;let r=null;let o=null;if(T(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(T(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(T(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=t.etc.push||ne(e,"hx-push-url");const c=t.etc.replace||ne(e,"hx-replace-url");const u=oe(e).boosted;let f=null;let a=null;if(l){f="push";a=l}else if(c){f="replace";a=c}else if(u){f="push";a=s||i}if(a){if(a==="false"){return{}}if(a==="true"){a=s||i}if(t.pathInfo.anchor&&a.indexOf("#")===-1){a=a+"#"+t.pathInfo.anchor}return{type:f,path:a}}else{return{}}}function Fn(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Bn(e){for(var t=0;t`+`.${t}{opacity:0;visibility: hidden} `+`.${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`+"")}}function Zn(){const e=te().querySelector('meta[name="htmx-config"]');if(e){return v(e.content)}else{return null}}function Yn(){const e=Zn();if(e){Q.config=le(Q.config,e)}}Gn(function(){Yn();Wn();let e=te().body;Ft(e);const t=te().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.detail.elt||e.target;const n=oe(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){en();ie(t,function(e){ae(e,"htmx:restored",{document:te(),triggerEvent:ae})})}else{if(n){n(e)}}};b().setTimeout(function(){ae(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file diff --git a/static/robots.txt b/web/static/robots.txt similarity index 100% rename from static/robots.txt rename to web/static/robots.txt