about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontend/mod.rs14
-rw-r--r--src/frontend/onboarding.js44
2 files changed, 57 insertions, 1 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs
index f14ac75..c92619b 100644
--- a/src/frontend/mod.rs
+++ b/src/frontend/mod.rs
@@ -146,6 +146,20 @@ mod templates {
                     }
 
                     div.form_group {
+                        label[for="urls"] { "Links to other pages of you" }
+                        div.multi_input#urls {
+                            template {
+                                input#hcard_url[name="hcard_url", placeholder="https://example.com/"];
+                            }
+                            button.add_more[type="button", "aria-label"="Add more"] { "[+] Add more" }
+                        }
+                        small {
+                            "These URLs will help your readers find you elsewhere and will help you that whoever owns these pages owns your website too"
+                            " in case the links are mutual. So make sure to put a link to your site in your other social profiles!"
+                        }
+                    }
+
+                    div.form_group {
                         label[for="hcard_note"] { "A little about yourself" }
                         textarea#hcard_note[name="hcard_note", placeholder="Loves cooking, plants, cats, dogs and racoons."] {}
                         small { "A little bit of introduction. Just one paragraph, and note, you can't use HTML here (yet)." }
diff --git a/src/frontend/onboarding.js b/src/frontend/onboarding.js
index 5bb08a1..7f9aa32 100644
--- a/src/frontend/onboarding.js
+++ b/src/frontend/onboarding.js
@@ -42,4 +42,46 @@ Array.from(document.querySelectorAll("form.onboarding > fieldset button.switch_c
 Array.from(document.querySelectorAll("form.onboarding > fieldset div.multi_input > button.add_more")).map(button => {
     button.addEventListener("click", multiInputAddMore)
     multiInputAddMore({ target: button });
-})
\ No newline at end of file
+})
+
+const form = document.querySelector("form.onboarding");
+console.log(form);
+form.onsubmit = async (event) => {
+    console.log(event);
+    event.preventDefault();
+    const form = event.target;
+    const json = {
+        user: {
+            type: ["h-card"],
+            properties: {
+                name: [form.querySelector("#hcard_name").value],
+                pronoun: Array.from(form.querySelectorAll("#hcard_pronouns")).map(input => input.value).filter(i => i != ""),
+                url: Array.from(form.querySelectorAll("#hcard_url")).map(input => input.value).filter(i => i != ""),
+                note: [form.querySelector("#hcard_note").value]
+            }
+        },
+        first_post: {
+            type: ["h-entry"],
+            properties: {
+                content: [form.querySelector("#first_post_content").value]
+            }
+        },
+        blog_name: form.querySelector("#blog_name").value,
+        feeds: Array.from(form.querySelectorAll(".multi_input#custom_feeds > fieldset.feed")).map(form => {
+            return {
+                name: form.querySelector("#feed_name").value,
+                slug: form.querySelector("#feed_slug").value
+            }
+        }).filter(feed => feed.name == "" || feed.slug == "")
+    };
+
+    await fetch("/", {
+        method: "POST",
+        body: JSON.stringify(json),
+        headers: { "Content-Type": "application/json" }
+    }).then(response => {
+        if (response.status == 201) {
+            window.location.href = window.location.href;
+        }
+    })
+}
\ No newline at end of file