From 4f1ef02897b9bc39a6f9e2b5a9a97de672b62623 Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Sun, 14 Jan 2024 19:50:52 +0100 Subject: Docs, pretty template, more info in `new` and `init` --- README.md | 36 +++++++++++++++++++++++++++++--- src/main.rs | 11 ++++++++++ templates/index.luax | 41 ++++++++++++++++++++++++++---------- templates/style.css | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 14 deletions(-) create mode 100644 templates/style.css diff --git a/README.md b/README.md index 357938b..1f44a83 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,38 @@ # reluax -`reluax` is a Rust webserver that generates its pages through LuaX, an extended -form of Lua with support for inline HTML that gets preprocessed into tables. +`reluax` lets you easily create dynamic websites in a custom dialect of Lua, +inspired by JSX. The service has been written in Rust, and uses `luajit` as +its Lua runtime for performance and ease of integration of other libraries. + +## Requirements +- `luajit` + +## Installation +This project is available through GitHub releases as a prebuild binary, or +from `crates.io` through `cargo install reluax`, if you have the Rust +toolchain installed. Alternatively, it is packaged as a Nix flake: +if you have Nix installed, you can `nix run github:Duckonaut/reluax`. + +## Usage +``` +Commands: + serve Serve a directory of LuaX files in production mode + build Build a directory of LuaX files + dev Serve a directory of LuaX files in development mode + new Create a new project + init Initialize a new project in the current directory + help Print this message or the help of the given subcommand(s) + +Options: + -h, --help Print help + +Examples: + reluax serve + reluax dev -P public/ -C luax/ +``` + +To create an example project, run `reluax new my-first-project`. ## Inspiration -The project was heavily, heavily inspired by Ben Visness' blog post, +The project was heavily inspired by Ben Visness' blog post, [I made JSX for Lua (because I hate static sites)](https://bvisness.me/luax/), which I highly recommend reading. diff --git a/src/main.rs b/src/main.rs index 058ce05..9715ef6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -300,6 +300,12 @@ fn create_project(name: &str) -> Result<()> { println!("🌴 Created project {}", name.bright_yellow()); + println!( + "🛠️ To start a development server, change to the {} directory and run {}.", + name.bright_yellow(), + "reluax dev".bright_green() + ); + Ok(()) } @@ -317,6 +323,11 @@ fn init_project() -> Result<()> { println!("🌴 Initialized project {}", name.bright_yellow()); + println!( + "🛠️ To start a development server, run {}.", + "reluax dev".bright_green() + ); + Ok(()) } diff --git a/templates/index.luax b/templates/index.luax index 6785491..7104964 100644 --- a/templates/index.luax +++ b/templates/index.luax @@ -1,14 +1,33 @@ return function() - return - - PROJECT_NAME - - -

PROJECT_NAME

-

Random number for you: {$ tostring(math.floor(math.random() * 100)) $}

-

- What font size is this? -

- + local font_sizes = { 12, 14, 18, 24 } + local font_size = font_sizes[math.floor(math.random() * #font_sizes) + 1] + return + + + + + + PROJECT_NAME + + +
+

PROJECT_NAME

+

+ Welcome to PROJECT_NAME! +

+

+ This project runs on + Reluax. +

+

+ Random number for you: + {$ tostring(math.floor(math.random() * 100)) $} +

+

+ What font size is this? +

+
+ end diff --git a/templates/style.css b/templates/style.css new file mode 100644 index 0000000..d770cea --- /dev/null +++ b/templates/style.css @@ -0,0 +1,59 @@ +:root { + font-weight: 400; + + color-scheme: dark; + color: var(--color-fg); + background-color: var(--color-bg); + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; + + /* variables */ + --color-bg: #161f30; + --color-fg: #a3b3d9; + --color-light-blue: #a3b3d9; + --color-yellow: #e5c07b; +} + +#app-main { + max-width: 1280px; + margin: 0 auto; + padding: 1rem 1rem 1rem 1rem; + text-align: center; + font-family: Hack, monospace; +} + +h1 { + font-size: 30pt; + color: var(--color-yellow); + text-align: center; + font-weight: bold; +} + +.project { + color: var(--color-light-blue); +} + +.description { + font-size: 15pt; + text-align: center; + font-family: "Trebuchet MS", Helvetica, sans-serif; + font-weight: bold; +} + +.rand, .reluax { + color: var(--color-yellow); +} + +a:link { + color: var(--color-light-blue); + text-decoration: none; +} + +a:visited { + color: var(--color-light-blue); + text-decoration: none; +} -- cgit v1.3.1