add: option_source_password and option_view_password
This commit is contained in:
parent
a49efdd238
commit
2de840f50d
5 changed files with 158 additions and 13 deletions
|
@ -180,6 +180,11 @@ video {
|
|||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.card-nest .card:nth-child(1) {
|
||||
background: var(--color-super-raised);
|
||||
padding: var(--pad-2) var(--pad-4);
|
||||
}
|
||||
|
||||
/* button */
|
||||
.button {
|
||||
--h: 36px;
|
||||
|
@ -307,6 +312,10 @@ input[data-invalid] {
|
|||
border-left: inset 5px var(--color-red);
|
||||
}
|
||||
|
||||
input.surface {
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
/* typo */
|
||||
p {
|
||||
margin-bottom: var(--pad-4);
|
||||
|
|
32
app/templates_src/password.lisp
Normal file
32
app/templates_src/password.lisp
Normal file
|
@ -0,0 +1,32 @@
|
|||
(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 %}")
|
|
@ -24,7 +24,7 @@
|
|||
("class" "w-full flex justify-between gap-2")
|
||||
(a
|
||||
("class" "button")
|
||||
("href" "/{{ entry.slug }}/edit")
|
||||
("href" "/{{ entry.slug }}/edit{% if password -%} ?key={{ password }} {%- endif %}")
|
||||
(text "Edit"))
|
||||
|
||||
(div
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue