From 092ad5b79597f5f36a43eec76eda847e23a2fba1 Mon Sep 17 00:00:00 2001 From: Bat Date: Sat, 1 Sep 2018 17:39:40 +0100 Subject: [PATCH] Instance about page Fixes #39 --- plume-models/src/instance.rs | 12 +++++++++ po/de.po | 18 ++++++++++++++ po/en.po | 15 +++++++++++ po/fr.po | 29 +++++++++++++++++++--- po/gl.po | 33 ++++++++++++++++++++---- po/nb.po | 18 ++++++++++++++ po/pl.po | 18 ++++++++++++++ po/plume.pot | 12 +++++++++ src/main.rs | 1 + src/routes/instance.rs | 13 ++++++++++ static/main.css | 7 ++++++ templates/instance/about.html.tera | 40 ++++++++++++++++++++++++++++++ 12 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 templates/instance/about.html.tera diff --git a/plume-models/src/instance.rs b/plume-models/src/instance.rs index 5cb2a3f..d0d553e 100644 --- a/plume-models/src/instance.rs +++ b/plume-models/src/instance.rs @@ -72,6 +72,14 @@ impl Instance { .len() > 0 } + pub fn main_admin(&self, conn: &PgConnection) -> User { + users::table.filter(users::instance_id.eq(self.id)) + .filter(users::is_admin.eq(true)) + .limit(1) + .get_result::(conn) + .expect("Couldn't load admins") + } + pub fn compute_box(&self, prefix: &'static str, name: String, box_name: &'static str) -> String { ap_url(format!( "{instance}/{prefix}/{name}/{box_name}", @@ -96,4 +104,8 @@ impl Instance { )).get_result::(conn) .expect("Couldn't update instance") } + + pub fn count(conn: &PgConnection) -> i64 { + instances::table.count().get_result(conn).expect("Couldn't count instances") + } } diff --git a/po/de.po b/po/de.po index 9b4b2ec..950ef74 100644 --- a/po/de.po +++ b/po/de.po @@ -438,5 +438,23 @@ msgstr "Artikel geschrieben haben" msgid "Read the detailed rules" msgstr "Lies die detailierten Regeln" +#, fuzzy +msgid "Delete this article" +msgstr "Neueste Artikel" + +msgid "And connected to" +msgstr "" + +#, fuzzy +msgid "other instances" +msgstr "Über diese Instanz" + +#, fuzzy +msgid "Administred by" +msgstr "Administration" + +msgid "Runs Plume {{ version }}" +msgstr "" + #~ msgid "Your password should be at least 8 characters long" #~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein" diff --git a/po/en.po b/po/en.po index d365eb0..5403fc1 100644 --- a/po/en.po +++ b/po/en.po @@ -430,3 +430,18 @@ msgstr "" msgid "Read the detailed rules" msgstr "" + +msgid "Delete this article" +msgstr "" + +msgid "And connected to" +msgstr "" + +msgid "other instances" +msgstr "" + +msgid "Administred by" +msgstr "" + +msgid "Runs Plume {{ version }}" +msgstr "" diff --git a/po/fr.po b/po/fr.po index 7d7c5d7..043b53c 100644 --- a/po/fr.po +++ b/po/fr.po @@ -256,7 +256,8 @@ msgid "You need to be logged in order to edit your profile" msgstr "Vous devez vous connecter pour modifier votre profil" msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" -msgstr "Par {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" +msgstr "" +"Par {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" msgid "{{ data }} reshared your article" msgstr "{{ data }} a repartagé votre article" @@ -407,14 +408,16 @@ msgid "Plume is a decentralized blogging engine." msgstr "Plume est un moteur de blog décentralisé." msgid "Authors can manage various blogs from an unique website." -msgstr "Les auteur⋅ice⋅s peuvent gérer différents blogs au sein d'un même site." +msgstr "" +"Les auteur⋅ice⋅s peuvent gérer différents blogs au sein d'un même site." msgid "" "Articles are also visible on other Plume websites, and you can interact with " "them directly from other platforms like Mastodon." msgstr "" -"Les articles sont également visibles sur d'autres sites Plume, et vous pouvez " -"interagir avec directement depuis d'autres plateformes telles que Mastodon." +"Les articles sont également visibles sur d'autres sites Plume, et vous " +"pouvez interagir avec directement depuis d'autres plateformes telles que " +"Mastodon." msgid "Create your account" msgstr "Créer votre compte" @@ -437,5 +440,23 @@ msgstr "articles" msgid "Read the detailed rules" msgstr "Lire les règles détaillées" +#, fuzzy +msgid "Delete this article" +msgstr "Derniers articles" + +msgid "And connected to" +msgstr "" + +#, fuzzy +msgid "other instances" +msgstr "À propos de cette instance" + +#, fuzzy +msgid "Administred by" +msgstr "Administration" + +msgid "Runs Plume {{ version }}" +msgstr "" + #~ msgid "Your password should be at least 8 characters long" #~ msgstr "Votre mot de passe doit faire au moins 8 caractères." diff --git a/po/gl.po b/po/gl.po index d27b2f6..3b1247b 100644 --- a/po/gl.po +++ b/po/gl.po @@ -68,7 +68,8 @@ msgstr "Notificacións" msgid "" "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" -msgstr "Escrito por {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" +msgstr "" +"Escrito por {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" msgid "This article is under the {{ license }} license." msgstr "Este artigo ten licenza {{ license }}" @@ -251,7 +252,8 @@ msgid "You need to be logged in order to edit your profile" msgstr "Debe estar conectada para editar o seu perfil" msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" -msgstr "Por {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" +msgstr "" +"Por {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" msgid "{{ data }} reshared your article" msgstr "{{ data }} comparteu o seu artigo" @@ -322,7 +324,9 @@ msgstr[0] "Unha autora en este blog: " msgstr[1] "{{ count }} autoras en este blog: " msgid "Login or use your Fediverse account to interact with this article" -msgstr "Conéctese ou utilice a súa conta no fediverso para interactuar con este artigo" +msgstr "" +"Conéctese ou utilice a súa conta no fediverso para interactuar con este " +"artigo" msgid "Optional" msgstr "Opcional" @@ -401,8 +405,9 @@ msgstr "As autoras poden xestionar varios blogs desde un único sitio web." msgid "" "Articles are also visible on other Plume websites, and you can interact with " "them directly from other platforms like Mastodon." -msgstr "Os artigos son visibles tamén en outros sitios Plume, e pode interactuar con" -"eles desde outras plataformas como Mastadon." +msgstr "" +"Os artigos son visibles tamén en outros sitios Plume, e pode interactuar " +"coneles desde outras plataformas como Mastadon." msgid "Create your account" msgstr "Cree a súa conta" @@ -424,3 +429,21 @@ msgstr "artigos" msgid "Read the detailed rules" msgstr "Lea o detalle das normas" + +#, fuzzy +msgid "Delete this article" +msgstr "Últimos artigos" + +msgid "And connected to" +msgstr "" + +#, fuzzy +msgid "other instances" +msgstr "Sobre esta instancia" + +#, fuzzy +msgid "Administred by" +msgstr "Administración" + +msgid "Runs Plume {{ version }}" +msgstr "" diff --git a/po/nb.po b/po/nb.po index c7d7b1c..6482079 100644 --- a/po/nb.po +++ b/po/nb.po @@ -433,5 +433,23 @@ msgstr "artikler" msgid "Read the detailed rules" msgstr "Les reglene" +#, fuzzy +msgid "Delete this article" +msgstr "Siste artikler" + +msgid "And connected to" +msgstr "" + +#, fuzzy +msgid "other instances" +msgstr "Om denne instansen" + +#, fuzzy +msgid "Administred by" +msgstr "Administrasjon" + +msgid "Runs Plume {{ version }}" +msgstr "" + #~ msgid "Your password should be at least 8 characters long" #~ msgstr "Passordet ditt må bestå av minst åtte tegn" diff --git a/po/pl.po b/po/pl.po index 3d0367f..30ba204 100644 --- a/po/pl.po +++ b/po/pl.po @@ -444,6 +444,24 @@ msgstr "artykuły" msgid "Read the detailed rules" msgstr "Przeczytaj szczegółowe zasady" +#, fuzzy +msgid "Delete this article" +msgstr "Najnowsze artykuły" + +msgid "And connected to" +msgstr "" + +#, fuzzy +msgid "other instances" +msgstr "O tej instancji" + +#, fuzzy +msgid "Administred by" +msgstr "Administracja" + +msgid "Runs Plume {{ version }}" +msgstr "" + #~ msgid "Your password should be at least 8 characters long" #~ msgstr "Twoje hasło musi składać się przynajmniej z 8 znaków" diff --git a/po/plume.pot b/po/plume.pot index aeff569..3780c29 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -423,3 +423,15 @@ msgstr "" msgid "Delete this article" msgstr "" + +msgid "And connected to" +msgstr "" + +msgid "other instances" +msgstr "" + +msgid "Administred by" +msgstr "" + +msgid "Runs Plume {{ version }}" +msgstr "" diff --git a/src/main.rs b/src/main.rs index 1b7acb2..e93429e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,7 @@ fn main() { routes::instance::update_settings, routes::instance::shared_inbox, routes::instance::nodeinfo, + routes::instance::about, routes::likes::create, routes::likes::create_auth, diff --git a/src/routes/instance.rs b/src/routes/instance.rs index cf8ec98..b4f395f 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -123,3 +123,16 @@ fn nodeinfo(conn: DbConn) -> Json { "metadata": {} })) } + +#[get("/about")] +fn about(user: User, conn: DbConn) -> Template { + Template::render("instance/about", json!({ + "account": user, + "instance": Instance::get_local(&*conn), + "admin": Instance::get_local(&*conn).map(|i| i.main_admin(&*conn).to_json(&*conn)), + "version": "0.1.0", + "n_users": User::count_local(&*conn), + "n_articles": Post::count_local(&*conn), + "n_instances": Instance::count(&*conn) - 1 + })) +} diff --git a/static/main.css b/static/main.css index d2c05ba..a53268b 100644 --- a/static/main.css +++ b/static/main.css @@ -42,6 +42,13 @@ small { margin: 4rem 0; } +.banner { + background: #DADADA; + padding-top: 2em; + padding-bottom: 1em; + margin: 3em 0px; +} + /* * == Header == */ diff --git a/templates/instance/about.html.tera b/templates/instance/about.html.tera new file mode 100644 index 0000000..69a70e3 --- /dev/null +++ b/templates/instance/about.html.tera @@ -0,0 +1,40 @@ +{% extends "base" %} +{% import "macros" as macros %} + +{% block title %} +About {{ instance.name }} +{% endblock title %} + +{% block content %} +

{{ "About {{ instance_name }}" | _(instance_name=instance.name) }}

+
+ {{ instance.short_description_html | safe }} +
+ +
+ {{ instance.long_description_html | safe }} +
+{% endblock content %}