Nekrocuck

This commit is contained in:
sneedmaster
2025-09-28 12:59:09 +02:00
commit a2d093954d
402 changed files with 13763 additions and 0 deletions

53
src/web/mod.rs Normal file
View File

@@ -0,0 +1,53 @@
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)
}