23 lines
538 B
Rust
23 lines
538 B
Rust
|
use std::sync::Arc;
|
||
|
|
||
|
use poem::{
|
||
|
error::InternalServerError,
|
||
|
handler,
|
||
|
web::{Data, Html},
|
||
|
};
|
||
|
use tera::Context;
|
||
|
|
||
|
use crate::{app_state::AppState, templates::TEMPLATES};
|
||
|
|
||
|
#[handler]
|
||
|
pub async fn handler(state: Data<&Arc<AppState>>) -> Result<Html<String>, poem::Error> {
|
||
|
let recent_books = state.calibre.recent_books(50).unwrap();
|
||
|
|
||
|
let mut context = Context::new();
|
||
|
context.insert("books", &recent_books);
|
||
|
TEMPLATES
|
||
|
.render("recents", &context)
|
||
|
.map_err(InternalServerError)
|
||
|
.map(Html)
|
||
|
}
|