From 6bfc272c462a40d92aab3fb3f1fe6a6a5e161a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mekina?= Date: Fri, 2 May 2025 15:12:52 +0200 Subject: [PATCH] add ui --- client/index.html | 11 ++- client/style.scss | 153 +++++++++++++++++++++++++++++++++++++ theseus-server/src/args.rs | 4 +- theseus-server/src/main.rs | 5 ++ 4 files changed, 167 insertions(+), 6 deletions(-) diff --git a/client/index.html b/client/index.html index 1fe3fd1..7764d10 100644 --- a/client/index.html +++ b/client/index.html @@ -8,16 +8,19 @@
-

Ask Stallman

+
+

Ask Stallman

+
{%- if message.len() != 0 -%} -
+

{{ message }}

{%- endif -%}
- + +
@@ -35,7 +38,7 @@
diff --git a/client/style.scss b/client/style.scss index e69de29..1a74708 100644 --- a/client/style.scss +++ b/client/style.scss @@ -0,0 +1,153 @@ +$color-primary: white; +$color-primary-background: black; +$color-subtle: #908caa; +$color-muted: #6e6a86; +$color-highlight: #f6c177; +$color-iris: #c4a7e7; +$color-error: #eb6f92; + +body { + font-family: Arial, Helvetica, sans-serif; + color: $color-primary; + background-color: $color-primary-background; + margin: 0; + min-height: 100vh; +} + +a { + color: $color-muted; +} + +a:visited { + color: $color-muted; +} + +header { + display: flex; + width: 100%; + margin: 0 auto; + justify-content: center; + align-items: center; + margin-bottom: 7em; + background-color: $color-primary-background; + box-shadow: 0 0 10em rgba($color-subtle, .5); + border-bottom: 1px solid rgba($color-subtle, .3); +} + +@keyframes notification-anim { + from { opacity: 0; } + to { opacity: 1; } +} + +.notification { + animation: notification-anim 1s forwards; + display: block; + margin: 2em 0; + width: min(90%, 50em); + color: $color-primary; + border: 2px dashed $color-primary; + overflow: hidden; + padding: 1em 1em; + border-radius: .5em; + box-sizing: border-box; + background-color: $color-primary-background; + margin: 0 auto; + margin-bottom: 4em; + z-index: 2; +} + +.notification-error { + color: $color-error; + border-color: $color-error; +} + +.question { + display: flex; + width: 100%; + justify-content: center; + + form { + width: min(90%, 50em); + + input { + z-index: 2; + } + + .input { + transition: .5s ease box-shadow, .5s ease border-color; + width: 100%; + box-sizing: border-box; + padding: 1em 2em; + color: $color-primary; + background-color: transparent; + border: 1px solid $color-iris; + border-radius: 2em; + outline: none; + box-shadow: 0 0 5em rgba($color-subtle, .1); + z-index: 1; + } + + .input:focus { + box-shadow: 0 0 5em $color-subtle; + border-color: rgba($color-iris, .5); + } + + .submit { + transition: .5s ease color, .5s ease background-color, .5s ease box-shadow; + display: block; + width: fit-content; + margin: 2em auto; + margin-top: 5em; + padding: .5em 1em; + border-radius: 2em; + box-sizing: border-box; + color: $color-primary-background; + background-color: $color-primary; + border: 2px solid $color-primary; + outline: none; + z-index: 2; + cursor: pointer; + } + + .submit:hover { + color: $color-primary; + background-color: $color-primary-background; + } + + .submit:focus { + color: $color-primary; + background-color: $color-primary-background; + box-shadow: 0 0 2em $color-primary; + } + } +} + +.info { + width: min(90%, 50em); + margin: 5em auto; + z-index: 2; + + ul { + padding: 1em; + + li { + margin: 1em 0; + } + } +} + +footer { + margin-top: 5em; + display: flex; + width: min(100%, 50em); + margin: 0 auto; + justify-content: center; + padding: 1em 2em; + box-sizing: border-box; + border-top: 1px solid $color-muted; + opacity: .6; + + p { + margin: 1em 0; + } +} diff --git a/theseus-server/src/args.rs b/theseus-server/src/args.rs index ea4823c..f7c0558 100644 --- a/theseus-server/src/args.rs +++ b/theseus-server/src/args.rs @@ -9,7 +9,7 @@ macro_rules! argdef { pub fn usage() -> &'static str { concat!("usage: ", $program_name, " ", $("[", stringify!($arg_id), "] "),*) } - + $(pub fn $arg_id(&self) -> &str { &self.$arg_id })* } @@ -39,7 +39,7 @@ macro_rules! argdef { } argdef!{ - + args Args("theseus-server") { config_path, } diff --git a/theseus-server/src/main.rs b/theseus-server/src/main.rs index 23f70f6..757940f 100644 --- a/theseus-server/src/main.rs +++ b/theseus-server/src/main.rs @@ -178,6 +178,11 @@ async fn new_question( )); }; let question = question.to_string(); + if question.len() == 0 { + return Ok(response!(main_page req, + "info", "You sent an empty question. Please try again." + )); + } // insert question match state.questions.lock().await.add_new(question) {