2025-07-20 02:49:01 -04:00
|
|
|
(text "{% extends \"root.lisp\" %} {% block head %}")
|
|
|
|
(title
|
|
|
|
(text "{{ name }}"))
|
2025-07-21 02:11:23 -04:00
|
|
|
(link ("rel" "icon") ("href" "/public/favicon.svg"))
|
2025-07-20 02:49:01 -04:00
|
|
|
(text "{% endblock %} {% block body %}")
|
|
|
|
(div
|
|
|
|
("class" "flex items-center bar")
|
|
|
|
(button
|
|
|
|
("class" "button tab_button")
|
|
|
|
("id" "editor_tab_button")
|
|
|
|
("onclick" "tab_editor()")
|
|
|
|
(text "Edit"))
|
|
|
|
(button
|
|
|
|
("class" "button camo tab_button")
|
|
|
|
("id" "preview_tab_button")
|
|
|
|
("onclick" "tab_preview()")
|
2025-07-21 02:11:23 -04:00
|
|
|
(text "Preview"))
|
|
|
|
(button
|
|
|
|
("class" "button camo tab_button")
|
|
|
|
("id" "metadata_tab_button")
|
|
|
|
("onclick" "tab_metadata()")
|
|
|
|
(text "Metadata")))
|
2025-07-20 02:49:01 -04:00
|
|
|
(div
|
|
|
|
("class" "card tab tabs")
|
|
|
|
(div
|
|
|
|
("id" "editor_tab")
|
|
|
|
("class" "tab fadein"))
|
|
|
|
(div
|
|
|
|
("id" "preview_tab")
|
2025-07-21 02:11:23 -04:00
|
|
|
("class" "tab fadein hidden container"))
|
|
|
|
(div
|
|
|
|
("id" "metadata_tab")
|
2025-07-20 02:49:01 -04:00
|
|
|
("class" "tab fadein hidden")))
|
|
|
|
(form
|
|
|
|
("class" "w-full flex justify-between gap-2 flex-collapse-rev")
|
|
|
|
("style" "margin-top: var(--pad-2)")
|
|
|
|
("onsubmit" "create_entry(event)")
|
|
|
|
(button
|
|
|
|
("class" "button")
|
|
|
|
(text "Go"))
|
|
|
|
(div
|
|
|
|
("class" "flex gap-2")
|
|
|
|
(input
|
|
|
|
("class" "w-full")
|
|
|
|
("type" "text")
|
|
|
|
("minlength" "2")
|
|
|
|
("name" "edit_code")
|
|
|
|
("placeholder" "Custom edit code"))
|
|
|
|
(input
|
|
|
|
("class" "w-full")
|
|
|
|
("type" "text")
|
|
|
|
("minlength" "2")
|
|
|
|
("maxlength" "32")
|
|
|
|
("name" "slug")
|
2025-07-20 20:43:01 -04:00
|
|
|
("oninput" "check_exists_input(event)")
|
2025-07-20 02:49:01 -04:00
|
|
|
("placeholder" "Custom url"))))
|
|
|
|
(text "{{ components::footer() }}")
|
|
|
|
|
|
|
|
; editor
|
|
|
|
(script ("src" "https://unpkg.com/codemirror@5.39.2/lib/codemirror.js"))
|
|
|
|
(script ("src" "https://unpkg.com/codemirror@5.39.2/mode/markdown/markdown.js"))
|
|
|
|
(script ("src" "https://unpkg.com/codemirror@5.39.2/addon/display/placeholder.js"))
|
|
|
|
(link ("rel" "stylesheet") ("href" "https://unpkg.com/codemirror@5.39.2/lib/codemirror.css"))
|
|
|
|
(script ("src" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"))
|
|
|
|
(link ("rel" "stylesheet") ("href" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css"))
|
|
|
|
|
|
|
|
(script
|
|
|
|
(text "setTimeout(() => {
|
|
|
|
globalThis.init_editor();
|
2025-07-21 02:11:23 -04:00
|
|
|
globalThis.init_editor(\"metadata_editor\", \"plain\", \"metadata_tab\");
|
2025-07-20 02:49:01 -04:00
|
|
|
}, 150);
|
|
|
|
|
|
|
|
globalThis.create_entry = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
fetch(\"/api/v1/entries\", {
|
|
|
|
method: \"POST\",
|
|
|
|
headers: {
|
|
|
|
\"Content-Type\": \"application/json\",
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
content: globalThis.editor.getValue(),
|
|
|
|
slug: e.target.slug.value || undefined,
|
|
|
|
edit_code: e.target.edit_code.value || undefined,
|
2025-07-21 02:11:23 -04:00
|
|
|
metadata: globalThis.metadata_editor.getValue(),
|
2025-07-20 02:49:01 -04:00
|
|
|
}),
|
|
|
|
})
|
|
|
|
.then(res => res.json())
|
|
|
|
.then((res) => {
|
|
|
|
if (res.ok) {
|
2025-07-20 03:24:55 -04:00
|
|
|
globalThis.ALLOW_LEAVE = true;
|
2025-07-20 02:49:01 -04:00
|
|
|
document.cookie = `Atto-Message=\"Entry created! Your edit code: <code>${res.payload[1]}</code>.\"; path=/`;
|
|
|
|
document.cookie = \"Atto-Message-Good=true; path=/\";
|
|
|
|
window.location.href = `/${res.payload[0]}`;
|
|
|
|
} else {
|
2025-07-21 02:11:23 -04:00
|
|
|
show_message(res.message, false);
|
2025-07-20 02:49:01 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}"))
|
|
|
|
(text "{% endblock %}")
|