From 4853519325d30a46899534ec4934039e00a00ebd Mon Sep 17 00:00:00 2001 From: Delta1925 Date: Sun, 16 Apr 2023 13:58:52 +0200 Subject: [PATCH] Improve webpage --- ...elete.4b1c40a3.css => delete.f34bd3df.css} | 2 +- assets/webpage/delete/index.html | 9 ++-- assets/webpage/index.html | 4 +- assets/webpage/{success => status}/index.html | 6 +-- assets/webpage/submit/index.html | 11 ++--- example.config.toml | 1 - src/confirmation.rs | 9 +--- src/errors.rs | 13 +++++- src/main.rs | 42 ++++++------------- src/management.rs | 4 +- src/settings.rs | 1 + src/utils.rs | 35 ++++++++++++++-- 12 files changed, 76 insertions(+), 61 deletions(-) rename assets/webpage/_astro/{delete.4b1c40a3.css => delete.f34bd3df.css} (87%) rename assets/webpage/{success => status}/index.html (93%) diff --git a/assets/webpage/_astro/delete.4b1c40a3.css b/assets/webpage/_astro/delete.f34bd3df.css similarity index 87% rename from assets/webpage/_astro/delete.4b1c40a3.css rename to assets/webpage/_astro/delete.f34bd3df.css index e2ae973..9562966 100644 --- a/assets/webpage/_astro/delete.4b1c40a3.css +++ b/assets/webpage/_astro/delete.f34bd3df.css @@ -1 +1 @@ -*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}[type=text],[type=email],[type=url],[type=password],[type=number],[type=date],[type=datetime-local],[type=month],[type=search],[type=tel],[type=time],[type=week],[multiple],textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-width:1px;border-radius:0;padding:.5rem .75rem;font-size:1rem;line-height:1.5rem;--tw-shadow: 0 0 #0000}[type=text]:focus,[type=email]:focus,[type=url]:focus,[type=password]:focus,[type=number]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=month]:focus,[type=search]:focus,[type=tel]:focus,[type=time]:focus,[type=week]:focus,[multiple]:focus,textarea:focus,select:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: #2563eb;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);border-color:#2563eb}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-top:0;padding-bottom:0}select{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple]{background-image:initial;background-position:initial;background-repeat:unset;background-size:initial;padding-right:.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type=checkbox],[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-shrink:0;height:1rem;width:1rem;color:#2563eb;background-color:#fff;border-color:#6b7280;border-width:1px;--tw-shadow: 0 0 #0000}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 2px;--tw-ring-offset-color: #fff;--tw-ring-color: #2563eb;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}[type=checkbox]:checked,[type=radio]:checked{border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type=checkbox]:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e")}[type=radio]:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e")}[type=checkbox]:checked:hover,[type=checkbox]:checked:focus,[type=radio]:checked:hover,[type=radio]:checked:focus{border-color:transparent;background-color:currentColor}[type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e");border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type=checkbox]:indeterminate:hover,[type=checkbox]:indeterminate:focus{border-color:transparent;background-color:currentColor}[type=file]{background:unset;border-color:inherit;border-width:0;border-radius:0;padding:0;font-size:unset;line-height:inherit}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.flex{display:flex}.h-full{height:100%}.w-full{width:100%}.max-w-full{max-width:100%}.resize-none{resize:none}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.self-end{align-self:flex-end}.px-8{padding-left:2rem;padding-right:2rem}.py-4{padding-top:1rem;padding-bottom:1rem}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.font-bold{font-weight:700}.focus\:rounded-lg:focus{border-radius:.5rem}@media (prefers-color-scheme: dark){.dark\:bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.dark\:text-neutral-300{--tw-text-opacity: 1;color:rgb(212 212 212 / var(--tw-text-opacity))}} +*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}[type=text],[type=email],[type=url],[type=password],[type=number],[type=date],[type=datetime-local],[type=month],[type=search],[type=tel],[type=time],[type=week],[multiple],textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-width:1px;border-radius:0;padding:.5rem .75rem;font-size:1rem;line-height:1.5rem;--tw-shadow: 0 0 #0000}[type=text]:focus,[type=email]:focus,[type=url]:focus,[type=password]:focus,[type=number]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=month]:focus,[type=search]:focus,[type=tel]:focus,[type=time]:focus,[type=week]:focus,[multiple]:focus,textarea:focus,select:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: #2563eb;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);border-color:#2563eb}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-top:0;padding-bottom:0}select{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple]{background-image:initial;background-position:initial;background-repeat:unset;background-size:initial;padding-right:.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type=checkbox],[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-shrink:0;height:1rem;width:1rem;color:#2563eb;background-color:#fff;border-color:#6b7280;border-width:1px;--tw-shadow: 0 0 #0000}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 2px;--tw-ring-offset-color: #fff;--tw-ring-color: #2563eb;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}[type=checkbox]:checked,[type=radio]:checked{border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type=checkbox]:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e")}[type=radio]:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e")}[type=checkbox]:checked:hover,[type=checkbox]:checked:focus,[type=radio]:checked:hover,[type=radio]:checked:focus{border-color:transparent;background-color:currentColor}[type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e");border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type=checkbox]:indeterminate:hover,[type=checkbox]:indeterminate:focus{border-color:transparent;background-color:currentColor}[type=file]{background:unset;border-color:inherit;border-width:0;border-radius:0;padding:0;font-size:unset;line-height:inherit}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.absolute{position:absolute}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.flex{display:flex}.hidden{display:none}.h-full{height:100%}.w-full{width:100%}.max-w-full{max-width:100%}.cursor-wait{cursor:wait}.resize-none{resize:none}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.self-end{align-self:flex-end}.px-8{padding-left:2rem;padding-right:2rem}.py-4{padding-top:1rem;padding-bottom:1rem}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.font-bold{font-weight:700}.focus\:rounded-lg:focus{border-radius:.5rem}@media (prefers-color-scheme: dark){.dark\:bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.dark\:text-neutral-300{--tw-text-opacity: 1;color:rgb(212 212 212 / var(--tw-text-opacity))}} diff --git a/assets/webpage/delete/index.html b/assets/webpage/delete/index.html index 68a9ce6..20f5f32 100644 --- a/assets/webpage/delete/index.html +++ b/assets/webpage/delete/index.html @@ -4,17 +4,18 @@ Delete a key - + - + +
-
+ - +
diff --git a/assets/webpage/index.html b/assets/webpage/index.html index fabeda4..9ff96ad 100644 --- a/assets/webpage/index.html +++ b/assets/webpage/index.html @@ -4,9 +4,9 @@ Manage keys - + - +
diff --git a/assets/webpage/success/index.html b/assets/webpage/status/index.html similarity index 93% rename from assets/webpage/success/index.html rename to assets/webpage/status/index.html index 0c7f24d..49002da 100644 --- a/assets/webpage/success/index.html +++ b/assets/webpage/status/index.html @@ -3,9 +3,9 @@ - Success! - - + ((%s)) + +
diff --git a/assets/webpage/submit/index.html b/assets/webpage/submit/index.html index d9aedb9..0e402a5 100644 --- a/assets/webpage/submit/index.html +++ b/assets/webpage/submit/index.html @@ -4,17 +4,18 @@ Submit a key - + - + +
-
+ - - + +
diff --git a/example.config.toml b/example.config.toml index e12b8f9..49e202a 100644 --- a/example.config.toml +++ b/example.config.toml @@ -1,5 +1,4 @@ variant = "Advanced" -root_folder = "data" max_age = 900 cleanup_interval = 21600 allowed_domains = ["example.org", "example.com"] diff --git a/src/confirmation.rs b/src/confirmation.rs index 76bf6e3..c5f3773 100644 --- a/src/confirmation.rs +++ b/src/confirmation.rs @@ -5,7 +5,7 @@ use log::{debug, error, trace, warn}; use crate::errors::Error; use crate::management::{delete_key, Action, Pending}; use crate::pending_path; -use crate::settings::{MAILER, SETTINGS}; +use crate::settings::{MAILER, ROOT_FOLDER, SETTINGS}; use crate::utils::{get_email_from_cert, get_filename, parse_pem}; use lettre::{Message, Transport}; @@ -63,12 +63,7 @@ pub fn confirm_action(token: &str) -> Result<(Action, String), Error> { return Err(Error::ParseEmail); } }; - match sequoia_net::wkd::insert( - &SETTINGS.root_folder, - domain, - SETTINGS.variant, - &cert, - ) { + match sequoia_net::wkd::insert(ROOT_FOLDER, domain, SETTINGS.variant, &cert) { Ok(_) => email, Err(_) => { warn!("Unable to create a wkd entry for token {}", token); diff --git a/src/errors.rs b/src/errors.rs index 945806e..706e55b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,8 @@ -use actix_web::http::StatusCode; +use actix_web::{http::StatusCode, HttpResponseBuilder, ResponseError}; use thiserror::Error; +use crate::utils::return_outcome; + #[derive(Error, Debug, Clone, Copy)] pub enum Error { #[error("(0x01) Cert is invalid")] @@ -35,7 +37,7 @@ pub enum Error { MissingFile, } -impl actix_web::ResponseError for Error { +impl ResponseError for Error { fn status_code(&self) -> actix_web::http::StatusCode { match self { Self::MissingPending => StatusCode::from_u16(404).unwrap(), @@ -45,4 +47,11 @@ impl actix_web::ResponseError for Error { _ => StatusCode::from_u16(500).unwrap(), } } + + fn error_response(&self) -> actix_web::HttpResponse { + match return_outcome(Err(&self.to_string())) { + Ok(httpbuilder) => httpbuilder, + Err(_) => HttpResponseBuilder::new(self.status_code()).body(self.to_string()), + } + } } diff --git a/src/main.rs b/src/main.rs index 174353e..d04f72e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,13 +4,13 @@ mod management; mod settings; mod utils; +use crate::confirmation::{confirm_action, send_confirmation_email}; use crate::errors::Error; -use crate::settings::SETTINGS; -use crate::utils::is_email_allowed; - -use self::confirmation::{confirm_action, send_confirmation_email}; -use self::management::{clean_stale, store_pending_addition, store_pending_deletion, Action}; -use self::utils::{gen_random_token, get_email_from_cert, parse_pem}; +use crate::management::{clean_stale, store_pending_addition, store_pending_deletion, Action}; +use crate::settings::{ROOT_FOLDER, SETTINGS}; +use crate::utils::{ + gen_random_token, get_email_from_cert, is_email_allowed, parse_pem, return_outcome, +}; use actix_files::Files; use actix_web::http::header::ContentType; @@ -41,21 +41,6 @@ struct Email { email: String, } -fn return_success(message: &str) -> Result { - let path = webpage_path!().join("success").join("index.html"); - let template = match fs::read_to_string(&path) { - Ok(template) => template, - Err(_) => { - debug!("file {} is inaccessible", path.display()); - return Err(Error::Inaccessible); - } - }; - let page = template.replace("((%m))", message); - return Ok(HttpResponseBuilder::new(StatusCode::OK) - .insert_header(ContentType::html()) - .body(page)); -} - #[actix_web::main] async fn main() -> std::io::Result<()> { if let Ok(value) = env::var("RUST_LOG") { @@ -85,11 +70,8 @@ async fn main() -> std::io::Result<()> { .service(confirm) .service(delete) .service( - Files::new( - "/.well-known", - Path::new(&SETTINGS.root_folder).join(".well-known"), - ) - .use_hidden_files(), + Files::new("/.well-known", Path::new(&ROOT_FOLDER).join(".well-known")) + .use_hidden_files(), ) .route("/{filename:.*}", web::get().to(index)) }) @@ -133,7 +115,7 @@ async fn submit(pem: web::Form) -> Result { store_pending_addition(pem.key.clone(), &email, &token)?; send_confirmation_email(&email, &Action::Add, &token)?; info!("User {} submitted a key!", &email); - return_success("You submitted your key successfully!") + return_outcome(Ok("You submitted your key successfully!")) } #[get("/api/confirm")] @@ -142,11 +124,11 @@ async fn confirm(token: web::Query) -> Result { match action { Action::Add => { info!("Key for user {} was added successfully!", email); - return_success("Your key was added successfully!") + return_outcome(Ok("Your key was added successfully!")) } Action::Delete => { info!("Key for user {} was deleted successfully!", email); - return_success("Your key was deleted successfully!") + return_outcome(Ok("Your key was deleted successfully!")) } } } @@ -157,5 +139,5 @@ async fn delete(email: web::Query) -> Result { store_pending_deletion(email.email.clone(), &token)?; send_confirmation_email(&email.email, &Action::Delete, &token)?; info!("User {} requested the deletion of his key!", email.email); - return_success("You requested the deletion of your key successfully!") + return_outcome(Ok("You requested the deletion of your key successfully!")) } diff --git a/src/management.rs b/src/management.rs index e184042..c23e4fe 100644 --- a/src/management.rs +++ b/src/management.rs @@ -1,5 +1,5 @@ use crate::pending_path; -use crate::settings::SETTINGS; +use crate::settings::ROOT_FOLDER; use crate::utils::{get_user_file_path, key_exists}; use crate::{errors::Error, utils::get_filename}; @@ -132,7 +132,7 @@ pub fn clean_stale(max_age: i64) { } pub fn delete_key(email: &str) -> Result<(), Error> { - let path = Path::new(&SETTINGS.root_folder).join(get_user_file_path(email)?); + let path = Path::new(&ROOT_FOLDER).join(get_user_file_path(email)?); match fs::remove_file(path) { Ok(_) => Ok(()), Err(_) => Err(Error::Inaccessible), diff --git a/src/settings.rs b/src/settings.rs index 08ebc1d..bc3bb56 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -92,5 +92,6 @@ fn get_mailer() -> SmtpTransport { mailer } +pub const ROOT_FOLDER: &str = "data"; pub static SETTINGS: Lazy = Lazy::new(get_settings); pub static MAILER: Lazy = Lazy::new(get_mailer); diff --git a/src/utils.rs b/src/utils.rs index 8f706ea..fe63ae3 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,16 +1,24 @@ -use crate::errors::Error; use crate::settings::SETTINGS; +use crate::{errors::Error, settings::ROOT_FOLDER}; +use actix_web::{ + http::{header::ContentType, StatusCode}, + HttpResponse, HttpResponseBuilder, +}; use flexi_logger::{style, DeferredNow, FileSpec, FlexiLoggerError, Logger, LoggerHandle, Record}; +use log::debug; use rand::{distributions::Alphanumeric, thread_rng, Rng}; use sequoia_net::wkd::Url; use sequoia_openpgp::{parse::Parse, policy::StandardPolicy, Cert}; -use std::path::{Path, PathBuf}; +use std::{ + fs, + path::{Path, PathBuf}, +}; #[macro_export] macro_rules! pending_path { () => { - Path::new(&SETTINGS.root_folder).join("pending") + Path::new(&ROOT_FOLDER).join("pending") }; } @@ -82,7 +90,7 @@ pub fn get_user_file_path(email: &str) -> Result { pub fn key_exists(email: &str) -> Result { let path = get_user_file_path(email)?; - if !Path::new(&SETTINGS.root_folder).join(path).is_file() { + if !Path::new(&ROOT_FOLDER).join(path).is_file() { return Err(Error::MissingKey); } Ok(true) @@ -135,3 +143,22 @@ pub fn init_logger() -> Result { .set_palette("b1;3;2;4;6".to_string()) .start() } + +pub fn return_outcome(data: Result<&str, &str>) -> Result { + let path = webpage_path!().join("status").join("index.html"); + let template = match fs::read_to_string(&path) { + Ok(template) => template, + Err(_) => { + debug!("file {} is inaccessible", path.display()); + return Err(Error::Inaccessible); + } + }; + let (page, message) = match data { + Ok(message) => (template.replace("((%s))", "Success!"), message), + Err(message) => (template.replace("((%s))", "Failure!"), message), + }; + let page = page.replace("((%m))", message); + return Ok(HttpResponseBuilder::new(StatusCode::OK) + .insert_header(ContentType::html()) + .body(page)); +}