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" msgid "Instance settings"
msgstr "" 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" msgid "Instance settings"
msgstr "" 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" msgid "Instance settings"
msgstr "" 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" msgid "Instance settings"
msgstr "" 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" #~ msgid "Logowanie"
#~ msgstr "Zaloguj się" #~ msgstr "Zaloguj się"

View File

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

View File

@ -14,6 +14,7 @@ use plume_models::{
blogs::*, blogs::*,
db_conn::DbConn, db_conn::DbConn,
comments::Comment, comments::Comment,
instance::Instance,
mentions::Mention, mentions::Mention,
post_authors::*, post_authors::*,
posts::*, posts::*,
@ -85,6 +86,7 @@ fn new(blog: String, user: User, conn: DbConn) -> Template {
} else { } else {
Template::render("posts/new", json!({ Template::render("posts/new", json!({
"account": user, "account": user,
"instance": Instance::get_local(&*conn),
"errors": null, "errors": null,
"form": null "form": null
})) }))
@ -141,7 +143,11 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, user: User, conn: D
title: form.title.to_string(), title: form.title.to_string(),
content: SafeString::new(&content), content: SafeString::new(&content),
published: true, 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(), ap_url: "".to_string(),
creation_date: None creation_date: None
}); });
@ -164,6 +170,7 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, user: User, conn: D
} else { } else {
Err(Template::render("posts/new", json!({ Err(Template::render("posts/new", json!({
"account": user, "account": user,
"instance": Instance::get_local(&*conn),
"errors": errors.inner(), "errors": errors.inner(),
"form": form "form": form
}))) })))

View File

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

View File

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