This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
cargo run # Dev mode
cargo build --release # Release build
cargo test # All tests
cargo test --lib <test_name> # Single test# Vue 3 + Vite + TypeScript (新版前端,默认)
cd frontend && npm install && npm run dev # Dev server
cd frontend && npm run build # Builds to frontend/dist/
# Vue 2 + Vue CLI (旧版前端,已废弃)
cd web && npm install
cd web && npm run serve # Dev server (uses disable-storage.js workaround)
cd web && npm run build # Builds to web/dist/
cd web && npm run lint # ESLint + Prettier# Build ARM64 image (requires pre-built binary)
cargo build --release --target aarch64-unknown-linux-musl
podman build --platform linux/arm64 -t docker.io/givenge/reader-rust:${TAG}-aarch64 -f Dockerfile .
# Build x86_64 image (requires pre-built binary)
cargo build --release --target x86_64-unknown-linux-musl
podman build --platform linux/amd64 -t docker.io/givenge/reader-rust:${TAG}-x86_64 -f Dockerfile.x86 .Dockerfiles do NOT compile Rust in-container. Build the binary on the host first, then copy it.
- Default release repository:
docker.io/givenge/reader-rust - Default rolling tags:
latest-> x86_64latest-aarch64-> arm64- Build commands must explicitly set platform:
- x86_64:
podman build --platform linux/amd64 ... -f Dockerfile.x86 . - arm64:
podman build --platform linux/arm64 ... -f Dockerfile . - For any “发布版本 / 发布docker镜像 / release版本” request, run
./scripts/release.shby default. - If user does not specify version, auto-bump patch from latest tag (
vX.Y.Z -> vX.Y.(Z+1)). - Full end-to-end workflow is in
/RELEASE_WORKFLOW.md. - Docker-specific details remain in
/DOCKER_RELEASE.md.
Loaded from .env file (via dotenvy) or environment variables. Separator is __ for nested keys. See .env.example for all options.
Key settings:
SERVER_HOST/SERVER_PORT— default0.0.0.0:8080DATABASE_URL— SQLite path, defaultsqlite:storage/reader.db?mode=rwcWEB_ROOT— static files path, defaultweb/distSECURE/SECURE_KEY— security mode toggleINVITE_CODE— registration gateUSER_LIMIT/USER_BOOK_LIMIT— default 50 / 2000LOG_LEVEL— defaultinfoREQUEST_TIMEOUT_SECS— default 15
Rust implementation of "阅读3.0" — a book source reading API server.
src/api/— HTTP handlers & routing (axum), routes under/reader3/*src/service/— Business logic (book search, sources, users)src/parser/— Content extraction engine with rule-based parsingsrc/crawler/— HTTP fetching via reqwestsrc/model/— Data structures (BookSource, rules)src/storage/— SQLite (sqlx), file cache (MD5 key), filesystem opssrc/app/— Config, logging, server setupsrc/error/— Error typessrc/util/— Utilities
api/handlers → service/ → crawler/ (fetch) → parser/rule_engine (parse with BookSource rules) → JSON response
RuleEngine auto-detects parsing mode:
- CSS selectors — default for HTML (
.class,#id,tag) - JSONPath — auto-detected for JSON (
$.data.list) - XPath — lines starting with
/or./ - JavaScript —
js:or@js:prefix (rquickjs) - Regex — starts with
: - Explicit prefixes:
@css:,@json:,@xpath:,@regex:
JSON objects with bookSourceUrl, bookSourceName, searchUrl/exploreUrl (with ${key} placeholders), and ruleSearch/ruleBookInfo/ruleToc/ruleContent parsing rules.
- Two frontend apps:
frontend/is Vue 3 (newer, default),web/is Vue 2 (legacy). Docker images usefrontend/dist/. web/build workaround:vue.config.jsdisables localStorage viadisable-storage.js— do not remove this./storage/is gitignored: Contains user data and SQLite DB.- No tests currently:
cargo testwill pass but there are no test files written yet.