module

Kozai::Assets

The web interface, compiled into the binary.

Every file under src/web/ is read at compile time by read_file and becomes a string constant. The resulting program has no data directory, no install step and no way to be half-deployed: the executable either runs or it does not, and if it runs it has its user interface.

NOTE: there is no build pipeline here, and there will not be one. No Node, no bundler, no transpiler, no CSS framework. The interface is HTML, CSS and JavaScript as the browser receives them, which means git blame on the file you are debugging points at the code that is actually running, and building this project needs nothing but a Crystal compiler.

The map is a committed SVG rather than tiles from a CDN. See tools/geojson_to_svg.cr; the short version is that a station with no internet is the target case, not a degraded one.

Constants

APP_JS = {{ read_file("/tmp/tmp.lHiJjp/src/src/web/app.js") }}

Behaviour.

FILES = {"/" => Asset.new(INDEX_HTML, "text/html; charset=utf-8"), "/index.html" => Asset.new(INDEX_HTML, "text/html; charset=utf-8"), "/app.js" => Asset.new(APP_JS, "text/javascript; charset=utf-8"), "/style.css" => Asset.new(STYLE_CSS, "text/css; charset=utf-8"), "/world.svg" => Asset.new(WORLD_SVG, "image/svg+xml; charset=utf-8")}

Every asset, by request path.

INDEX_HTML = {{ read_file("/tmp/tmp.lHiJjp/src/src/web/index.html") }}

The single page.

STYLE_CSS = {{ read_file("/tmp/tmp.lHiJjp/src/src/web/style.css") }}

Presentation.

WORLD_SVG = {{ read_file("/tmp/tmp.lHiJjp/src/src/web/world.svg") }}

Continent outlines, equirectangular, public domain.

Class methods

lookup(path : String) : Asset | Nil

The asset for path, or nil if there is none.

Source
total_bytes

Total size of the embedded interface, for the startup banner.

Source

Nested types