[add] BODY_EMBED support

This commit is contained in:
hkau 2024-03-30 14:54:06 -04:00
parent 6d26e7c6ce
commit 4fabded7f8
4 changed files with 33 additions and 0 deletions

View File

@ -3,6 +3,7 @@ pub struct BaseTemplate {
pub auth_state: bool,
pub bundlrs: String,
pub guppy: String,
pub body_embed: String,
}
pub fn get_base_values(token_cookie: bool) -> BaseTemplate {
@ -15,11 +16,19 @@ pub fn get_base_values(token_cookie: bool) -> BaseTemplate {
info = info_req.unwrap();
}
let body_embed_req = std::env::var("BODY_EMBED");
let body_embed = if body_embed_req.is_ok() {
body_embed_req.unwrap()
} else {
String::new()
};
// return
BaseTemplate {
info,
auth_state: token_cookie,
bundlrs: std::env::var("BUNDLRS_ROOT").unwrap(),
guppy: std::env::var("GUPPY_ROOT").unwrap(),
body_embed,
}
}

View File

@ -15,6 +15,7 @@ struct NewTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[derive(Template)]
@ -25,6 +26,7 @@ struct PasswordPromptTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
// ...
board_name: String,
}
@ -37,6 +39,7 @@ struct AuthPromptTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[derive(Template)]
@ -56,6 +59,7 @@ struct ViewBoardTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[derive(Template)]
@ -70,6 +74,7 @@ struct NewPostTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[derive(Default, PartialEq, serde::Deserialize)]
@ -100,6 +105,7 @@ struct ViewPostTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[derive(Default, PartialEq, serde::Deserialize)]
@ -118,6 +124,7 @@ struct SettingsTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[derive(Template)]
@ -129,6 +136,7 @@ struct DashboardTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
/* #[derive(Default, PartialEq, serde::Deserialize)]
@ -179,6 +187,7 @@ pub async fn new_request(req: HttpRequest, data: web::Data<pufferdb::AppData>) -
auth_state: base.auth_state,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::NotFound()
@ -198,6 +207,7 @@ pub async fn new_request(req: HttpRequest, data: web::Data<pufferdb::AppData>) -
auth_state: base.auth_state,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
}
.render()
.unwrap(),
@ -262,6 +272,7 @@ pub async fn view_board_request(
auth_state: base.auth_state,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::NotFound()
@ -300,6 +311,7 @@ pub async fn view_board_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::Ok()
@ -356,6 +368,7 @@ pub async fn view_board_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
board_m: metadata.clone(),
topic_required: metadata.topic_required.is_some()
&& metadata.topic_required.as_ref().unwrap() == "yes",
@ -430,6 +443,7 @@ pub async fn create_board_post_request(
auth_state: base.auth_state,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::NotFound()
@ -468,6 +482,7 @@ pub async fn create_board_post_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::Ok()
@ -489,6 +504,7 @@ pub async fn create_board_post_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
board_m: metadata.clone(),
can_post_from_anonymous: metadata.allow_anonymous.is_none()
|| metadata.allow_anonymous.unwrap() != "no",
@ -582,6 +598,7 @@ pub async fn view_board_post_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
edit_text: if info.edit_text.is_some() {
info.edit_text.unwrap()
} else {
@ -717,6 +734,7 @@ pub async fn board_settings_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::Ok()
@ -929,6 +947,7 @@ pub async fn dashboard_request(
auth_state: base.auth_state,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::NotFound()
@ -950,6 +969,7 @@ pub async fn dashboard_request(
info: base.info,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
};
return HttpResponse::Ok()

View File

@ -13,6 +13,7 @@ struct HomeTemplate {
auth_state: bool,
bundlrs: String,
guppy: String,
body_embed: String,
}
#[get("/")]
@ -51,6 +52,7 @@ pub async fn home_request(req: HttpRequest, data: web::Data<pufferdb::AppData>)
auth_state: base.auth_state,
bundlrs: base.bundlrs,
guppy: base.guppy,
body_embed: base.body_embed,
}
.render()
.unwrap(),

View File

@ -167,6 +167,8 @@
<div class="toolbar-layout-wrapper" id="_page">
{% block content %}{% endblock %}
</div>
{{ body_embed|safe }}
</body>
</html>