aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/forms.rs9
-rw-r--r--src/get_routes.rs10
-rw-r--r--src/main.rs4
3 files changed, 13 insertions, 10 deletions
diff --git a/src/forms.rs b/src/forms.rs
index c827ccb..15a22cf 100644
--- a/src/forms.rs
+++ b/src/forms.rs
@@ -35,7 +35,8 @@ pub fn edit_text_form<'a, C: Controller>(
header: data
.oid
.is_some()
- .then(|| action_links("edit", controller, ctx, parts)),
+ .then(|| action_links("edit", controller, ctx, parts))
+ .unwrap_or_default(),
scripts: vec![include_str!("static/edit_script.js")],
script_src: vec![include_str!("static/edit_script.js.sha")],
..Default::default()
@@ -91,7 +92,7 @@ pub fn move_form<C: Controller>(
) -> Result<Response, Error> {
let mut page = Page {
title: format!("Move {}", filename),
- header: Some(action_links("move", controller, ctx, parts)),
+ header: action_links("move", controller, ctx, parts),
..Default::default()
};
@@ -127,7 +128,9 @@ pub fn upload_form<'a, C: Controller>(
<button>Upload</button>\
</form>"
.into(),
- header: file_exists.then(|| action_links("edit", controller, &ctx, parts)),
+ header: file_exists
+ .then(|| action_links("edit", controller, &ctx, parts))
+ .unwrap_or_default(),
..Default::default()
}
}
diff --git a/src/get_routes.rs b/src/get_routes.rs
index be2e9c4..a743292 100644
--- a/src/get_routes.rs
+++ b/src/get_routes.rs
@@ -56,7 +56,7 @@ fn view_blob<C: Controller>(
) -> Result<Response, Error> {
let mut page = Page {
title: ctx.file_name().unwrap().to_owned(),
- header: Some(action_links(&params.action, controller, &ctx, parts)),
+ header: action_links(&params.action, controller, &ctx, parts),
..Default::default()
};
@@ -135,7 +135,7 @@ fn log_blob<C: Controller>(
let mut page = Page {
title: format!("Log for {}", filename),
- header: Some(action_links(&params.action, controller, &ctx, parts)),
+ header: action_links(&params.action, controller, &ctx, parts),
..Default::default()
};
@@ -255,7 +255,7 @@ fn diff_blob<C: Controller>(
return Ok(Page {
title: format!("Commit for {}", ctx.file_name().unwrap()),
body: "file removed".into(),
- header: Some(action_links(&action_param.action, controller, &ctx, parts)),
+ header: action_links(&action_param.action, controller, &ctx, parts),
..Default::default()
}
.into());
@@ -279,7 +279,7 @@ fn diff_blob<C: Controller>(
},
ctx.file_name().unwrap()
),
- header: Some(action_links(&action_param.action, controller, &ctx, parts)),
+ header: action_links(&action_param.action, controller, &ctx, parts),
..Default::default()
};
page.body.push_str("<div>");
@@ -426,7 +426,7 @@ fn remove_blob<C: Controller>(
let page = Page {
title: format!("Remove {}", filename),
- header: Some(action_links(&params.action, controller, &ctx, parts)),
+ header: action_links(&params.action, controller, &ctx, parts),
body: "<form method=post autocomplete=off>\
<label>Message <input name=msg autofocus></label>\
<button>Remove</button></form>"
diff --git a/src/main.rs b/src/main.rs
index 231a7af..7127922 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -272,7 +272,7 @@ async fn service<C: Controller>(
#[derive(Default)]
pub struct Page {
title: String,
- header: Option<String>,
+ header: String,
body: String,
/// will be embedded as inline <script> tags
scripts: Vec<&'static str>,
@@ -290,7 +290,7 @@ fn render_page<C: Controller>(page: &Page, controller: &C, parts: &Parts) -> Str
out.push_str("<meta name=viewport content=\"width=device-width, initial-scale=1\"><style>");
out.push_str(include_str!("static/style.css"));
out.push_str("</style></head><body><header id=header>");
- out.push_str(page.header.as_deref().unwrap_or_default());
+ out.push_str(&page.header);
out.push_str(
&controller
.user_info_html(parts)