2024-05-06 08:55:18 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2024-05-06 11:51:49 +00:00
|
|
|
use calibre_db::data::pagination::SortOrder;
|
|
|
|
use poem::{
|
|
|
|
handler,
|
|
|
|
web::{Data, Html, Path},
|
|
|
|
};
|
2024-05-06 08:55:18 +00:00
|
|
|
|
2024-05-06 11:51:49 +00:00
|
|
|
use crate::{app_state::AppState, handlers::paginated};
|
2024-05-06 08:55:18 +00:00
|
|
|
|
|
|
|
#[handler]
|
2024-05-06 11:51:49 +00:00
|
|
|
pub async fn handler_init(state: Data<&Arc<AppState>>) -> Result<Html<String>, poem::Error> {
|
|
|
|
paginated::render(
|
|
|
|
"authors",
|
|
|
|
|| state.calibre.authors(25, None, &SortOrder::ASC),
|
|
|
|
|author| author.sort.clone(),
|
|
|
|
|cursor| state.calibre.has_previous_authors(cursor),
|
|
|
|
|cursor| state.calibre.has_more_authors(cursor),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[handler]
|
|
|
|
pub async fn handler(
|
|
|
|
Path((cursor, sort_order)): Path<(String, SortOrder)>,
|
|
|
|
state: Data<&Arc<AppState>>,
|
|
|
|
) -> Result<Html<String>, poem::Error> {
|
|
|
|
paginated::render(
|
|
|
|
"authors",
|
|
|
|
|| state.calibre.authors(25, Some(&cursor), &sort_order),
|
|
|
|
|author| author.sort.clone(),
|
|
|
|
|cursor| state.calibre.has_previous_authors(cursor),
|
|
|
|
|cursor| state.calibre.has_more_authors(cursor),
|
|
|
|
)
|
2024-05-06 08:55:18 +00:00
|
|
|
}
|