aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs
index cdb5650..5c9f10c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -273,29 +273,24 @@ pub struct Page {
body: String,
}
-const CSS: &str = include_str!("static/style.css");
-
fn render_page<C: Controller>(page: &Page, controller: &C, parts: &Parts) -> String {
- format!(
- "<!doctype html>\
- <html>\
- <head>\
- <meta charset=utf-8>\
- <title>{}</title>\
- <meta name=viewport content=\"width=device-width, initial-scale=1\">\
- <style>{}</style>\
- </head>\
- <body><header id=header>{}{}</header>{}</body></html>\
- ",
- html_escape(&page.title),
- CSS,
- page.header.as_deref().unwrap_or_default(),
- controller
+ let mut out = String::new();
+ out.push_str("<!doctype html><html><head><meta charset=utf-8>");
+ out.push_str(&format!("<title>{}</title>", html_escape(&page.title)));
+ 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(
+ &controller
.user_info_html(parts)
.map(|h| format!("<div class=user-info>{}</div>", h))
.unwrap_or_default(),
- page.body,
- )
+ );
+ out.push_str("</header>");
+ out.push_str(&page.body);
+ out.push_str("</body></html>");
+ out
}
#[derive(Deserialize)]