This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(unreachable_code)] | |
fn rocket_route_fn_episode_login<'_b>(__req: &'_b ::rocket::Request, | |
__data: ::rocket::Data) | |
-> ::rocket::handler::Outcome<'_b> { | |
let rocket_param_date: Datestamp = | |
match match __req.get_param_str(0usize) { | |
Some(s) => | |
<Datestamp as | |
::rocket::request::FromParam>::from_param(s), | |
None => return ::rocket::Outcome::Forward(__data), | |
} { | |
Ok(v) => v, | |
Err(e) => { | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[" => Failed to parse \'", | |
"\': ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&"date", | |
&e) { | |
(__arg0, | |
__arg1) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, | |
::std::fmt::Debug::fmt)], | |
})); | |
return ::rocket::Outcome::Forward(__data) | |
} | |
}; | |
let rocket_param_flow: Option<FlowType> = | |
match match __req.get_param_str(1usize) { | |
Some(s) => | |
<Option<FlowType> as | |
::rocket::request::FromParam>::from_param(s), | |
None => return ::rocket::Outcome::Forward(__data), | |
} { | |
Ok(v) => v, | |
Err(e) => { | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[" => Failed to parse \'", | |
"\': ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&"flow", | |
&e) { | |
(__arg0, | |
__arg1) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, | |
::std::fmt::Debug::fmt)], | |
})); | |
return ::rocket::Outcome::Forward(__data) | |
} | |
}; | |
let rocket_param_idx: u32 = | |
match match __req.get_param_str(2usize) { | |
Some(s) => | |
<u32 as ::rocket::request::FromParam>::from_param(s), | |
None => return ::rocket::Outcome::Forward(__data), | |
} { | |
Ok(v) => v, | |
Err(e) => { | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[" => Failed to parse \'", | |
"\': ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&"idx", | |
&e) { | |
(__arg0, | |
__arg1) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, | |
::std::fmt::Debug::fmt)], | |
})); | |
return ::rocket::Outcome::Forward(__data) | |
} | |
}; | |
#[allow(non_snake_case)] | |
let rocket_param_uri: &URI = | |
match ::rocket::request::FromRequest::from_request(__req) { | |
::rocket::Outcome::Success(v) => v, | |
::rocket::Outcome::Forward(_) => | |
return ::rocket::Outcome::Forward(__data), | |
::rocket::Outcome::Failure((code, _)) => { | |
return ::rocket::Outcome::Failure(code) | |
} | |
}; | |
#[allow(non_snake_case)] | |
let rocket_param_users: State<ActiveUsers> = | |
match ::rocket::request::FromRequest::from_request(__req) { | |
::rocket::Outcome::Success(v) => v, | |
::rocket::Outcome::Forward(_) => | |
return ::rocket::Outcome::Forward(__data), | |
::rocket::Outcome::Failure((code, _)) => { | |
return ::rocket::Outcome::Failure(code) | |
} | |
}; | |
let responder = | |
episode_login(rocket_param_uri, rocket_param_users, | |
rocket_param_date, rocket_param_flow, | |
rocket_param_idx); | |
::rocket::handler::Outcome::from(__req, responder) | |
} | |
/// Rocket code generated static route information structure. | |
#[allow(non_upper_case_globals)] | |
#[rocket_route_info] | |
pub static static_rocket_route_info_for_episode_login: | |
::rocket::StaticRouteInfo = | |
::rocket::StaticRouteInfo{method: ::rocket::http::Method::Get, | |
path: "/<date>/<flow>/<idx>", | |
handler: rocket_route_fn_episode_login, | |
format: None, | |
rank: Some(1isize),}; | |
#[allow(unused_variables)] | |
#[rocket_route(static_rocket_route_info_for_episode_login)] | |
pub fn episode_login(uri: &URI, users: State<ActiveUsers>, | |
date: Datestamp, flow: Option<FlowType>, idx: u32) | |
-> Redirect { | |
Redirect::to(&::fmt::format(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&["/login?uri="]; | |
__STATIC_FMTSTR | |
}, | |
&match (&URI::percent_encode(uri.as_str()),) | |
{ | |
(__arg0,) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt)], | |
}))) | |
} | |
#[allow(unreachable_code)] | |
fn rocket_route_fn_episode<'_b>(__req: &'_b ::rocket::Request, | |
__data: ::rocket::Data) | |
-> ::rocket::handler::Outcome<'_b> { | |
let rocket_param_date: Datestamp = | |
match match __req.get_param_str(0usize) { | |
Some(s) => | |
<Datestamp as | |
::rocket::request::FromParam>::from_param(s), | |
None => return ::rocket::Outcome::Forward(__data), | |
} { | |
Ok(v) => v, | |
Err(e) => { | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[" => Failed to parse \'", | |
"\': ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&"date", | |
&e) { | |
(__arg0, | |
__arg1) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, | |
::std::fmt::Debug::fmt)], | |
})); | |
return ::rocket::Outcome::Forward(__data) | |
} | |
}; | |
let rocket_param_flow: Option<FlowType> = | |
match match __req.get_param_str(1usize) { | |
Some(s) => | |
<Option<FlowType> as | |
::rocket::request::FromParam>::from_param(s), | |
None => return ::rocket::Outcome::Forward(__data), | |
} { | |
Ok(v) => v, | |
Err(e) => { | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[" => Failed to parse \'", | |
"\': ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&"flow", | |
&e) { | |
(__arg0, | |
__arg1) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, | |
::std::fmt::Debug::fmt)], | |
})); | |
return ::rocket::Outcome::Forward(__data) | |
} | |
}; | |
let rocket_param_idx: u32 = | |
match match __req.get_param_str(2usize) { | |
Some(s) => | |
<u32 as ::rocket::request::FromParam>::from_param(s), | |
None => return ::rocket::Outcome::Forward(__data), | |
} { | |
Ok(v) => v, | |
Err(e) => { | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[" => Failed to parse \'", | |
"\': ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&"idx", | |
&e) { | |
(__arg0, | |
__arg1) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, | |
::std::fmt::Debug::fmt)], | |
})); | |
return ::rocket::Outcome::Forward(__data) | |
} | |
}; | |
#[allow(non_snake_case)] | |
let rocket_param_user: User = | |
match ::rocket::request::FromRequest::from_request(__req) { | |
::rocket::Outcome::Success(v) => v, | |
::rocket::Outcome::Forward(_) => | |
return ::rocket::Outcome::Forward(__data), | |
::rocket::Outcome::Failure((code, _)) => { | |
return ::rocket::Outcome::Failure(code) | |
} | |
}; | |
#[allow(non_snake_case)] | |
let rocket_param_users: State<ActiveUsers> = | |
match ::rocket::request::FromRequest::from_request(__req) { | |
::rocket::Outcome::Success(v) => v, | |
::rocket::Outcome::Forward(_) => | |
return ::rocket::Outcome::Forward(__data), | |
::rocket::Outcome::Failure((code, _)) => { | |
return ::rocket::Outcome::Failure(code) | |
} | |
}; | |
let responder = | |
episode(rocket_param_user, rocket_param_users, rocket_param_date, | |
rocket_param_flow, rocket_param_idx); | |
::rocket::handler::Outcome::from(__req, responder) | |
} | |
/// Rocket code generated static route information structure. | |
#[allow(non_upper_case_globals)] | |
#[rocket_route_info] | |
pub static static_rocket_route_info_for_episode: ::rocket::StaticRouteInfo | |
= | |
::rocket::StaticRouteInfo{method: ::rocket::http::Method::Get, | |
path: "/<date>/<flow>/<idx>", | |
handler: rocket_route_fn_episode, | |
format: None, | |
rank: None,}; | |
#[rocket_route(static_rocket_route_info_for_episode)] | |
pub fn episode(user: User, users: State<ActiveUsers>, date: Datestamp, | |
flow: Option<FlowType>, idx: u32) | |
-> StdResult<Template, Failure> { | |
do catch { | |
let flow = flow.ok_or(ErrorKind::BadParam("invalid flow type"))?; | |
let mut data = | |
{ | |
let mut data = None; | |
for dir in settings::DATADIRS { | |
let mut path = PathBuf::from(dir); | |
path.push(::fmt::format(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[""]; | |
__STATIC_FMTSTR | |
}, | |
&match (&date.0,) | |
{ | |
(__arg0,) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt)], | |
}))); | |
path.push(::fmt::format(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[""]; | |
__STATIC_FMTSTR | |
}, | |
&match (&flow,) | |
{ | |
(__arg0,) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt)], | |
}))); | |
path.push(::fmt::format(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&[""]; | |
__STATIC_FMTSTR | |
}, | |
&match (&idx,) | |
{ | |
(__arg0,) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt)], | |
}))); | |
path.push(::fmt::format(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&["", | |
".flow"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&flow,) | |
{ | |
(__arg0,) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Display::fmt)], | |
}))); | |
data = | |
match SurfaceData::from_flow_file(date, flow, idx, | |
&path) { | |
Ok(d) => Some(d), | |
Err(e) => | |
match *e.kind() { | |
ErrorKind::Io(ref ioe) => | |
match ioe.kind() { | |
io::ErrorKind::NotFound => continue , | |
_ => break , | |
}, | |
_ => break , | |
}, | |
}; | |
} | |
data.ok_or(io::Error::new(io::ErrorKind::NotFound, | |
"episode not found in any datadir"))? | |
}; | |
for rating in data.ratings.iter_mut() { | |
if rating.prompt == "cool/warm" { | |
rating.short = Some("warm"); | |
rating.long = | |
Some("What temperature would you feel when touching this surface? 1: ice cold beer bottle. 5: hot sand at the beach."); | |
} else if rating.prompt == "soft/hard" { | |
rating.short = Some("hard"); | |
rating.long = | |
Some("How soft or hard is this surface? 1: pillow. 5: rock."); | |
} else if rating.prompt == "smooth/rough" { | |
rating.short = Some("rough"); | |
rating.long = | |
Some("How smooth or rough is this surface? 1: glass. 5: sandpaper."); | |
} else if rating.prompt == "slippery/sticky" { | |
rating.short = Some("sticky"); | |
rating.long = | |
Some("How slippery or sticky is this surface? This is NOT the same as roughness, nor is it sticky as in glue. This question refers to how much a finger would get stuck while rubbing due to friction with the surface. 1: silk. 5: rubber."); | |
} | |
} | |
let mut users = users.lock().unwrap(); | |
let user_info = | |
users.entry(user.clone()).or_insert_with(Default::default); | |
let rate_error = | |
if user_info.rate_error { | |
user_info.rate_error = false; | |
"All ratings are required" | |
} else { "" }; | |
let report_error = | |
if user_info.report_error { | |
user_info.report_error = false; | |
"At least one reason is required" | |
} else { "" }; | |
Ok(Template::render("episode", | |
::Value::Object({ | |
let mut object = | |
::Map::new(); | |
object.insert(("rate_error").into(), | |
::to_value(&rate_error).unwrap()); | |
object.insert(("report_error").into(), | |
::to_value(&report_error).unwrap()); | |
object.insert(("user").into(), | |
::to_value(&user).unwrap()); | |
object.insert(("surface").into(), | |
::to_value(&data).unwrap()); | |
object.insert(("date").into(), | |
::to_value(&date.0).unwrap()); | |
object.insert(("flow").into(), | |
::to_value(&flow.to_string()).unwrap()); | |
object.insert(("idx").into(), | |
::to_value(&idx).unwrap()); | |
object | |
}))) | |
}.map_err(|err: Error| | |
{ | |
::io::_print(::std::fmt::Arguments::new_v1({ | |
static __STATIC_FMTSTR: | |
&'static [&'static str] | |
= | |
&["ERROR: ", | |
"\n"]; | |
__STATIC_FMTSTR | |
}, | |
&match (&err,) | |
{ | |
(__arg0,) | |
=> | |
[::std::fmt::ArgumentV1::new(__arg0, | |
::std::fmt::Debug::fmt)], | |
})); | |
let mut code = 500; | |
match *err.kind() { | |
ErrorKind::Io(ref ioerr) => | |
match ioerr.kind() { | |
io::ErrorKind::NotFound => code = 404, | |
io::ErrorKind::PermissionDenied => | |
code = 403, | |
_ => { } | |
}, | |
ErrorKind::BadParam { .. } => code = 400, | |
_ => { } | |
} | |
Failure(Status::from_code(code).unwrap()) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment