54 lines
1.1 KiB
Rust
54 lines
1.1 KiB
Rust
pub mod actions;
|
|
pub mod board;
|
|
pub mod board_catalog;
|
|
pub mod captcha;
|
|
pub mod edit_posts;
|
|
pub mod index;
|
|
pub mod ip_posts;
|
|
pub mod live;
|
|
pub mod login;
|
|
pub mod logout;
|
|
pub mod news;
|
|
pub mod overboard;
|
|
pub mod overboard_catalog;
|
|
pub mod page;
|
|
pub mod search;
|
|
pub mod staff;
|
|
pub mod tcx;
|
|
pub mod thread;
|
|
pub mod thread_json;
|
|
|
|
use actix_web::{http::StatusCode, HttpRequest, HttpResponse, HttpResponseBuilder};
|
|
use askama::Template;
|
|
|
|
use self::tcx::TemplateCtx;
|
|
use crate::{ctx::Ctx, db::models::Ban, error::NekrochanError, filters};
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "banned.html")]
|
|
struct BannedTemplate {
|
|
tcx: TemplateCtx,
|
|
ban: Ban,
|
|
}
|
|
|
|
pub async fn ban_response(
|
|
ctx: &Ctx,
|
|
req: &HttpRequest,
|
|
ban: Ban,
|
|
) -> Result<HttpResponse, NekrochanError> {
|
|
let tcx = TemplateCtx::new(ctx, req).await?;
|
|
|
|
template_response(&BannedTemplate { tcx, ban })
|
|
}
|
|
|
|
pub fn template_response<T>(template: &T) -> Result<HttpResponse, NekrochanError>
|
|
where
|
|
T: Template,
|
|
{
|
|
let res = HttpResponseBuilder::new(StatusCode::OK)
|
|
.append_header(("Content-Type", "text/html"))
|
|
.body(template.render()?);
|
|
|
|
Ok(res)
|
|
}
|