31 lines
730 B
Rust
31 lines
730 B
Rust
use actix_web::{get, web::Data, HttpRequest, HttpResponse};
|
|
use askama::Template;
|
|
|
|
use crate::{
|
|
ctx::Ctx,
|
|
db::models::Post,
|
|
error::NekrochanError,
|
|
filters,
|
|
web::{tcx::TemplateCtx, template_response},
|
|
};
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "overboard-catalog.html")]
|
|
struct OverboardCatalogTemplate {
|
|
tcx: TemplateCtx,
|
|
threads: Vec<Post>,
|
|
}
|
|
|
|
#[get("/overboard/catalog")]
|
|
pub async fn overboard_catalog(
|
|
ctx: Data<Ctx>,
|
|
req: HttpRequest,
|
|
) -> Result<HttpResponse, NekrochanError> {
|
|
let tcx = TemplateCtx::new(&ctx, &req).await?;
|
|
let threads = Post::read_overboard_catalog(&ctx).await?;
|
|
|
|
let template = OverboardCatalogTemplate { tcx, threads };
|
|
|
|
template_response(&template)
|
|
}
|