form
This commit is contained in:
parent
85962a8ff2
commit
63d78a1772
5 changed files with 122 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
19
schema.sql
19
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)
|
||||
|
|
30
src/main.rs
30
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 = "<tag>")]
|
||||
fn handle_register(tag: Form<TagForm>) -> Template {
|
||||
println!("register: {:?}", tag);
|
||||
Template::render("register", context! {})
|
||||
}
|
||||
|
||||
#[get("/profile?<ident>")]
|
||||
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],
|
||||
)
|
||||
}
|
||||
|
|
|
@ -48,24 +48,64 @@
|
|||
|
||||
<div class="fields raised">
|
||||
<div>
|
||||
<label for="name">The entity's name (required)</label>
|
||||
<input type="text" name="name" id="name" required />
|
||||
<p class="note">Remember: names only mean what you want them to!</p>
|
||||
<label for="name">The entity's name and pronouns (required)</label>
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<input type="text" name="name" id="name" required placeholder="A name or callsign" />
|
||||
<p class="note">Remember: names only mean what you want them to!</p>
|
||||
</div>
|
||||
<div>
|
||||
<input class="pronoun" type="text" name="pronoun_subject" required maxlength="255" placeholder="they" /> /
|
||||
<input class="pronoun" type="text" name="pronoun_object" required maxlength="255" placeholder="them" /> /
|
||||
<input class="pronoun" type="text" name="pronoun_possessive" required maxlength="255" placeholder="theirs" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="handler_name">The handler's name (required)</label>
|
||||
<input type="text" name="handler_name" id="handler_name" required />
|
||||
<label for="handler_name">The handler's name (required) and contact</label>
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<input type="text" name="handler_name" id="handler_name" required placeholder="Another name or callsign" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="url" name="handler_link" id="handler_link" placeholder="E-mails can be entered using mailto:" />
|
||||
<p class="note">Optional, will make the handler's name clickable.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="handler_link">A contact link to the handler (optional)</label>
|
||||
<input type="url" name="handler_link" id="handler_link" placeholder="E-mails can be entered using the syntax mailto:your@email.address" />
|
||||
<p class="note">Optional, will make the handler's name clickable.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h4>Entity description and notable features</h4>
|
||||
<p>
|
||||
Have fun with those inputs; empty ones will not be shown so you can selectively fill them.<br/>
|
||||
You can poke me if you'd like me to add more.
|
||||
</p>
|
||||
|
||||
<div class="fields raised">
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<label for="kind">What kind of entity?</label>
|
||||
<input type="text" name="kind" id="kind" placeholder="Something" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="breed">What breed is it?</label>
|
||||
<input type="text" name="breed" id="breed" placeholder="Mutt :3" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<label for="behaviour">Its general behaviour</label>
|
||||
<input type="text" name="behaviour" id="behaviour" placeholder="Totally independent" />
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<button class="submit" type="submit">Register this tag!</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue