forked from Botanical/BotanJS
1.7 KiB
1.7 KiB
botanres-go
Go rewrite for the old BotanJS dynamic resource resolver.
cmd/botan-genscans the JS tree and generatesinternal/generated/classmap_gen.go.internal/resolverresolves requested classes in memory.cmd/botan-apiaccepts the old-ish URL shape and returns merged JS/CSS content or a hash filename.- Closure/YUI compression is not in this skeleton. The returned merged JS is the right handoff point for a Closure Compiler server.
Generate the class map
go run ./cmd/botan-gen \
-src /path/to/BotanJS/src \
-out internal/generated/classmap_gen.go
Commit the generated file if the source tree is mostly static. Generate it in CI if the source changes frequently.
Run API
go run ./cmd/botan-api -src /path/to/BotanJS/src -addr :8080
Examples:
curl 'http://127.0.0.1:8080/rjs/System'
curl 'http://127.0.0.1:8080/rcss/BotanJS.Core.Main'
curl 'http://127.0.0.1:8080/hjs/BotanJS.Core.Main'
Requests support / separated plain names, e.g. A.B.C/A.B.D, plus old compressed base64+zlib comma-separated payloads.
Prefix an item with - to exclude it.
What is intentionally different from the Python version
- No XML tree. Symbols are flattened by full namespace name.
- No per-request classmap reload. Regenerate and restart/redeploy instead.
- No background compressor. This is a resolver/merger only.
- Hashes use SHA-1 per file for change detection, then MD5 over the resolved hash list for compatibility-style output names.
TODO
- Test against the old python resolver output
- Add an output interface so JS can be piped directly to a Closure Compiler server.
- Put generated classmap in a separate package if multiple services need to import it.