From 92bc42436111860187b5f99e0db0c76cfd767aa6 Mon Sep 17 00:00:00 2001 From: trisua Date: Wed, 20 Aug 2025 00:37:00 -0400 Subject: [PATCH] chore: clean up repo --- app/public/app.js | 189 +---------------------------- app/public/style.css | 151 ----------------------- app/templates_src/claim.lisp | 39 ------ app/templates_src/doc.lisp | 13 -- app/templates_src/edit.lisp | 209 -------------------------------- app/templates_src/index.lisp | 109 +---------------- app/templates_src/password.lisp | 32 ----- app/templates_src/root.lisp | 15 +-- app/templates_src/view.lisp | 94 -------------- app/templates_src/warning.lisp | 54 --------- src/main.rs | 2 +- 11 files changed, 7 insertions(+), 900 deletions(-) delete mode 100644 app/templates_src/claim.lisp delete mode 100644 app/templates_src/doc.lisp delete mode 100644 app/templates_src/edit.lisp delete mode 100644 app/templates_src/password.lisp delete mode 100644 app/templates_src/view.lisp delete mode 100644 app/templates_src/warning.lisp diff --git a/app/public/app.js b/app/public/app.js index 47d2625..b74d6b2 100644 --- a/app/public/app.js +++ b/app/public/app.js @@ -63,8 +63,8 @@ function get_cookie(key) { function check_message() { const element = document.getElementById("messages"); - const message = get_cookie("Atto-Message"); - const message_good = get_cookie("Atto-Message-Good") === "true"; + const message = get_cookie("App-Message"); + const message_good = get_cookie("App-Message-Good") === "true"; if (message) { element.style.marginBottom = "1rem"; @@ -88,151 +88,6 @@ globalThis.show_message = (message, message_good = true) => { check_message(); -// editor -globalThis.init_editor = ( - name = "editor", - mode = "markdown", - element = "editor_tab", - content_element = "editor_content", -) => { - globalThis[name] = CodeMirror(document.getElementById(element), { - value: (document.getElementById(content_element) || { innerHTML: "" }) - .innerHTML, - mode, - lineWrapping: true, - lineNumbers: false, - autoCloseBrackets: true, - autofocus: true, - viewportMargin: Number.POSITIVE_INFINITY, - inputStyle: "contenteditable", - highlightFormatting: false, - fencedCodeBlockHighlighting: false, - xml: false, - smartIndent: false, - indentUnit: 4, - tabSize: 4, - indentWithTabs: false, - placeholder: "", - extraKeys: { - Home: "goLineLeft", - End: "goLineRight", - Enter: (cm) => { - cm.replaceSelection("\n"); - }, - Tab: "insertSoftTab", - }, - }); - - if (name === "editor") { - window.addEventListener("beforeunload", (e) => { - if (!globalThis.ALLOW_LEAVE) { - e.preventDefault(); - return null; - } - }); - } -}; - -globalThis.tab_editor = () => { - document.getElementById("editor_tab").classList.remove("hidden"); - document.getElementById("preview_tab").classList.add("hidden"); - document.getElementById("metadata_tab").classList.add("hidden"); - - document.getElementById("editor_tab_button").classList.remove("camo"); - document.getElementById("preview_tab_button").classList.add("camo"); - document.getElementById("metadata_tab_button").classList.add("camo"); - - if (document.getElementById("metadata_css")) { - document.getElementById("metadata_css").remove(); - } -}; - -globalThis.get_preview = async () => { - return await ( - await fetch("/api/v1/render", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - content: globalThis.editor.getValue(), - metadata: globalThis.metadata_editor.getValue(), - }), - }) - ).text(); -}; - -globalThis.tab_preview = async () => { - if ( - !document - .getElementById("preview_tab_button") - .classList.contains("camo") - ) { - return; - } - - // render - const res = await get_preview(); - - document.getElementById("preview_tab").innerHTML = res; - hljs.highlightAll(); - - // ... - document.getElementById("editor_tab").classList.add("hidden"); - document.getElementById("preview_tab").classList.remove("hidden"); - document.getElementById("metadata_tab").classList.add("hidden"); - - document.getElementById("editor_tab_button").classList.add("camo"); - document.getElementById("preview_tab_button").classList.remove("camo"); - document.getElementById("metadata_tab_button").classList.add("camo"); -}; - -globalThis.first_time_on_metadata_tab = true; -globalThis.tab_metadata = () => { - document.getElementById("editor_tab").classList.add("hidden"); - document.getElementById("preview_tab").classList.add("hidden"); - document.getElementById("metadata_tab").classList.remove("hidden"); - - document.getElementById("editor_tab_button").classList.add("camo"); - document.getElementById("preview_tab_button").classList.add("camo"); - document.getElementById("metadata_tab_button").classList.remove("camo"); - - if (globalThis.first_time_on_metadata_tab) { - globalThis.metadata_editor.refresh(); - } - - globalThis.first_time_on_metadata_tab = false; -}; - -let exists_timeout = null; -globalThis.check_exists_input = (e) => { - if (exists_timeout) { - clearTimeout(exists_timeout); - } - - exists_timeout = setTimeout(async () => { - if (e.target.value.length < 2 || e.target.value.length > 32) { - e.target.setCustomValidity(""); - e.target.removeAttribute("data-invalid"); - e.target.reportValidity(); - return; - } - - const exists = ( - await (await fetch(`/api/v1/entries/${e.target.value}`)).json() - ).payload; - - console.log(exists); - if (exists) { - e.target.setCustomValidity("Slug is already in use"); - e.target.setAttribute("data-invalid", "true"); - } else { - e.target.setCustomValidity(""); - e.target.removeAttribute("data-invalid"); - } - - e.target.reportValidity(); - }, 1000); -}; - // components function close_dropdowns() { for (const dropdown of Array.from( @@ -314,46 +169,6 @@ globalThis.init_dropdowns = (bind_to) => { }); }; -globalThis.METADATA_CSS_ENABLED = true; -globalThis.toggle_metadata_css = (e) => { - e.target.classList.add("yellow"); - - METADATA_CSS_ENABLED = !METADATA_CSS_ENABLED; - if (!METADATA_CSS_ENABLED) { - media_theme_pref(); // user user theme - document.getElementById("metadata_css").remove(); // remove css - - // reset colored text - for (const element of Array.from( - document.querySelectorAll("#content_rect .color_block"), - )) { - element.removeAttribute("style"); - element.classList.remove("color_block"); - } - - // strikethrough auto theme since it's disabled - if (document.getElementById("auto_theme")) { - document.getElementById("auto_theme").style.textDecoration = - "line-through"; - } - - // remove styles - for (const element of Array.from( - document.querySelectorAll("#content_rect style"), - )) { - element.remove(); - } - - for (const element of Array.from( - document.querySelectorAll("#content_rect [style]"), - )) { - element.removeAttribute("style"); - } - } else { - window.location.reload(); - } -}; - globalThis.hash_check = (hash) => { if (hash.startsWith("#/")) { for (const x of Array.from(document.querySelectorAll(".subpage"))) { diff --git a/app/public/style.css b/app/public/style.css index 1cf9f64..1b39b76 100644 --- a/app/public/style.css +++ b/app/public/style.css @@ -580,157 +580,6 @@ span { font-size: inherit; } -/* codemirror/hljs */ -.CodeMirror { - color: var(--color-text) !important; -} - -.CodeMirror { - background: transparent !important; - font-family: inherit !important; - height: 10rem !important; - min-height: 100%; - max-height: 100%; - cursor: text; -} - -.CodeMirror-cursor { - border-color: rgb(0, 0, 0) !important; -} - -.CodeMirror-cursor:is(.dark *) { - border-color: rgb(255, 255, 255) !important; -} - -.CodeMirror-cursor { - height: 22px !important; -} - -[role="presentation"]::-moz-selection, -[role="presentation"] *::-moz-selection { - background-color: rgb(191, 219, 254) !important; -} - -[role="presentation"]::selection, -[role="presentation"] *::selection, -.CodeMirror-selected { - background-color: rgb(191, 219, 254) !important; -} - -[role="presentation"]:is(.dark *)::-moz-selection, -[role="presentation"] *:is(.dark *)::-moz-selection { - background-color: rgb(64, 64, 64) !important; -} - -[role="presentation"]:is(.dark *)::selection, -[role="presentation"] *:is(.dark *)::selection, -.CodeMirror-selected:is(.dark *) { - background-color: rgb(64, 64, 64) !important; -} - -.cm-header { - color: inherit !important; -} - -.cm-variable-2, -.cm-quote, -.cm-keyword, -.cm-string, -.cm-atom, -.hljs-string { - color: rgb(63, 98, 18) !important; -} - -.cm-variable-2:is(.dark *), -.cm-quote:is(.dark *), -.cm-keyword:is(.dark *), -.cm-string:is(.dark *), -.cm-atom:is(.dark *), -.hljs-string:is(.dark *) { - color: rgb(217, 249, 157) !important; -} - -.cm-comment, -.hljs-keyword { - color: oklch(47% 0.157 37.304) !important; -} - -.cm-comment:is(.dark *), -.hljs-keyword:is(.dark *) { - color: oklch(90.1% 0.076 70.697) !important; -} - -.cm-link { - color: var(--color-link) !important; -} - -.cm-url, -.cm-property, -.cm-qualifier, -.hljs-title { - color: rgb(29, 78, 216) !important; -} - -.cm-url:is(.dark *), -.cm-property:is(.dark *), -.cm-qualifier:is(.dark *), -.hljs-title:is(.dark *) { - color: rgb(191, 219, 254) !important; -} - -.cm-variable-3, -.cm-tag, -.cm-def, -.cm-attribute, -.cm-number, -.hljs-type { - color: rgb(91, 33, 182) !important; -} - -.cm-variable-3:is(.dark *), -.cm-tag:is(.dark *), -.cm-def:is(.dark *), -.cm-attribute:is(.dark *), -.cm-number:is(.dark *), -.hljs-type:is(.dark *) { - color: rgb(221, 214, 254) !important; -} - -.hljs-built_in { - color: var(--color-purple) !important; -} - -.hljs-variable { - color: var(--color-link) !important; -} - -.hljs-number { - color: var(--color-green) !important; -} - -.hljs-link { - color: var(--color-link) !important; -} - -.CodeMirror-scroll { - height: 100% !important; -} - -.CodeMirror-line { - padding-left: 0 !important; - font-size: 16px !important; -} - -.CodeMirror-focused .CodeMirror-placeholder { - opacity: 50%; -} - -.hljs { - background: transparent !important; - color: inherit !important; - padding: 0 !important; -} - /* extra */ @keyframes fadein { from { diff --git a/app/templates_src/claim.lisp b/app/templates_src/claim.lisp deleted file mode 100644 index bff9a83..0000000 --- a/app/templates_src/claim.lisp +++ /dev/null @@ -1,39 +0,0 @@ -(text "{% extends \"root.lisp\" %} {% block head %}") -(title - (text "Create reclaim for \"{{ entry.slug }}\" - {{ name }}")) -(link ("rel" "icon") ("href" "/public/favicon.svg")) -(text "{% endblock %} {% block body %}") -(div - ("class" "card container") - (h1 (text "{{ entry.slug }}")) - (p (text "Custom slug reclaims are handled through ") (b (text "{{ tetratto }}")) (text ". You'll need to have an account there to submit a claim request.")) - (p (text "Please note that you are unlikely to receive a response unless your claim is accepted. Please do not submit additional requests for the same slug.")) - - (text "{% if metadata.tetratto_owner_username -%}") - ; contact owner text - (p (text "Since this entry is connected to a user, it is encouraged that you directly contact the owner of the entry instead. If that doesn't work, you can create a regular request.")) - (text "{%- endif %}") - - (p (text "Once you're ready, you can submit a claim using the button below.")) - (hr) - (ul - (li (b (text "Requsted slug: ")) (text "{{ entry.slug }}")) - (li (b (text "Last updated: ")) (text "{{ entry.edited / 1000|int|date(format=\"%Y-%m-%d %H:%M\", timezone=\"Etc/UTC\") }} UTC"))) - (hr) - (text "{% if claimable -%}") - (text "{% if metadata.tetratto_owner_username -%}") - ; contact owner button - (a - ("href" "{{ tetratto }}/mail/compose?receivers={{ tetratto_owner_username }}&subject=Reclaim%20for%20%22{{ entry.slug }}%22") - ("class" "button surface no_fill") - (text "{{ icon \"external-link\" }} Contact owner")) - (text "{%- endif %}") - - (a - ("href" "{{ tetratto }}/mail/compose?receivers={{ tetratto_handler_account_username }}&subject=Reclaim%20for%20%22{{ entry.slug }}%22") - ("class" "button surface no_fill") - (text "{{ icon \"external-link\" }} Submit request")) - (text "{% else %}") - (span (text "This slug is currently not claimable as it was edited too recently. ") (a ("href" "/{{ entry.slug }}") ("class" "red") (text "Go back"))) - (text "{%- endif %}")) -(text "{% endblock %}") diff --git a/app/templates_src/doc.lisp b/app/templates_src/doc.lisp deleted file mode 100644 index bf4df99..0000000 --- a/app/templates_src/doc.lisp +++ /dev/null @@ -1,13 +0,0 @@ -(text "{% extends \"root.lisp\" %} {% block head %}") -(title - (text "{{ file_name }} - {{ name }}")) -(link ("rel" "icon") ("href" "/public/favicon.svg")) -(text "{% endblock %} {% block body %}") -(div - ("class" "card container") - (p (text "{{ text|markdown|safe }}"))) - -(link ("rel" "stylesheet") ("href" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css")) -(script ("src" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js")) -(script (text "hljs.highlightAll();")) -(text "{% endblock %}") diff --git a/app/templates_src/edit.lisp b/app/templates_src/edit.lisp deleted file mode 100644 index 0edfdfb..0000000 --- a/app/templates_src/edit.lisp +++ /dev/null @@ -1,209 +0,0 @@ -(text "{% extends \"root.lisp\" %} {% block head %}") -(title - (text "{{ entry.slug }}")) -(link ("rel" "icon") ("href" "/public/favicon.svg")) -(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")) - (button - ("class" "button camo tab_button") - ("id" "metadata_tab_button") - ("onclick" "tab_metadata()") - (text "Metadata") - (a - ("class" "button simple surface") - ("href" "/docs/metadata") - ("target" "_blank") - ("title" "Info") - (text "i")))) -(div - ("class" "flex justify_center tab") - (div - ("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)") - ("onsubmit" "edit_entry(event)") - (div - ("class" "w_full flex gap_2") - (input - ("class" "w_full") - ("type" "text") - ("minlength" "2") - ("name" "edit_code") - ("required" "") - ("placeholder" "Enter edit code")) - (input ("class" "w_full") ("style" "visibility: hidden") ("aria-hidden" "true") ("disabled" "true")) - (input ("class" "w_full") ("style" "visibility: hidden") ("aria-hidden" "true") ("disabled" "true"))) - (div - ("class" "flex gap_2") - (input - ("class" "w_full") - ("type" "text") - ("minlength" "2") - ("name" "new_edit_code") - ("placeholder" "New edit code")) - (input - ("class" "w_full") - ("type" "text") - ("minlength" "2") - ("name" "new_modify_code") - ("placeholder" "New modify code")) - (input - ("class" "w_full") - ("type" "text") - ("minlength" "2") - ("name" "new_slug") - ("oninput" "check_exists_input(event)") - ("placeholder" "New url"))) - (div - ("class" "w_full flex justify_between gap_2") - (div - ("class" "flex gap_2") - (button - ("class" "button green") - (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") - (text "Back"))) - - (button - ("class" "button red") - ("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")) -(link ("rel" "stylesheet") ("href" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css")) - -(script ("id" "editor_content") ("type" "text/markdown") (text "{{ entry.content|remove_script_tags|safe }}")) -(script ("id" "editor_metadata_content") ("type" "text/markdown") (text "{{ entry.metadata|remove_script_tags|safe }}")) - -(script - (text "setTimeout(() => { - globalThis.init_editor(); - 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\"; - - const { load, failed } = submitter_load(rm ? document.getElementById(\"fake_delete_button\") : e.submitter); - load(); - - fetch(\"/api/v1/entries/{{ entry.id }}\", { - method: \"POST\", - headers: { - \"Content-Type\": \"application/json\", - }, - body: JSON.stringify({ - content: globalThis.editor.getValue(), - edit_code: e.target.edit_code.value, - new_slug: e.target.new_slug.value || undefined, - new_edit_code: e.target.new_edit_code.value || undefined, - new_modify_code: e.target.new_modify_code.value || undefined, - metadata: globalThis.metadata_editor.getValue(), - \"delete\": rm, - }), - }) - .then(res => res.json()) - .then((res) => { - if (res.ok) { - globalThis.ALLOW_LEAVE = true; - - if (!rm) { - document.cookie = `Atto-Message=\"Entry updated\"; path=/`; - document.cookie = \"Atto-Message-Good=true; path=/\"; - window.location.href = `/${res.payload}`; - } else { - document.cookie = `Atto-Message=\"Entry deleted\"; path=/`; - document.cookie = \"Atto-Message-Good=true; path=/\"; - window.location.href = \"/\"; - } - } 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 %}") diff --git a/app/templates_src/index.lisp b/app/templates_src/index.lisp index f425ee0..7ade9be 100644 --- a/app/templates_src/index.lisp +++ b/app/templates_src/index.lisp @@ -6,112 +6,5 @@ (meta ("property" "twitter:title") ("content" "{{ name }}")) (link ("rel" "icon") ("href" "/public/favicon.svg")) (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")) - (button - ("class" "button camo tab_button") - ("id" "metadata_tab_button") - ("onclick" "tab_metadata()") - (text "Metadata") - (a - ("class" "button simple surface") - ("href" "/docs/metadata") - ("target" "_blank") - ("title" "Info") - (text "i")))) -(div - ("class" "flex justify_center tab") - (div - ("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 justify_between gap_2 flex_collapse_rev") - ("style" "margin-top: var(--pad-2)") - ("onsubmit" "create_entry(event)") - (button - ("class" "button") - (span ("ui_ident" "text") (text "Go")) - (span ("class" "hidden loader no_fill") ("ui_ident" "loader") (text "{{ icon \"loader-circle\" }}"))) - (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") - ("oninput" "check_exists_input(event)") - ("placeholder" "Custom url")))) - -; 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")) -(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(); - globalThis.init_editor(\"metadata_editor\", \"toml\", \"metadata_tab\"); - }, 150); - - globalThis.create_entry = (e) => { - e.preventDefault(); - - const { load, failed } = submitter_load(e.submitter); - load(); - - 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, - metadata: globalThis.metadata_editor.getValue(), - }), - }) - .then(res => res.json()) - .then((res) => { - if (res.ok) { - globalThis.ALLOW_LEAVE = true; - document.cookie = `Atto-Message=\"Entry created! Your edit code: ${res.payload[1]}.\"; path=/`; - document.cookie = \"Atto-Message-Good=true; path=/\"; - window.location.href = `/${res.payload[0]}`; - } else { - show_message(res.message, false); - failed(); - } - }) - }")) +(h1 (text "{{ name }}")) (text "{% endblock %}") diff --git a/app/templates_src/password.lisp b/app/templates_src/password.lisp deleted file mode 100644 index 42caaa6..0000000 --- a/app/templates_src/password.lisp +++ /dev/null @@ -1,32 +0,0 @@ -(text "{% extends \"root.lisp\" %} {% block head %}") -(title - (text "{{ entry.slug }}")) -(link ("rel" "icon") ("href" "/public/favicon.svg")) -(text "{% endblock %} {% block body %}") -(main - ("class" "card_nest") - (div - ("class" "card flex items_center gap_2 no_fill") - (text "{{ icon \"lock\" }}") - (b (text "Password required"))) - (form - ("class" "card flex flex_col gap_2") - ("onsubmit" "use_password(event)") - (div - ("class" "flex flex_collapse gap_2") - (input - ("class" "surface") - ("required" "") - ("placeholder" "Password") - ("name" "password")) - (button - ("class" "button surface") - (text "Go"))))) -(script - (text "async function use_password(event) { - event.preventDefault(); - const hash = Array.from(new Uint8Array(await window.crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(event.target.password.value)))); - const hex_hash = hash.map((b) => b.toString(16).padStart(2, \"0\")).join(\"\"); - window.location.href = `?key=h:${hex_hash}`; - }")) -(text "{% endblock %}") diff --git a/app/templates_src/root.lisp b/app/templates_src/root.lisp index 18774d1..6901e4c 100644 --- a/app/templates_src/root.lisp +++ b/app/templates_src/root.lisp @@ -6,7 +6,7 @@ (meta ("name" "viewport") ("content" "width=device-width, initial-scale=1.0")) (meta ("http-equiv" "X-UA-Compatible") ("content" "ie=edge")) - (link ("rel" "stylesheet") ("href" "{{ tetratto }}/css/utility.css?v={{ build_code }}")) + (link ("rel" "stylesheet") ("href" "https://repodelivery.trisua.com/tetratto/crates/app/src/public/css/utility.css")) (link ("rel" "stylesheet") ("href" "/public/style.css?v={{ build_code }}")) (style (text ":root { --color-primary: {{ theme_color }}; }")) @@ -37,22 +37,13 @@ (a ("class" "button") ("href" "/") - (text "new")) - (a - ("class" "button") - ("href" "/{{ what_page_slug }}") - (text "what")) + (text "home")) (a ("class" "button") ("href" "https://trisua.com/t/malachite") (text "source")) (text "{% block dropdown %}{% endblock %}"))) - - (a - ("class" "button camo fade") - ("href" "/") - ("title" "new") - (text "{{ icon \"plus\" }}"))) + (a ("href" "/") (b (text "{{ name }}")))) (div ("class" "side flex") diff --git a/app/templates_src/view.lisp b/app/templates_src/view.lisp deleted file mode 100644 index d06db89..0000000 --- a/app/templates_src/view.lisp +++ /dev/null @@ -1,94 +0,0 @@ -(text "{% extends \"root.lisp\" %} {% block head %}") -(text "{% if not metadata.page_title -%}") -(title - (text "{{ entry.slug }}")) -(text "{%- endif %} {{ metadata_head|safe }}") - -(text "{% if not metadata.share_title -%}") -(meta ("property" "og:title") ("content" "{{ entry.slug }}")) -(meta ("property" "twitter:title") ("content" "{{ entry.slug }}")) -(text "{%- endif %}") - -(text "{% if metadata.page_icon|length == 0 -%}") -(link ("rel" "icon") ("href" "/public/favicon.svg")) -(text "{%- endif %}") -(text "{% endblock %} {% block body %}") -(div - ("class" "flex flex_col gap_2") - (div - ("class" "card container") - ("id" "content_rect") - ("style" "min-height: 15rem") - (text "{{ entry.content|markdown|safe }}")) - (div - ("class" "w_full flex justify_between gap_2") - (a - ("class" "button") - ("href" "/{{ entry.slug }}/edit{% if password -%} ?key={{ password }} {%- endif %}") - (text "Edit")) - - (div - ("class" "flex flex_col gap-1 items-end fade") - ; dates - (span (text "Pub: {{ entry.created / 1000|int|date(format=\"%Y-%m-%d %H:%M\", timezone=\"Etc/UTC\") }} UTC")) - (span (text "Edit: {{ entry.edited / 1000|int|date(format=\"%Y-%m-%d %H:%M\", timezone=\"Etc/UTC\") }} UTC")) - - ; auto theme - (text "{% if metadata.access_recommended_theme != 'None' -%}") - (span ("id" "auto_theme") (text "Auto theme: {{ metadata.access_recommended_theme }}")) - (script ("defer" "true") (text "setTimeout(() => { temporary_set_theme('{{ metadata.access_recommended_theme }}') }, 150);")) - (text "{%- endif %}") - - ; owner - (text "{% if metadata.tetratto_owner_username|length > 0 -%}") - (span - ("class" "flex items_center gap_2") - (text "Owner:") - (a - ("class" "flex items_center gap_2") - ("href" "{{ tetratto }}/@{{ metadata.tetratto_owner_username }}") - (img - ("class" "avatar") - ("src" "{{ tetratto }}/api/v1/auth/user/{{ metadata.tetratto_owner_username }}/avatar?selector_type=username")) - (text "{{ metadata.tetratto_owner_username }}"))) - (text "{%- endif %}") - - ; views - (text "{% if not metadata.option_disable_views -%}") - (span (text "Views: {{ entry.views }}")) - (text "{%- endif %}") - - ; easy-to-read - (text "{% if metadata.access_easy_read|length > 0 -%}") - (a ("class" "button small") ("href" "/{{ metadata.access_easy_read }}") (b (text "E2R"))) - (text "{%- endif %}")))) - -(div ("style" "display: none") ("id" "metadata_css") (text "{{ metadata_css|safe }}")) - -(link ("rel" "stylesheet") ("href" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css")) -(script ("src" "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js")) -(script (text "hljs.highlightAll();")) -(text "{% endblock %}") -(text "{% block nav_extras %}") -(button - ("class" "button camo fade no_fill") - ("title" "Toggle high-contrast") - ("id" "toggle_high_contrast_button") - ("onclick" "toggle_metadata_css(event)") - (text "{{ icon \"contrast\" }}")) - -(text "{% if \"EntryHighContrast\" in flags -%}") -(script - (text "setTimeout(() => { - toggle_metadata_css({ target: document.getElementById(\"toggle_high_contrast_button\") }); - }, 150);")) -(text "{%- endif %}") -(text "{% endblock %}") - -(text "{% block dropdown %}") -(hr) -(a - ("class" "button") - ("href" "/{{ entry.slug }}/claim") - (text "claim")) -(text "{%- endblock %}") diff --git a/app/templates_src/warning.lisp b/app/templates_src/warning.lisp deleted file mode 100644 index 4f058ed..0000000 --- a/app/templates_src/warning.lisp +++ /dev/null @@ -1,54 +0,0 @@ -(text "{% extends \"root.lisp\" %} {% block head %}") -(text "{% if not metadata.page_title -%}") -(title - (text "{{ entry.slug }}")) -(text "{%- endif %} {{ metadata_head|safe }}") - -(text "{% if not metadata.share_title -%}") -(meta ("property" "og:title") ("content" "{{ entry.slug }}")) -(meta ("property" "twitter:title") ("content" "{{ entry.slug }}")) -(text "{%- endif %}") - -(text "{% if metadata.page_icon|length == 0 -%}") -(link ("rel" "icon") ("href" "/public/favicon.svg")) -(text "{%- endif %}") - -(text "{% endblock %} {% block body %}") -(div - ("class" "card container flex flex_col gap-1") - ("id" "content_rect") - (p ("class" "fade") (text "Content warning:")) - (div (text "{{ metadata.safety_content_warning|markdown|safe }}")) - (hr) - (div - ("class" "flex flex_col gap_4") - (label - ("class" "flex flex-row gap_2 items_center") - ("for" "open_in_high_contrast") - (input - ("type" "checkbox") - ("id" "open_in_high_contrast") - ("name" "open_in_high_contrast")) - (span (text "Open in high contrast"))) - (div - ("class" "flex gap_2") - (button - ("class" "button surface green") - ("onclick" "accept()") - (text "Continue")) - (button - ("class" "button surface red") - ("onclick" "window.history.back()") - (text "Cancel"))))) - -(script - (text "const QFLAGS = [\"AcceptWarning\"]; - function accept() { - if (document.getElementById(\"open_in_high_contrast\").checked) { - QFLAGS.push(\"EntryHighContrast\"); - } - - document.cookie = `Atto-QFlags=\"${JSON.stringify(QFLAGS)}\"; path=/`; - window.location.reload(); - }")) -(text "{% endblock %}") diff --git a/src/main.rs b/src/main.rs index 7e3efea..04cdfe8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,7 @@ async fn main() { let port = match var("PORT") { Ok(port) => port.parse::().expect("port should be a u16"), - Err(_) => 9119, + Err(_) => 8020, }; // ...