web: More descriptive page titles

This commit is contained in:
Tiffany Bennett 2016-10-07 20:16:16 -04:00
parent e0e90f209d
commit 99d277b16b
2 changed files with 12 additions and 4 deletions

View file

@ -39,10 +39,9 @@ use std::env;
use worker::{eval_text, eval_json};
use limiter::RequestLimit;
use logger::Logger;
use rustc_serialize::json::ToJson;
fn root(req: &mut Request) -> IronResult<Response> {
use rustc_serialize::json::ToJson;
let mut data = BTreeMap::new();
let map = req.get_ref::<Params>().unwrap();
@ -53,6 +52,7 @@ fn root(req: &mut Request) -> IronResult<Response> {
reply.as_object_mut().unwrap().insert("input".to_owned(), query.to_json());
println!("{}", reply.pretty());
data.insert("queries".to_owned(), vec![reply].to_json());
data.insert("title".to_owned(), query.to_json());
},
_ => (),
};
@ -72,9 +72,10 @@ impl AfterMiddleware for ErrorMiddleware {
let mut error = BTreeMap::new();
if let Some(status) = err.response.status {
error.insert("status".to_owned(), format!("{}", status));
data.insert("title".to_owned(), format!("{}", status).to_json());
}
error.insert("message".to_owned(), format!("{}", err.error));
data.insert("error".to_owned(), error);
data.insert("error".to_owned(), error.to_json());
println!("{:#?}", data);
Ok(err.response.set(Template::new("index", data)))
}

View file

@ -4,7 +4,14 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Rink</title>
<title>
Rink
{{#if title}}
- {{title}}
{{/if}}
</title>
<link href="/static/app.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css"
rel="stylesheet" />