From e9b2a20ad3e5db0acc02d1fe0277d2b1a3e0b9fe Mon Sep 17 00:00:00 2001 From: Trinity Pointard Date: Fri, 20 Jul 2018 17:24:34 +0200 Subject: [PATCH 1/4] Update dependancie to rocket_csrf fix #117 --- Cargo.lock | 25 +++++++++++++------------ Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3173b306..760bc6c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,7 +210,7 @@ dependencies = [ "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -236,7 +236,7 @@ source = "git+https://github.com/alexcrichton/cookie-rs?rev=0365a18#0365a18e4518 dependencies = [ "base64 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -537,7 +537,7 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -560,7 +560,7 @@ dependencies = [ "mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -996,7 +996,7 @@ dependencies = [ "rocket 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)", "rocket_codegen 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)", "rocket_contrib 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)", - "rocket_csrf 0.1.0 (git+https://github.com/fdb-hiroshima/rocket_csrf?rev=13ca47ef73be86cef9caca30c516e4e95f3051ce)", + "rocket_csrf 0.1.0 (git+https://github.com/fdb-hiroshima/rocket_csrf?branch=plume)", "rocket_i18n 0.1.1 (git+https://github.com/BaptisteGelez/rocket_i18n?rev=5b4225d5bed5769482dc926a7e6d6b79f1217be6)", "rpassword 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1285,7 +1285,7 @@ dependencies = [ "rocket_codegen_next 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)", "rocket_http 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)", "state 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "yansi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1328,13 +1328,14 @@ dependencies = [ [[package]] name = "rocket_csrf" version = "0.1.0" -source = "git+https://github.com/fdb-hiroshima/rocket_csrf?rev=13ca47ef73be86cef9caca30c516e4e95f3051ce#13ca47ef73be86cef9caca30c516e4e95f3051ce" +source = "git+https://github.com/fdb-hiroshima/rocket_csrf?branch=plume#5309b7634a9cd204d003312cb70ce9d36b660e6b" dependencies = [ "csrf 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "rocket 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)", "serde 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1348,7 +1349,7 @@ dependencies = [ "pear 0.1.0 (git+http://github.com/SergioBenitez/Pear?rev=54667ae)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1381,7 +1382,7 @@ dependencies = [ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1680,7 +1681,7 @@ dependencies = [ [[package]] name = "time" -version = "0.1.39" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2195,7 +2196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rocket_codegen 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)" = "" "checksum rocket_codegen_next 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)" = "" "checksum rocket_contrib 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)" = "" -"checksum rocket_csrf 0.1.0 (git+https://github.com/fdb-hiroshima/rocket_csrf?rev=13ca47ef73be86cef9caca30c516e4e95f3051ce)" = "" +"checksum rocket_csrf 0.1.0 (git+https://github.com/fdb-hiroshima/rocket_csrf?branch=plume)" = "" "checksum rocket_http 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket?rev=df7111143e466c18d1f56377a8d9530a5a306aba)" = "" "checksum rocket_i18n 0.1.1 (git+https://github.com/BaptisteGelez/rocket_i18n?rev=5b4225d5bed5769482dc926a7e6d6b79f1217be6)" = "" "checksum rpassword 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d127299b02abda51634f14025aec43ae87a7aa7a95202b6a868ec852607d1451" @@ -2236,7 +2237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508" "checksum tera 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e815b67d44c26feb06630011fb58b5b243f4e9585aac1ed0592c5795de64cd75" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" -"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" +"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" "checksum tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "be15ef40f675c9fe66e354d74c73f3ed012ca1aa14d65846a33ee48f1ae8d922" "checksum tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" "checksum tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cac2a7883ff3567e9d66bb09100d09b33d90311feca0206c7ca034bc0c55113" diff --git a/Cargo.toml b/Cargo.toml index 75522b0c..84d25c07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ rev = "df7111143e466c18d1f56377a8d9530a5a306aba" [dependencies.rocket_csrf] git = "https://github.com/fdb-hiroshima/rocket_csrf" -rev = "13ca47ef73be86cef9caca30c516e4e95f3051ce" +branch = "plume" [dependencies.rocket_i18n] git = "https://github.com/BaptisteGelez/rocket_i18n" From 114a5295bb0b88d791ac06ab48e5705ac7e9ff65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Fri, 20 Jul 2018 20:56:04 +0200 Subject: [PATCH 2/4] i18n: Update Polish translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak --- po/pl.po | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/po/pl.po b/po/pl.po index e57f447a..69163662 100644 --- a/po/pl.po +++ b/po/pl.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: plume\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-15 16:33-0700\n" -"PO-Revision-Date: 2018-07-16 11:26+0200\n" +"PO-Revision-Date: 2018-07-20 20:55+0200\n" "Last-Translator: Marcin Mikołajczak \n" "Language-Team: none\n" "Language: pl\n" @@ -329,18 +329,19 @@ 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." +msgstr[0] "Ten blog ma jednego autora: " +msgstr[1] "Ten blog ma {{ count }} autorów: " +msgstr[2] "Ten blog ma {{ count }} autorów: " msgid "Login or use your Fediverse account to interact with this article" msgstr "" +"Zaloguj się lub użyj konta w Fediwersum, aby wejść w interakcje z tym " +"artykułem" msgid "Optional" -msgstr "" +msgstr "Nieobowiązkowe" #~ msgid "Logowanie" #~ msgstr "Zaloguj się" From cd24b0f057c065e468ae4fc7ff910d07f2c0e447 Mon Sep 17 00:00:00 2001 From: "Kevin \"Ilphrin\" Pellet" Date: Sat, 21 Jul 2018 16:58:30 +0200 Subject: [PATCH 3/4] Show the total number of article on a blog fixes #150 --- plume-models/src/posts.rs | 6 ++++++ src/routes/blogs.rs | 4 +++- templates/blogs/details.html.tera | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 856ec349..5a04b9f8 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -91,6 +91,12 @@ impl Post { .expect("Error loading recent posts for blog") } + pub fn get_for_blog(conn: &PgConnection, blog:&Blog) -> Vec { + posts::table.filter(posts::blog_id.eq(blog.id)) + .load::(conn) + .expect("Error loading posts for blog") + } + pub fn get_authors(&self, conn: &PgConnection) -> Vec { use schema::users; use schema::post_authors; diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 1a42f405..6ce0a874 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -23,6 +23,7 @@ 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 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) -> Template { "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() + "n_authors": authors.len(), + "n_articles": articles.len() })) }) } diff --git a/templates/blogs/details.html.tera b/templates/blogs/details.html.tera index 96d805c1..37799663 100644 --- a/templates/blogs/details.html.tera +++ b/templates/blogs/details.html.tera @@ -19,7 +19,10 @@ {{ name }}{% if not loop.last %},{% endif %} {% endfor %}

- +

+ {{ "{{ count }} articles in this blog" | _n(singular="One article in this blog", count = n_articles) }} +

+

{{ "Latest articles" | _ }}

{% if recents | length < 1 %} From 4b84fb7ed0fb1d151a04769031a5d096b8ba03af Mon Sep 17 00:00:00 2001 From: "Kevin \"Ilphrin\" Pellet" Date: Sat, 21 Jul 2018 20:59:47 +0200 Subject: [PATCH 4/4] Add translation string for article count on blog --- po/plume.pot | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/po/plume.pot b/po/plume.pot index 0fdd5303..c61456af 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -325,3 +325,8 @@ msgstr "" msgid "Optional" msgstr "" + +msgid "One article in this blog" +msgid_plural "{{ count }} articles in this blog" +msgstr[0] "" +msgstr[1] ""