diff --git a/Cargo.toml b/Cargo.toml
index 2eef7b5..22eb3d6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "board_server"
-version = "2.0.1"
+version = "2.1.0"
edition = "2018"
license = "Zlib"
repository = "https://git.solow.xyz/cgit.cgi/Boarders/"
diff --git a/src/html/boards.rs b/src/html/boards.rs
index b9c3f10..8e3a0de 100644
--- a/src/html/boards.rs
+++ b/src/html/boards.rs
@@ -122,10 +122,8 @@ pub async fn board_post(
} else {
return Err(HttpResponse::Unauthorized().body("Unauthorized: Bad login attempt, invalid auth token"));
}
- }, form.content.clone());
+ }, form.content.clone().trim());
println!("new message");
- //println!("board: {{ id: {}, name: {} }}{:?}", a.id, a.title, msg);
- //let a = a.clone().add_message(msg);
a.add_message(msg);
Ok(HttpResponse::SeeOther().header("location", format!("/board/{}/", a.id)).finish())
},
diff --git a/src/lib/boards.rs b/src/lib/boards.rs
index 78acd35..8592239 100644
--- a/src/lib/boards.rs
+++ b/src/lib/boards.rs
@@ -27,10 +27,10 @@ pub struct Board {
impl Board {
pub fn open
(path: P) -> Result where P: AsRef {
- let mut b: std::result::Result = match File::open(&path) {
- Ok(a) => Ok(serde_json::from_reader(a).unwrap()),
- Err(e) => Err(e)
- };
+ let mut b: std::result::Result = File::open(&path).map(
+ |a| serde_json::from_reader(a).unwrap()
+ );
+ /* backwards compatability */
if let Ok(ref mut b) = b {
if b.last_active.is_none() {
b.last_active = b.messages.borrow().last().map(|x| x.timestamp);
diff --git a/src/res/board.hbs b/src/res/board.hbs
index eb9e973..05b891d 100644
--- a/src/res/board.hbs
+++ b/src/res/board.hbs
@@ -3,40 +3,36 @@
-
+
{{> board_bar board=board user=user}}
-
-
- {{#each messages as | msg |}}
-
-
- {{#if msg.author.nick}}
-
- {{msg.author.nick}}
- {{author.username}}
-
- {{else}}
- {{msg.author.username}}
- {{/if}}
- |
-
- {{msg.text}}
- |
-
- {{msg.timestamp}}
- |
-
- {{/each}}
-
-
+
+ {{#each messages as | msg |}}
+
+ {{#if msg.author.nick}}
+
+ {{msg.author.nick}}
+
{{author.username}}
+
+ {{else}}
+
{{msg.author.username}}
+ {{/if}}
+
+
+ {{msg.timestamp}}
+
+
+ {{/each}}
+
diff --git a/src/res/board_index.hbs b/src/res/board_index.hbs
index 246cc8d..67e1423 100644
--- a/src/res/board_index.hbs
+++ b/src/res/board_index.hbs
@@ -3,7 +3,7 @@
-
+
Board Index
diff --git a/static/index.css b/static/index.css
index 0f1aec1..3cac126 100644
--- a/static/index.css
+++ b/static/index.css
@@ -106,6 +106,20 @@ body {
margin-top: 0.5em;
margin-bottom: 0.5em;
border-bottom: 1px solid #555;
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-start;
+ align-items: center;
+}
+
+.message > * {
+ padding: 0.2em;
+}
+
+.message:hover {
+ background-color: #3a3a3a;
+ animation-duration: 0.1s;
+ animation-name: msg-hover;
}
@keyframes msg-hover {
@@ -113,21 +127,10 @@ body {
background-color: inherit;
}
to {
- background-color: #5a5a5a
+ background-color: #3a3a3a;
}
}
-tr.message:hover {
- animation-duration: 0.2s;
- animation-name: msg-hover;
- background-color: #5a5a5a
-}
-
-.message.right {
-}
-.message.left {
-}
-
.vertical-center {
margin: 0;
position: absolute;
@@ -149,13 +152,6 @@ th {
margin-bottom: 1em;
}
-tr.a {
- background-color: #3A3A3A;
-}
-tr.b {
- background-color: inherit;
-}
-
.auth {
margin: auto;
width: 20em;
@@ -171,6 +167,9 @@ tr.b {
#index {
padding: 3em;
padding-top: 0;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
}
@keyframes board-hover {
@@ -195,3 +194,16 @@ tr.board:hover {
animation-name: board-hover;
background-color: #444;
}
+
+.message-content {
+ flex-grow: 1;
+ max-width: 90%;
+}
+
+pre {
+ white-space: pre-wrap; /* Since CSS 2.1 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+}