From 46c889be59f0d0254ba6b9bcafc20722c9d0ca2e Mon Sep 17 00:00:00 2001 From: eiiko6 Date: Mon, 1 Dec 2025 19:07:30 +0100 Subject: [PATCH] added README --- Cargo.lock | 36 ++++++++++++++++++------------------ Cargo.toml | 2 +- README.md | 31 +++++++++++++++++++++++++++++++ answers.json | 15 +++++++++++++++ config.toml | 42 +++++++++++++++++++++++++++--------------- 5 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 README.md create mode 100644 answers.json 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 = "

Identity

" [[fields]] name = "age" +title = "Age" description = "Your age" answer_type = "number" [[fields]] name = "email" +title = "Email Address" description = "Your email address" answer_type = "email" - -[[fields]] -name = "password" -description = "Set a password" -answer_type = "password" - -[[fields]] -name = "website" -description = "Personal website (optional)" -answer_type = "url" - -[[fields]] -name = "about_you" -description = "Tell us about yourself" -answer_type = "textarea" +html_before = "

Contact Info

" [[fields]] name = "contact_number" +title = "Contact Number" description = "Phone number" answer_type = "tel" +[[fields]] +name = "website" +title = "Website" +description = "Personal website (optional)" +answer_type = "url" +html_after = "

More About You

" + +[[fields]] +name = "about_you" +title = "About You" +description = "Tell us about yourself" +answer_type = "textarea" + [[fields]] name = "favorite_color" +title = "Favorite Color" description = "Favorite color (text)" answer_type = "text" + +[[fields]] +name = "password" +title = "Password" +description = "Set a password" +answer_type = "password"