add: cleaner ui, prior view check, audio element, rendering fixes
This commit is contained in:
parent
f215d038b3
commit
cacd992f53
7 changed files with 320 additions and 57 deletions
|
@ -27,17 +27,19 @@
|
|||
("title" "Info")
|
||||
(text "i"))))
|
||||
(div
|
||||
("class" "card tab tabs container")
|
||||
("id" "tabs_group")
|
||||
("class" "flex justify_center tab")
|
||||
(div
|
||||
("id" "editor_tab")
|
||||
("class" "tab fadein"))
|
||||
(div
|
||||
("id" "preview_tab")
|
||||
("class" "tab fadein hidden"))
|
||||
(div
|
||||
("id" "metadata_tab")
|
||||
("class" "tab fadein hidden")))
|
||||
("class" "card tab tabs container w_full")
|
||||
("id" "tabs_group")
|
||||
(div
|
||||
("id" "editor_tab")
|
||||
("class" "tab fadein w_full"))
|
||||
(div
|
||||
("id" "preview_tab")
|
||||
("class" "tab fadein hidden w_full"))
|
||||
(div
|
||||
("id" "metadata_tab")
|
||||
("class" "tab fadein hidden w_full"))))
|
||||
(form
|
||||
("class" "w_full flex flex_col gap_2")
|
||||
("style" "margin-top: var(--pad-2)")
|
||||
|
@ -80,7 +82,8 @@
|
|||
("class" "flex gap_2")
|
||||
(button
|
||||
("class" "button green")
|
||||
(text "Save"))
|
||||
(span ("ui_ident" "text") (text "Save"))
|
||||
(span ("class" "hidden loader no_fill") ("ui_ident" "loader") (text "{{ icon \"loader-circle\" }}")))
|
||||
(a
|
||||
("href" "/{{ entry.slug }}")
|
||||
("class" "button")
|
||||
|
@ -88,12 +91,37 @@
|
|||
|
||||
(button
|
||||
("class" "button red")
|
||||
("ui_ident" "delete")
|
||||
(text "Delete"))))
|
||||
("type" "button")
|
||||
("onclick" "document.getElementById('delete_modal').showModal()")
|
||||
("id" "fake_delete_button")
|
||||
(span ("ui_ident" "text") (text "Delete"))
|
||||
(span ("class" "hidden loader no_fill") ("ui_ident" "loader") (text "{{ icon \"loader-circle\" }}")))
|
||||
|
||||
(dialog
|
||||
("id" "delete_modal")
|
||||
(div
|
||||
("class" "inner")
|
||||
(h2 ("class" "text_center w_full") (text "Delete {{ entry.slug }}?"))
|
||||
(p (text "Deleting this entry will make its custom slug claimable by anyone."))
|
||||
(p (text "Please ensure that you understand the consequences of deleting this entry before continuing."))
|
||||
(hr ("class" "margin"))
|
||||
(div
|
||||
("class" "w_full flex gap_2 justify_between")
|
||||
(button
|
||||
("class" "button")
|
||||
("type" "button")
|
||||
("onclick" "document.getElementById('delete_modal').close()")
|
||||
(text "Cancel"))
|
||||
(button
|
||||
("class" "button red")
|
||||
("ui_ident" "delete")
|
||||
("onclick" "document.getElementById('delete_modal').close()")
|
||||
(text "Delete")))))))
|
||||
|
||||
; 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/mode/toml/toml.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"))
|
||||
|
@ -105,16 +133,15 @@
|
|||
(script
|
||||
(text "setTimeout(() => {
|
||||
globalThis.init_editor();
|
||||
globalThis.init_editor(\"metadata_editor\", \"plain\", \"metadata_tab\", \"editor_metadata_content\");
|
||||
globalThis.init_editor(\"metadata_editor\", \"toml\", \"metadata_tab\", \"editor_metadata_content\");
|
||||
}, 150);
|
||||
|
||||
globalThis.edit_entry = (e) => {
|
||||
e.preventDefault();
|
||||
const rm = e.submitter.getAttribute(\"ui_ident\") === \"delete\";
|
||||
|
||||
if (rm && !confirm(\"Are you sure you want to do this?\")) {
|
||||
return;
|
||||
}
|
||||
const { load, failed } = submitter_load(rm ? document.getElementById(\"fake_delete_button\") : e.submitter);
|
||||
load();
|
||||
|
||||
fetch(\"/api/v1/entries/{{ entry.slug }}\", {
|
||||
method: \"POST\",
|
||||
|
@ -147,7 +174,36 @@
|
|||
}
|
||||
} else {
|
||||
show_message(res.message, false);
|
||||
failed();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
globalThis.download = (content, type, name) => {
|
||||
const blob = new Blob([content], { type });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const anchor = document.createElement(\"a\");
|
||||
|
||||
anchor.setAttribute(\"download\", name);
|
||||
anchor.href = url;
|
||||
anchor.click();
|
||||
anchor.remove();
|
||||
}"))
|
||||
(text "{% endblock %}")
|
||||
|
||||
(text "{% block dropdown %}")
|
||||
(hr)
|
||||
(span ("class" "title") (text "export"))
|
||||
(button
|
||||
("class" "button")
|
||||
("onclick" "download(globalThis.editor.getValue(), 'text/markdown', '{{ entry.slug }}.md')")
|
||||
(text "markdown"))
|
||||
(button
|
||||
("class" "button")
|
||||
("onclick" "download(globalThis.metadata_editor.getValue(), 'application/toml', '{{ entry.slug }}.toml')")
|
||||
(text "metadata"))
|
||||
(button
|
||||
("class" "button")
|
||||
("onclick" "(async () => { download(await get_preview(), 'text/html', '{{ entry.slug }}.html') })();")
|
||||
(text "html"))
|
||||
(text "{%- endblock %}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue