Take in account instance's default license

Fix #145
This commit is contained in:
Bat 2018-07-27 20:31:47 +02:00
parent 6a062f78ff
commit fb2f4e9bcd
8 changed files with 84 additions and 6 deletions

View file

@ -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 ""

View file

@ -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 ""

View file

@ -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 ""

View file

@ -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ę"

View file

@ -364,9 +364,6 @@ msgstr ""
msgid "Instance settings"
msgstr ""
msgid "Name"
msgstr ""
msgid "Allow anyone to register"
msgstr ""

View file

@ -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<NewPostForm>, 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<NewPostForm>, user: User, conn: D
} else {
Err(Template::render("posts/new", json!({
"account": user,
"instance": Instance::get_local(&*conn),
"errors": errors.inner(),
"form": form
})))

View file

@ -17,12 +17,13 @@
</p>
</div>
{% 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='') %}
<label for="{{ name }}">
{{ label | _ }}
{% if optional %}
<small>{{ "Optional" | _ }}</small>
{% endif %}
<small>{{ details }}</small>
</label>
{% if errors is defined and errors[name] %}
{% for err in errors[name] %}

View file

@ -19,7 +19,8 @@
<label for="content">{{ "Content" | _ }}</label>
<textarea id="content" name="content" value="{{ form.content | default(value="") }}"></textarea>
{{ 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) }}
<input type="submit" value="{{ "Publish" | _ }}" />
</form>