diff --git a/Cargo.lock b/Cargo.lock index 06595f5..4d690b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -253,6 +253,24 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" +[[package]] +name = "form-generator" +version = "0.1.0" +dependencies = [ + "anyhow", + "askama", + "axum", + "chrono", + "serde", + "serde_json", + "tokio", + "toml", + "tower-http", + "tower_governor", + "tracing", + "tracing-subscriber", +] + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -697,24 +715,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "polar-pigeons-form" -version = "0.1.0" -dependencies = [ - "anyhow", - "askama", - "axum", - "chrono", - "serde", - "serde_json", - "tokio", - "toml", - "tower-http", - "tower_governor", - "tracing", - "tracing-subscriber", -] - [[package]] name = "portable-atomic" version = "1.11.1" diff --git a/Cargo.toml b/Cargo.toml index fd736f4..61dc111 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "polar-pigeons-form" +name = "form-generator" version = "0.1.0" edition = "2024" diff --git a/README.md b/README.md new file mode 100644 index 0000000..61c4905 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Form Generator + +A lightweight application for generating dynamic form websites and storing user responses. The form fields, labels, and behavior are fully configurable via a TOML configuration file. + +## Usage + +The server will listen on `127.0.0.1:8081` by default. You can override with: + +```bash +SERVER_PORT=8082 form-generator +``` + +## Configuration + +The application is configured via a TOML file (default: `config.toml`). + +See [config.toml](./config.toml) for an example. + +### Configuration Fields + +* `json_output`: Path to the JSON file where responses are stored. + +* `submit_button`: Text displayed on the form’s submit button. + +* `fields`: List of form fields + * `name`: Internal key for storage. + * `title`: Label displayed in the form. + * `description`: Short description displayed below the field. + * `answer_type`: Type of input (`text`, `number`, `email`, `password`, `url`, `tel`, `textarea`). + * `html_before` (optional): HTML snippet rendered before the field. + * `html_after` (optional): HTML snippet rendered after the field. diff --git a/answers.json b/answers.json new file mode 100644 index 0000000..9956459 --- /dev/null +++ b/answers.json @@ -0,0 +1,15 @@ +[ + { + "timestamp": "2025-12-01T17:58:25.865893826Z", + "answers": { + "about_you": "", + "password": "!Y%5#yH^QcZmwHR", + "age": "", + "favorite_color": "", + "email": "foobar@mail.com", + "website": "", + "full_name": "", + "contact_number": "" + } + } +] \ No newline at end of file diff --git a/config.toml b/config.toml index 8b92ce6..013c084 100644 --- a/config.toml +++ b/config.toml @@ -1,41 +1,53 @@ json_output = "answers.json" +submit_button = "Send" [[fields]] name = "full_name" +title = "Full Name" description = "Your full name" answer_type = "text" +html_before = "