tetratto/crates/app/src/public/html/forge/home.lisp
2025-08-03 23:24:57 -04:00

80 lines
2.6 KiB
Common Lisp

(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "Forge - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav(selected=\"\") }}")
(main
("class" "flex flex_col gap_2")
; create new
(text "{% if user.secondary_permissions|has_dev_pass -%}")
(div
("class" "card_nest")
(div
("class" "card small")
(b
(text "{{ text \"forge:label.create_new\" }}")))
(form
("class" "card flex flex_col gap_2")
("onsubmit" "create_community_from_form(event)")
(div
("class" "flex flex_col gap_1")
(label
("for" "title")
(text "{{ text \"communities:label.name\" }}"))
(input
("type" "text")
("name" "title")
("id" "title")
("placeholder" "name")
("required" "")
("minlength" "2")
("maxlength" "32")))
(button
(text "{{ text \"communities:action.create\" }}"))))
(text "{% else %}")
(text "{{ components::developer_pass_ad(body=\"Get a developer pass to create forges!\") }}")
(text "{%- endif %}")
; forge listing
(div
("class" "card_nest")
(div
("class" "card small flex items_center gap_2")
(icon (text "anvil"))
(str (text "forge:label.my_forges")))
(div
("class" "card flex flex_col gap_2")
(text "{% for item in list %} {{ components::community_listing_card(community=item) }} {% endfor %}"))))
(script
(text "async function create_community_from_form(e) {
e.preventDefault();
await trigger(\"atto::debounce\", [\"communities::create\"]);
fetch(\"/api/v1/communities\", {
method: \"POST\",
headers: {
\"Content-Type\": \"application/json\",
},
body: JSON.stringify({
title: e.target.title.value,
forge: true
}),
})
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
if (res.ok) {
e.target.reset();
setTimeout(() => {
window.location.href = `/forge/${res.payload}`;
}, 100);
}
});
}"))
(text "{% endblock %}")