diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dc35434 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = true + +[*.rs] +indent_size = 4 diff --git a/panel/css/chat.css b/panel/css/chat.css new file mode 100644 index 0000000..ec40ba7 --- /dev/null +++ b/panel/css/chat.css @@ -0,0 +1,36 @@ +.chat-box { + display: flex; + flex-direction: column; + + padding: 1em; + + height: 12em; +} + +.chat-entries { + display: flex; + flex: 1; + + margin: 0; + padding: 0.5em; + flex-direction: column-reverse; + overflow-y: scroll; +} + +.chat-input { + padding: 0.5em; +} + +.chat-message { + display: flex; +} + +.message-author { + margin-inline-end: 0.5ch; +} + +.message-content { + display: inline-block; + flex: 1; + overflow-wrap: anywhere; +} diff --git a/panel/css/styles.css b/panel/css/styles.css new file mode 100644 index 0000000..ffa51e7 --- /dev/null +++ b/panel/css/styles.css @@ -0,0 +1,43 @@ +html { + font-family: sans-serif; + margin: 0; +} + +body { + min-height: 100vh; + margin: 0; + display: flex; + flex-direction: column; +} + +nav, +main, +footer { + max-width: 80ch; + margin: 0 auto; + width: 100%; + padding: 1em; +} + +main { + flex: 1; +} + +nav ul { + display: block; + margin: 0; + padding: 0; +} + +nav li, +nav li a { + display: inline-block; +} + +nav li a { + padding: 0.5em; +} + +a { + color: rgb(252, 38, 145); +} diff --git a/panel/index.html b/panel/index.html new file mode 100644 index 0000000..5075a0c --- /dev/null +++ b/panel/index.html @@ -0,0 +1,40 @@ + + + + + + Chat + + + + + + + + +
+

Chat

+ +
+ + +
+
+ + + + diff --git a/src/auth.rs b/src/auth.rs new file mode 100644 index 0000000..fbbf74c --- /dev/null +++ b/src/auth.rs @@ -0,0 +1,8 @@ +use std::collections::HashMap; + +use warp::{Rejection, Reply}; + +pub async fn login(form: HashMap) -> Result { + // TODO: Accept 'username' and 'password', I guess. + Ok("Hello!".to_string()) +} diff --git a/src/main.rs b/src/main.rs index 071f4c9..0fb9885 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,24 @@ -use warp::{Filter, Rejection, Reply}; - -mod db; -mod users; - -async fn hello() -> Result { - Ok("Hello!".to_string()) -} - -#[tokio::main] -async fn main() { - let hello = warp::any().and_then(hello); - warp::serve(hello).run(([127, 0, 0, 1], 8000)).await; -} +use std::net::SocketAddr; + +use warp::Filter; + +mod auth; +mod db; +mod users; + +#[tokio::main] +async fn main() { + let login_route = warp::path("login") + .and(warp::path::end()) + .and(warp::post()) + .and(warp::body::form()) + .and_then(auth::login); + + let panel_route = warp::fs::dir("panel"); + + let routes = login_route.or(panel_route); + let addr: SocketAddr = ([127, 0, 0, 1], 8000).into(); + + println!("Listening on: http://{}/ ...", &addr); + warp::serve(routes).run(addr).await; +}