diff --git a/po/de.po b/po/de.po index 207df2c7..2d442bad 100644 --- a/po/de.po +++ b/po/de.po @@ -339,3 +339,9 @@ msgstr "" msgid "Optional" msgstr "" + +#, fuzzy +msgid "One article in this blog" +msgid_plural "{{ count }} articles 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 40764f17..3da7d51e 100644 --- a/po/en.po +++ b/po/en.po @@ -332,3 +332,8 @@ msgstr "" msgid "Optional" msgstr "" + +msgid "One article in this blog" +msgid_plural "{{ count }} articles in this blog" +msgstr[0] "" +msgstr[1] "" diff --git a/po/fr.po b/po/fr.po index 07e1fe9b..c58c2ae3 100644 --- a/po/fr.po +++ b/po/fr.po @@ -335,3 +335,9 @@ msgstr "" msgid "Optional" msgstr "Optionnel" + +#, fuzzy +msgid "One article in this blog" +msgid_plural "{{ count }} articles 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 69163662..086f0fa4 100644 --- a/po/pl.po +++ b/po/pl.po @@ -343,5 +343,12 @@ msgstr "" msgid "Optional" msgstr "Nieobowiązkowe" +#, fuzzy +msgid "One article in this blog" +msgid_plural "{{ count }} articles in this blog" +msgstr[0] "Ten blog ma jednego autora: " +msgstr[1] "Ten blog ma {{ count }} autorów: " +msgstr[2] "Ten blog ma {{ count }} autorów: " + #~ msgid "Logowanie" #~ msgstr "Zaloguj się" diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index d725a525..39df22a0 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -34,7 +34,9 @@ fn paginated_details(name: String, conn: DbConn, user: Option, page: Page) "posts": posts.into_iter().map(|p| p.to_json(&*conn)).collect::>(), "authors": authors.into_iter().map(|u| u.to_json(&*conn)).collect::>(), "n_authors": authors.len(), - "n_articles": articles.len() + "n_articles": articles.len(), + "page": page.page, + "n_pages": Page::total(articles.len() as i32) })) }) } diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 8bfd4cf0..c46fc2f2 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -61,6 +61,15 @@ impl Page { } } + /// Computes the total number of pages needed to display n_items + pub fn total(n_items: i32) -> i32 { + if n_items % ITEMS_PER_PAGE == 0 { + n_items / ITEMS_PER_PAGE + } else { + (n_items / ITEMS_PER_PAGE) + 1 + } + } + pub fn limits(&self) -> (i32, i32) { ((self.page - 1) * ITEMS_PER_PAGE, self.page * ITEMS_PER_PAGE) } diff --git a/templates/blogs/details.html.tera b/templates/blogs/details.html.tera index dd23af4d..9c484f60 100644 --- a/templates/blogs/details.html.tera +++ b/templates/blogs/details.html.tera @@ -36,5 +36,6 @@ {{ macros::post_card(article=article) }} {% endfor %} + {{ macros::paginate(page=page, total=n_pages) }} {% endblock content %} diff --git a/templates/macros.html.tera b/templates/macros.html.tera index d474a6be..e6b04564 100644 --- a/templates/macros.html.tera +++ b/templates/macros.html.tera @@ -35,3 +35,13 @@ {% endif %} {% endmacro input %} +{% macro paginate(page, total, previous="Previous page", next="Next page") %} + +{% endmacro %}