aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-01-10 23:18:41 +0100
committermetamuffin <metamuffin@disroot.org>2023-01-10 23:18:41 +0100
commit0d81cb164983fdb40a9f0daebd5951d3cdc084e6 (patch)
tree9065ce8aedf864c241c2d3a197c45026922e45d4 /src/frontend
parentd38812fdbb968b14538ec59989873b1daf1fa7ab (diff)
downloadjellything-0d81cb164983fdb40a9f0daebd5951d3cdc084e6.tar
jellything-0d81cb164983fdb40a9f0daebd5951d3cdc084e6.tar.bz2
jellything-0d81cb164983fdb40a9f0daebd5951d3cdc084e6.tar.zst
error handling
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/pages/home.rs2
-rw-r--r--src/frontend/pages/mod.rs12
-rw-r--r--src/frontend/pages/node.rs9
-rw-r--r--src/frontend/style/layout.css6
4 files changed, 25 insertions, 4 deletions
diff --git a/src/frontend/pages/home.rs b/src/frontend/pages/home.rs
index d76fc6e..5076177 100644
--- a/src/frontend/pages/home.rs
+++ b/src/frontend/pages/home.rs
@@ -7,7 +7,7 @@ pub async fn page_home(state: &State<AppState>) -> HtmlTemplate<markup::DynRende
HtmlTemplate(
"Home".to_string(),
markup::new! {
- h1 { "Welcome to Jellything" }
+ p { "Welcome to Jellything" }
@NodePage { node: state.library.root.clone() }
},
)
diff --git a/src/frontend/pages/mod.rs b/src/frontend/pages/mod.rs
index fa1133e..a20fa0e 100644
--- a/src/frontend/pages/mod.rs
+++ b/src/frontend/pages/mod.rs
@@ -35,9 +35,19 @@ pub struct MyError(anyhow::Error);
impl<'r> Responder<'r, 'static> for MyError {
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> {
+ let mut out = String::new();
+ Layout {
+ title: "Error".to_string(),
+ main: markup::new! {
+ h2 { "An error occured. Nobody is sorry"}
+ pre.error { @format!("{:?}", self.0) }
+ },
+ }
+ .render(&mut out)
+ .unwrap();
Response::build()
.header(ContentType::HTML)
- .streamed_body(Cursor::new(format!("{:?}", self.0)))
+ .streamed_body(Cursor::new(out))
.ok()
}
}
diff --git a/src/frontend/pages/node.rs b/src/frontend/pages/node.rs
index b454793..7ac4332 100644
--- a/src/frontend/pages/node.rs
+++ b/src/frontend/pages/node.rs
@@ -1,8 +1,9 @@
use crate::{
- frontend::pages::{layout::Layout, HtmlTemplate},
+ frontend::pages::HtmlTemplate,
library::{Directory, Item, Node},
AppState,
};
+use anyhow::Context;
use rocket::{get, uri, State};
use std::{ops::Deref, path::PathBuf, sync::Arc};
@@ -14,7 +15,11 @@ pub async fn page_library_node(
state: &State<AppState>,
) -> Result<HtmlTemplate<markup::DynRender>, MyError> {
let path = path.to_str().unwrap().to_string();
- let node = state.library.nested(&path)?.clone();
+ let node = state
+ .library
+ .nested(&path)
+ .context("retrieving library node")?
+ .clone();
Ok(HtmlTemplate(
format!("{}", node.title()),
markup::new! {
diff --git a/src/frontend/style/layout.css b/src/frontend/style/layout.css
index dd05e9a..4418903 100644
--- a/src/frontend/style/layout.css
+++ b/src/frontend/style/layout.css
@@ -34,3 +34,9 @@ nav h1 {
padding-left: 3em;
padding-right: 3em;
}
+
+.error {
+ padding: 1em;
+ color: rgb(255, 117, 117);
+ font-family: monospace;
+}