added README
This commit is contained in:
Generated
+18
-18
@@ -253,6 +253,24 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
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]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.2.2"
|
version = "1.2.2"
|
||||||
@@ -697,24 +715,6 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
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]]
|
[[package]]
|
||||||
name = "portable-atomic"
|
name = "portable-atomic"
|
||||||
version = "1.11.1"
|
version = "1.11.1"
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "polar-pigeons-form"
|
name = "form-generator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -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": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
+27
-15
@@ -1,41 +1,53 @@
|
|||||||
json_output = "answers.json"
|
json_output = "answers.json"
|
||||||
|
submit_button = "Send"
|
||||||
|
|
||||||
[[fields]]
|
[[fields]]
|
||||||
name = "full_name"
|
name = "full_name"
|
||||||
|
title = "Full Name"
|
||||||
description = "Your full name"
|
description = "Your full name"
|
||||||
answer_type = "text"
|
answer_type = "text"
|
||||||
|
html_before = "<h2>Identity</h2>"
|
||||||
|
|
||||||
[[fields]]
|
[[fields]]
|
||||||
name = "age"
|
name = "age"
|
||||||
|
title = "Age"
|
||||||
description = "Your age"
|
description = "Your age"
|
||||||
answer_type = "number"
|
answer_type = "number"
|
||||||
|
|
||||||
[[fields]]
|
[[fields]]
|
||||||
name = "email"
|
name = "email"
|
||||||
|
title = "Email Address"
|
||||||
description = "Your email address"
|
description = "Your email address"
|
||||||
answer_type = "email"
|
answer_type = "email"
|
||||||
|
html_before = "<h2>Contact Info</h2>"
|
||||||
[[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"
|
|
||||||
|
|
||||||
[[fields]]
|
[[fields]]
|
||||||
name = "contact_number"
|
name = "contact_number"
|
||||||
|
title = "Contact Number"
|
||||||
description = "Phone number"
|
description = "Phone number"
|
||||||
answer_type = "tel"
|
answer_type = "tel"
|
||||||
|
|
||||||
|
[[fields]]
|
||||||
|
name = "website"
|
||||||
|
title = "Website"
|
||||||
|
description = "Personal website (optional)"
|
||||||
|
answer_type = "url"
|
||||||
|
html_after = "<h2>More About You</h2>"
|
||||||
|
|
||||||
|
[[fields]]
|
||||||
|
name = "about_you"
|
||||||
|
title = "About You"
|
||||||
|
description = "Tell us about yourself"
|
||||||
|
answer_type = "textarea"
|
||||||
|
|
||||||
[[fields]]
|
[[fields]]
|
||||||
name = "favorite_color"
|
name = "favorite_color"
|
||||||
|
title = "Favorite Color"
|
||||||
description = "Favorite color (text)"
|
description = "Favorite color (text)"
|
||||||
answer_type = "text"
|
answer_type = "text"
|
||||||
|
|
||||||
|
[[fields]]
|
||||||
|
name = "password"
|
||||||
|
title = "Password"
|
||||||
|
description = "Set a password"
|
||||||
|
answer_type = "password"
|
||||||
|
|||||||
Reference in New Issue
Block a user