diff --git a/.gitignore b/.gitignore index 89bfb82..7d9d44f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,3 @@ Thumbs.db .vscode/ project.nimcache/ -# Files without extensions (propably binaries) -**/[^./]* -!**/[^./]*/ diff --git a/README.md b/README.md index fa5661a..71c49c6 100755 --- a/README.md +++ b/README.md @@ -7,19 +7,18 @@ Luxtools is a minimal-but-complete scaffold for a retro-styled web application b - **Nim**: Nim's ahead-of-time compilation and small standard library make it ideal for producing a single self-contained binary. Its async HTTP primitives provide great performance with minimal boilerplate. - **HTMX**: HTMX keeps the frontend simple by embracing hypermedia. We can ship almost entirely server-rendered HTML snippets, allowing Nim to stay in control without a bulky SPA build step. - **TUI.CSS**: This lightweight CSS framework offers a retro terminal aesthetic with zero JavaScript and a tiny footprint—perfect for a nostalgic interface while remaining easy to customize. -- **Single binary delivery**: HTML templates and the entire `static/` tree of vendored assets are embedded at compile time via `staticRead`, so the server ships with everything it needs. The compiled binary serves those resources directly from an in-memory table, while a separate `www/` directory remains available for user-provided uploads. +- **Single binary delivery**: HTML templates and the entire `src/static/` tree of vendored assets are embedded at compile time via `staticRead`, so the server ships with everything it needs. The compiled binary serves those resources directly from an in-memory table, while a separate `assets/` directory remains available for user-provided uploads. ## Project layout ``` luxtools/ ├── bin/ # Output directory for release binaries -├── static/ # Vendored assets compiled into the binary static table ├── src/ -│ └── luxtools.nim # Main server entrypoint -├── templates/ -│ └── index.html # HTMX-powered landing page (compiled into the binary) -├── www/ # Runtime asset directory served from disk +│ ├── luxtools.nim # Main server entrypoint +│ ├── static/ # Vendored assets compiled into the binary static table +│ └── templates/ # HTMX-powered landing page (compiled into the binary) +├── assets/ # Runtime asset directory served from disk ├── tests/ │ └── test_rendering.nim# Lightweight regression tests for HTML helpers ├── luxtools.nimble # Nimble manifest with build/test tasks diff --git a/www/demo.txt b/assets/demo.txt similarity index 100% rename from www/demo.txt rename to assets/demo.txt diff --git a/luxtools b/luxtools new file mode 100755 index 0000000..55afbda Binary files /dev/null and b/luxtools differ diff --git a/luxtools.nimble b/luxtools.nimble index a87e80f..a2da1cc 100755 --- a/luxtools.nimble +++ b/luxtools.nimble @@ -13,7 +13,7 @@ task build, "Build the optimized standalone binary": exec "nim c -d:release --opt:speed -o:bin/luxtools src/luxtools.nim" task run, "Start the development server with hot rebuild": - exec "nim c -r src/luxtools.nim" + exec "nim c -o:bin/luxtools -r src/luxtools.nim" task test, "Execute the lightweight test suite": - exec "nim c -r --path:src tests/test_rendering.nim" + exec "nim c -r --path:src -o:bin/test_rendering tests/test_rendering.nim" diff --git a/src/luxtools.nim b/src/luxtools.nim index 35b7f1e..d07a692 100755 --- a/src/luxtools.nim +++ b/src/luxtools.nim @@ -1,7 +1,7 @@ import std/[asynchttpserver, asyncdispatch, os, strformat, strutils, tables, times] const - indexPage = staticRead("../templates/index.html") + indexPage = staticRead("templates/index.html") type StaticFile = tuple[content: string, contentType: string] @@ -33,7 +33,7 @@ proc guessContentType(path: string): string = else: defaultContentType -const staticRootDir = parentDir(currentSourcePath()) / ".." / "static" +const staticRootDir = parentDir(currentSourcePath()) / "static" const staticFileEntries: seq[(string, StaticFile)] = block: var entries: seq[(string, StaticFile)] = @[] @@ -59,7 +59,7 @@ proc findStaticFile(path: string; asset: var StaticFile): bool = false proc assetsRoot(): string = - absolutePath(joinPath(getAppDir(), "..", "www")) + absolutePath(joinPath(getAppDir(), "..", "assets")) var clickCount = 0 diff --git a/static/lib/htmx.2.0.7.min.js b/src/static/lib/htmx.2.0.7.min.js similarity index 100% rename from static/lib/htmx.2.0.7.min.js rename to src/static/lib/htmx.2.0.7.min.js diff --git a/static/lib/tuicss/fonts/Perfect DOS VGA 437 Win.ttf b/src/static/lib/tuicss/fonts/Perfect DOS VGA 437 Win.ttf similarity index 100% rename from static/lib/tuicss/fonts/Perfect DOS VGA 437 Win.ttf rename to src/static/lib/tuicss/fonts/Perfect DOS VGA 437 Win.ttf diff --git a/static/lib/tuicss/fonts/Perfect DOS VGA 437.ttf b/src/static/lib/tuicss/fonts/Perfect DOS VGA 437.ttf similarity index 100% rename from static/lib/tuicss/fonts/Perfect DOS VGA 437.ttf rename to src/static/lib/tuicss/fonts/Perfect DOS VGA 437.ttf diff --git a/static/lib/tuicss/fonts/dos437.txt b/src/static/lib/tuicss/fonts/dos437.txt similarity index 100% rename from static/lib/tuicss/fonts/dos437.txt rename to src/static/lib/tuicss/fonts/dos437.txt diff --git a/static/lib/tuicss/images/bg-blue-black.png b/src/static/lib/tuicss/images/bg-blue-black.png similarity index 100% rename from static/lib/tuicss/images/bg-blue-black.png rename to src/static/lib/tuicss/images/bg-blue-black.png diff --git a/static/lib/tuicss/images/bg-blue-white.png b/src/static/lib/tuicss/images/bg-blue-white.png similarity index 100% rename from static/lib/tuicss/images/bg-blue-white.png rename to src/static/lib/tuicss/images/bg-blue-white.png diff --git a/static/lib/tuicss/images/bg-cyan-black.png b/src/static/lib/tuicss/images/bg-cyan-black.png similarity index 100% rename from static/lib/tuicss/images/bg-cyan-black.png rename to src/static/lib/tuicss/images/bg-cyan-black.png diff --git a/static/lib/tuicss/images/bg-cyan-white.png b/src/static/lib/tuicss/images/bg-cyan-white.png similarity index 100% rename from static/lib/tuicss/images/bg-cyan-white.png rename to src/static/lib/tuicss/images/bg-cyan-white.png diff --git a/static/lib/tuicss/images/bg-green-black.png b/src/static/lib/tuicss/images/bg-green-black.png similarity index 100% rename from static/lib/tuicss/images/bg-green-black.png rename to src/static/lib/tuicss/images/bg-green-black.png diff --git a/static/lib/tuicss/images/bg-green-white.png b/src/static/lib/tuicss/images/bg-green-white.png similarity index 100% rename from static/lib/tuicss/images/bg-green-white.png rename to src/static/lib/tuicss/images/bg-green-white.png diff --git a/static/lib/tuicss/images/bg-orange-black.png b/src/static/lib/tuicss/images/bg-orange-black.png similarity index 100% rename from static/lib/tuicss/images/bg-orange-black.png rename to src/static/lib/tuicss/images/bg-orange-black.png diff --git a/static/lib/tuicss/images/bg-orange-white.png b/src/static/lib/tuicss/images/bg-orange-white.png similarity index 100% rename from static/lib/tuicss/images/bg-orange-white.png rename to src/static/lib/tuicss/images/bg-orange-white.png diff --git a/static/lib/tuicss/images/bg-purple-black.png b/src/static/lib/tuicss/images/bg-purple-black.png similarity index 100% rename from static/lib/tuicss/images/bg-purple-black.png rename to src/static/lib/tuicss/images/bg-purple-black.png diff --git a/static/lib/tuicss/images/bg-purple-white.png b/src/static/lib/tuicss/images/bg-purple-white.png similarity index 100% rename from static/lib/tuicss/images/bg-purple-white.png rename to src/static/lib/tuicss/images/bg-purple-white.png diff --git a/static/lib/tuicss/images/bg-red-black.png b/src/static/lib/tuicss/images/bg-red-black.png similarity index 100% rename from static/lib/tuicss/images/bg-red-black.png rename to src/static/lib/tuicss/images/bg-red-black.png diff --git a/static/lib/tuicss/images/bg-red-white.png b/src/static/lib/tuicss/images/bg-red-white.png similarity index 100% rename from static/lib/tuicss/images/bg-red-white.png rename to src/static/lib/tuicss/images/bg-red-white.png diff --git a/static/lib/tuicss/images/bg-yellow-black.png b/src/static/lib/tuicss/images/bg-yellow-black.png similarity index 100% rename from static/lib/tuicss/images/bg-yellow-black.png rename to src/static/lib/tuicss/images/bg-yellow-black.png diff --git a/static/lib/tuicss/images/bg-yellow-white.png b/src/static/lib/tuicss/images/bg-yellow-white.png similarity index 100% rename from static/lib/tuicss/images/bg-yellow-white.png rename to src/static/lib/tuicss/images/bg-yellow-white.png diff --git a/static/lib/tuicss/images/scroll-blue.png b/src/static/lib/tuicss/images/scroll-blue.png similarity index 100% rename from static/lib/tuicss/images/scroll-blue.png rename to src/static/lib/tuicss/images/scroll-blue.png diff --git a/static/lib/tuicss/images/scroll-cyan.png b/src/static/lib/tuicss/images/scroll-cyan.png similarity index 100% rename from static/lib/tuicss/images/scroll-cyan.png rename to src/static/lib/tuicss/images/scroll-cyan.png diff --git a/static/lib/tuicss/images/scroll-green.png b/src/static/lib/tuicss/images/scroll-green.png similarity index 100% rename from static/lib/tuicss/images/scroll-green.png rename to src/static/lib/tuicss/images/scroll-green.png diff --git a/static/lib/tuicss/images/scroll-orange.png b/src/static/lib/tuicss/images/scroll-orange.png similarity index 100% rename from static/lib/tuicss/images/scroll-orange.png rename to src/static/lib/tuicss/images/scroll-orange.png diff --git a/static/lib/tuicss/images/scroll-purple.png b/src/static/lib/tuicss/images/scroll-purple.png similarity index 100% rename from static/lib/tuicss/images/scroll-purple.png rename to src/static/lib/tuicss/images/scroll-purple.png diff --git a/static/lib/tuicss/images/scroll-red.png b/src/static/lib/tuicss/images/scroll-red.png similarity index 100% rename from static/lib/tuicss/images/scroll-red.png rename to src/static/lib/tuicss/images/scroll-red.png diff --git a/static/lib/tuicss/images/scroll-white.png b/src/static/lib/tuicss/images/scroll-white.png similarity index 100% rename from static/lib/tuicss/images/scroll-white.png rename to src/static/lib/tuicss/images/scroll-white.png diff --git a/static/lib/tuicss/images/scroll-yellow.png b/src/static/lib/tuicss/images/scroll-yellow.png similarity index 100% rename from static/lib/tuicss/images/scroll-yellow.png rename to src/static/lib/tuicss/images/scroll-yellow.png diff --git a/static/lib/tuicss/tuicss.css b/src/static/lib/tuicss/tuicss.css similarity index 100% rename from static/lib/tuicss/tuicss.css rename to src/static/lib/tuicss/tuicss.css diff --git a/static/lib/tuicss/tuicss.js b/src/static/lib/tuicss/tuicss.js similarity index 100% rename from static/lib/tuicss/tuicss.js rename to src/static/lib/tuicss/tuicss.js diff --git a/static/lib/tuicss/tuicss.min.css b/src/static/lib/tuicss/tuicss.min.css similarity index 100% rename from static/lib/tuicss/tuicss.min.css rename to src/static/lib/tuicss/tuicss.min.css diff --git a/static/lib/tuicss/tuicss.min.js b/src/static/lib/tuicss/tuicss.min.js similarity index 100% rename from static/lib/tuicss/tuicss.min.js rename to src/static/lib/tuicss/tuicss.min.js diff --git a/templates/index.html b/src/templates/index.html similarity index 100% rename from templates/index.html rename to src/templates/index.html diff --git a/tests/test_rendering.nim b/tests/test_rendering.nim index 9b6959b..f5519c5 100755 --- a/tests/test_rendering.nim +++ b/tests/test_rendering.nim @@ -1,7 +1,7 @@ import std/[os, strutils, unittest] import ../src/luxtools -const indexTemplate = staticRead("../templates/index.html") +const indexTemplate = staticRead("../src/templates/index.html") suite "rendering helpers": test "counter markup references hx attributes": @@ -19,6 +19,6 @@ suite "rendering helpers": check not indexTemplate.contains("unpkg.com/htmx") check not indexTemplate.contains("unpkg.com/tui-css") - test "demo asset lives in www directory": - let assetPath = joinPath(getAppDir(), "..", "www", "demo.txt") + test "demo asset lives in assets directory": + let assetPath = joinPath(getAppDir(), "..", "assets", "demo.txt") check fileExists(assetPath)