From fb2f4e9bcdfb008a7b6df28d4b785bda2de473f6 Mon Sep 17 00:00:00 2001 From: Bat Date: Fri, 27 Jul 2018 20:31:47 +0200 Subject: [PATCH] Take in account instance's default license Fix #145 --- po/de.po | 18 ++++++++++++++++++ po/en.po | 18 ++++++++++++++++++ po/fr.po | 18 ++++++++++++++++++ po/pl.po | 18 ++++++++++++++++++ po/plume.pot | 3 --- src/routes/posts.rs | 9 ++++++++- templates/macros.html.tera | 3 ++- templates/posts/new.html.tera | 3 ++- 8 files changed, 84 insertions(+), 6 deletions(-) diff --git a/po/de.po b/po/de.po index 907385db..f3905a73 100644 --- a/po/de.po +++ b/po/de.po @@ -383,3 +383,21 @@ msgstr "" msgid "Instance settings" msgstr "" + +msgid "Allow anyone to register" +msgstr "" + +msgid "Short description" +msgstr "" + +msgid "Markdown is supported" +msgstr "" + +msgid "Long description" +msgstr "" + +msgid "Default license" +msgstr "" + +msgid "Save settings" +msgstr "" diff --git a/po/en.po b/po/en.po index 6b46a0b8..9f8cf5a9 100644 --- a/po/en.po +++ b/po/en.po @@ -370,3 +370,21 @@ msgstr "" msgid "Instance settings" msgstr "" + +msgid "Allow anyone to register" +msgstr "" + +msgid "Short description" +msgstr "" + +msgid "Markdown is supported" +msgstr "" + +msgid "Long description" +msgstr "" + +msgid "Default license" +msgstr "" + +msgid "Save settings" +msgstr "" diff --git a/po/fr.po b/po/fr.po index f6d0a96f..6127ddf8 100644 --- a/po/fr.po +++ b/po/fr.po @@ -379,3 +379,21 @@ msgstr "" msgid "Instance settings" msgstr "" + +msgid "Allow anyone to register" +msgstr "" + +msgid "Short description" +msgstr "" + +msgid "Markdown is supported" +msgstr "" + +msgid "Long description" +msgstr "" + +msgid "Default license" +msgstr "" + +msgid "Save settings" +msgstr "" diff --git a/po/pl.po b/po/pl.po index 37a8fd29..5b9d28c1 100644 --- a/po/pl.po +++ b/po/pl.po @@ -388,5 +388,23 @@ msgstr "" msgid "Instance settings" msgstr "" +msgid "Allow anyone to register" +msgstr "" + +msgid "Short description" +msgstr "" + +msgid "Markdown is supported" +msgstr "" + +msgid "Long description" +msgstr "" + +msgid "Default license" +msgstr "" + +msgid "Save settings" +msgstr "" + #~ msgid "Logowanie" #~ msgstr "Zaloguj siÄ™" diff --git a/po/plume.pot b/po/plume.pot index da17da39..45d2850e 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -364,9 +364,6 @@ msgstr "" msgid "Instance settings" msgstr "" -msgid "Name" -msgstr "" - msgid "Allow anyone to register" msgstr "" diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 24e44706..1fd4f4f2 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -14,6 +14,7 @@ use plume_models::{ blogs::*, db_conn::DbConn, comments::Comment, + instance::Instance, mentions::Mention, post_authors::*, posts::*, @@ -85,6 +86,7 @@ fn new(blog: String, user: User, conn: DbConn) -> Template { } else { Template::render("posts/new", json!({ "account": user, + "instance": Instance::get_local(&*conn), "errors": null, "form": null })) @@ -141,7 +143,11 @@ fn create(blog_name: String, data: LenientForm, user: User, conn: D title: form.title.to_string(), content: SafeString::new(&content), published: true, - license: form.license.to_string(), + license: if form.license.len() > 0 { + form.license.to_string() + } else { + Instance::get_local(&*conn).map(|i| i.default_license).unwrap_or(String::from("CC-0")) + }, ap_url: "".to_string(), creation_date: None }); @@ -164,6 +170,7 @@ fn create(blog_name: String, data: LenientForm, user: User, conn: D } else { Err(Template::render("posts/new", json!({ "account": user, + "instance": Instance::get_local(&*conn), "errors": errors.inner(), "form": form }))) diff --git a/templates/macros.html.tera b/templates/macros.html.tera index 0f9dbf69..50ec315d 100644 --- a/templates/macros.html.tera +++ b/templates/macros.html.tera @@ -17,12 +17,13 @@

{% endmacro post_card %} -{% macro input(name, label, errors, form, type="text", props="", optional=false, default='') %} +{% macro input(name, label, errors, form, type="text", props="", optional=false, default='', details='') %} {% if errors is defined and errors[name] %} {% for err in errors[name] %} diff --git a/templates/posts/new.html.tera b/templates/posts/new.html.tera index 6570ca5f..f1778c1f 100644 --- a/templates/posts/new.html.tera +++ b/templates/posts/new.html.tera @@ -19,7 +19,8 @@ - {{ macros::input(name="license", label="License", errors=errors, form=form, optional=true) }} + {% set license_infos = "Default license will be {{ instance.default_license }}" | _(instance=instance) %} + {{ macros::input(name="license", label="License", errors=errors, form=form, optional=true, details=license_infos) }}