Initial
This commit is contained in:
commit
94cec33b46
8 changed files with 1011 additions and 0 deletions
87
app/templates_src/index.lisp
Normal file
87
app/templates_src/index.lisp
Normal file
|
@ -0,0 +1,87 @@
|
|||
(text "{% extends \"root.lisp\" %} {% block head %}")
|
||||
(title
|
||||
(text "{{ name }}"))
|
||||
(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()")
|
||||
(text "Preview")))
|
||||
(div
|
||||
("class" "card tab tabs")
|
||||
(div
|
||||
("id" "editor_tab")
|
||||
("class" "tab fadein"))
|
||||
(div
|
||||
("id" "preview_tab")
|
||||
("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")
|
||||
("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();
|
||||
}, 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,
|
||||
}),
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
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 {
|
||||
document.cookie = `Atto-Message=\"${res.message}\"; path=/`;
|
||||
check_message();
|
||||
}
|
||||
})
|
||||
}"))
|
||||
(text "{% endblock %}")
|
Loading…
Add table
Add a link
Reference in a new issue