From 63d78a17727ca72faef32f04657a0b54784d6d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=C3=A9mis?= Date: Fri, 10 Jan 2025 15:20:21 +0100 Subject: [PATCH] form --- README.md | 3 ++ assets/site.css | 31 ++++++++++++++++++- schema.sql | 19 +++++++----- src/main.rs | 30 ++++++++++++++++++- templates/register.html.tera | 58 ++++++++++++++++++++++++++++++------ 5 files changed, 122 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 625decb..56ead21 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,6 @@ a profile is # TODOs - privacy policy and GDPR notice +- saving register form as it gets filled / re-display it with partial values +- form submit errors +- tag password to allow editing diff --git a/assets/site.css b/assets/site.css index 91a75cd..8018a90 100644 --- a/assets/site.css +++ b/assets/site.css @@ -95,6 +95,19 @@ section { border-left: 2pt solid var(--clr-primary-a0); } +div.dual-fields { + display: flex; +} +.dual-fields>* { + flex: 1; +} +.dual-fields>*:first-child { + margin-right: 1em; +} +.dual-fields>*:last-child { + margin-left: 1em; +} + .raised { background-color: var(--clr-surface-tonal-a10); padding: 1em; @@ -104,7 +117,7 @@ section { .fields>*:not(:last-child) { margin-bottom: 1em; } -.fields>*>* { +.fields>* * { display: block; width: 100% } @@ -113,11 +126,27 @@ section { margin-bottom: 4pt; } +.checkbox>* { + display: inline-block; + width: unset; +} + +input.pronoun { + display: inline-block; + width: 10ch; +} + p.note { margin: 2pt 0 0 0; font-size: .9em; } +button.submit { + margin: 2em auto; + font-size: 1.2em; + display: block; +} + #stray-form { display: flex; flex-direction: column; diff --git a/schema.sql b/schema.sql index d61bb1e..02c4d00 100644 --- a/schema.sql +++ b/schema.sql @@ -1,25 +1,28 @@ -- base schema +-- notnulls are tmp till i deal with proper validation create table doll_profiles ( id uuid not null primary key, - public_id integer not null, -- 000-000 format + public_id char(6) not null, -- 000000 format created_at timestamptz not null default current_timestamp, updated_at timestamptz, -- base info name varchar(255) not null, - pronouns varchar(255) not null, -- not sure about this format + pronouns varchar(255) not null, -- format as `{subject}/{object}/{possessive}` eg `she/her/hers` + handler_name text not null, handler_url text not null, -- customisation options for various entities - kind varchar(255), - breed varchar(255), - chassis_type varchar(255), - chassis_id varchar(255), - chassis_color varchar(255), + description text not null, + kind varchar(255) not null, + breed varchar(255) not null, + chassis_type varchar(255) not null, + chassis_id varchar(255) not null, + chassis_color varchar(255) not null, -- ID'ing - behaviour varchar(255), + behaviour varchar(255) not null, microchipped boolean not null, unique (public_id) diff --git a/src/main.rs b/src/main.rs index 51f2e68..85ecb2b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #[macro_use] extern crate rocket; +use rocket::form::Form; use rocket::fs::{relative, FileServer}; use rocket_dyn_templates::{context, Template}; @@ -13,6 +14,30 @@ fn show_register() -> Template { Template::render("register", context! {}) } +// TODO: Validation +#[derive(Debug, FromForm)] +struct TagForm { + pub ident: String, + + pub name: String, + pub pronoun_subject: String, + pub pronoun_object: String, + pub pronoun_possessive: String, + + pub handler_name: String, + pub handler_link: String, + + pub kind: String, + pub breed: String, + pub behaviour: String, +} + +#[post("/register", data = "")] +fn handle_register(tag: Form) -> Template { + println!("register: {:?}", tag); + Template::render("register", context! {}) +} + #[get("/profile?")] fn show_profile(ident: &str) -> Template { Template::render( @@ -28,5 +53,8 @@ fn rocket() -> _ { rocket::build() .attach(Template::fairing()) .mount("/assets", FileServer::from(relative!("/assets"))) - .mount("/", routes![index, show_profile, show_register]) + .mount( + "/", + routes![index, show_profile, show_register, handle_register], + ) } diff --git a/templates/register.html.tera b/templates/register.html.tera index 689ecc2..1bcd98e 100644 --- a/templates/register.html.tera +++ b/templates/register.html.tera @@ -48,24 +48,64 @@
- - -

Remember: names only mean what you want them to!

+ +
+
+ +

Remember: names only mean what you want them to!

+
+
+ / + / + +
+
- - + +
+
+ +
+
+ +

Optional, will make the handler's name clickable.

+
+
-
- - -

Optional, will make the handler's name clickable.

Entity description and notable features

+

+ Have fun with those inputs; empty ones will not be shown so you can selectively fill them.
+ You can poke me if you'd like me to add more. +

+ +
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +