diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index bd2a0a31..7123d36a 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -23,6 +23,7 @@ use plume_common::activity_pub::{ sign }; use instance::*; +use users::User; use schema::blogs; pub type CustomGroup = CustomObject; @@ -68,6 +69,15 @@ impl Blog { Instance::get(conn, self.instance_id).expect("Couldn't find instance") } + pub fn list_authors(&self, conn: &PgConnection) -> Vec { + use schema::blog_authors; + use schema::users; + let authors_ids = blog_authors::table.filter(blog_authors::blog_id.eq(self.id)).select(blog_authors::author_id); + users::table.filter(users::id.eq(any(authors_ids))) + .load::(conn) + .expect("Couldn't load authors of a blog") + } + pub fn find_for_author(conn: &PgConnection, author_id: i32) -> Vec { use schema::blog_authors; let author_ids = blog_authors::table.filter(blog_authors::author_id.eq(author_id)).select(blog_authors::blog_id); diff --git a/po/de.po b/po/de.po index ec86afe8..5a870f9a 100644 --- a/po/de.po +++ b/po/de.po @@ -327,3 +327,9 @@ msgstr "" msgid "Password should be at least 8 characters long" msgstr "" + +#, fuzzy +msgid "One author in this blog: " +msgid_plural "{{ count }} authors in this blog: " +msgstr[0] "Du bist kein Autor in diesem Blog." +msgstr[1] "Du bist kein Autor in diesem Blog." diff --git a/po/en.po b/po/en.po index 7e3192fe..ea0cd335 100644 --- a/po/en.po +++ b/po/en.po @@ -321,3 +321,8 @@ msgstr "" msgid "Password should be at least 8 characters long" msgstr "" + +msgid "One author in this blog: " +msgid_plural "{{ count }} authors in this blog: " +msgstr[0] "" +msgstr[1] "" diff --git a/po/fr.po b/po/fr.po index 5de44dde..4d8f0db7 100644 --- a/po/fr.po +++ b/po/fr.po @@ -70,7 +70,8 @@ msgstr "Notifications" msgid "" "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" -msgstr "Écrit par {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" +msgstr "" +"Écrit par {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" msgid "This article is under the {{ license }} license." msgstr "Cet article est placé sous la licence {{ license }}" @@ -303,7 +304,9 @@ msgid "A post with the same title already exists." msgstr "Un article avec le même titre existe déjà." msgid "We need an email or a username to identify you" -msgstr "Nous avons besoin d'une adresse mail ou d'un nom d'utilisateur pour vous identifier." +msgstr "" +"Nous avons besoin d'une adresse mail ou d'un nom d'utilisateur pour vous " +"identifier." msgid "Your password should be at least 8 characters long" msgstr "Votre mot de passe doit faire au moins 8 caractères." @@ -319,3 +322,8 @@ msgstr "Adresse mail invalide" msgid "Password should be at least 8 characters long" msgstr "Le mot de passe doit faire au moins 8 caractères." + +msgid "One author in this blog: " +msgid_plural "{{ count }} authors in this blog: " +msgstr[0] "{{ count }} aut⋅eur⋅rice dans ce blog : " +msgstr[1] "{{ count }} aut⋅eur⋅rice⋅s dans ce blog : " diff --git a/po/pl.po b/po/pl.po index 6f5c7e5c..63ecaa83 100644 --- a/po/pl.po +++ b/po/pl.po @@ -329,5 +329,12 @@ msgstr "Nieprawidłowy adres e-mail" msgid "Password should be at least 8 characters long" msgstr "Hasło musi składać się z przynajmniej 8 znaków" +#, fuzzy +msgid "One author in this blog: " +msgid_plural "{{ count }} authors in this blog: " +msgstr[0] "Nie jesteś autorem tego bloga." +msgstr[1] "Nie jesteś autorem tego bloga." +msgstr[2] "Nie jesteś autorem tego bloga." + #~ msgid "Logowanie" #~ msgstr "Zaloguj się" diff --git a/po/plume.pot b/po/plume.pot index ccb727e3..a5c0d95c 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -315,3 +315,7 @@ msgstr "" msgid "Password should be at least 8 characters long" msgstr "" +msgid "One author in this blog: " +msgid_plural "{{ count }} authors in this blog: " +msgstr[0] "" +msgstr[1] "" diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 1a2b0104..1a42f405 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -23,12 +23,15 @@ use plume_models::{ fn details(name: String, conn: DbConn, user: Option) -> 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 authors = &blog.list_authors(&*conn); Template::render("blogs/details", json!({ - "blog": blog, + "blog": &blog, "account": user, - "is_author": user.map(|x| x.is_author_in(&*conn, blog)), - "recents": recents.into_iter().map(|p| p.to_json(&*conn)).collect::>() + "is_author": user.map(|x| x.is_author_in(&*conn, blog.clone())), + "recents": recents.into_iter().map(|p| p.to_json(&*conn)).collect::>(), + "authors": authors.into_iter().map(|u| u.to_json(&*conn)).collect::>(), + "n_authors": authors.len() })) }) } diff --git a/templates/blogs/details.html.tera b/templates/blogs/details.html.tera index ed9994a9..40ddf629 100644 --- a/templates/blogs/details.html.tera +++ b/templates/blogs/details.html.tera @@ -8,6 +8,17 @@ {% block content %}

{{ blog.title }} (~{{ blog.actor_id }})

{{ blog.summary }}

+

+ {{ "{{ count }} authors in this blog: " | _n(singular="One author in this blog: ", count = n_authors) }} + {% for author in authors %} + {% if author.display_name %} + {% set name = author.display_name %} + {% else %} + {% set name = author.username %} + {% endif %} + {{ name }}{% if not loop.last %},{% endif %} + {% endfor %} +

{{ "Latest articles" | _ }}