Show the total number of article on a blog

fixes #150
This commit is contained in:
Kevin "Ilphrin" Pellet
2018-07-21 16:58:30 +02:00
parent 7319cf9829
commit cd24b0f057
3 changed files with 13 additions and 2 deletions
+3 -1
View File
@@ -23,6 +23,7 @@ use plume_models::{
fn details(name: String, conn: DbConn, user: Option<User>) -> Template {
may_fail!(user, Blog::find_by_fqn(&*conn, name), "Requested blog couldn't be found", |blog| {
let recents = Post::get_recents_for_blog(&*conn, &blog, 5);
let articles = Post::get_for_blog(&*conn, &blog);
let authors = &blog.list_authors(&*conn);
Template::render("blogs/details", json!({
@@ -31,7 +32,8 @@ fn details(name: String, conn: DbConn, user: Option<User>) -> Template {
"is_author": user.map(|x| x.is_author_in(&*conn, blog.clone())),
"recents": recents.into_iter().map(|p| p.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
"authors": authors.into_iter().map(|u| u.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
"n_authors": authors.len()
"n_authors": authors.len(),
"n_articles": articles.len()
}))
})
}