Add an interface to select an article illustration

fix-mobile-margin
Baptiste Gelez 6 years ago
parent ab5edbc6a5
commit 485aac2e20

@ -32,6 +32,7 @@ use safe_string::SafeString;
use std::collections::HashSet;
#[derive(Queryable, Identifiable, Serialize, Clone, AsChangeset)]
#[changeset_options(treat_none_as_null = "true")]
pub struct Post {
pub id: i32,
pub blog_id: i32,

@ -614,3 +614,9 @@ msgstr ""
msgid "There is currently no article with that tag"
msgstr ""
msgid "Illustration"
msgstr ""
msgid "None"
msgstr ""

@ -630,3 +630,10 @@ msgstr "Cet article nest pas encore publié."
msgid "There is currently no article with that tag"
msgstr "Il n'y a pas encore d'article avec ce tag"
#, fuzzy
msgid "Illustration"
msgstr "Administration"
msgid "None"
msgstr ""

@ -617,3 +617,10 @@ msgstr "Esto é un borrador, non publicar por agora."
msgid "There is currently no article with that tag"
msgstr ""
#, fuzzy
msgid "Illustration"
msgstr "Administración"
msgid "None"
msgstr ""

@ -66,8 +66,10 @@ msgstr "Benvenuto su {{ instance_name | escape }}"
msgid "Notifications"
msgstr "Notifiche"
msgid "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
msgstr "Scritto da {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
msgid ""
"Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
msgstr ""
"Scritto da {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
msgid "This article is under the {{ license }} license."
msgstr "Questo articolo è rilasciato con licenza {{ license }} ."
@ -131,7 +133,9 @@ msgid "Your Blogs"
msgstr "I Tuoi Blogs"
msgid "You don't have any blog yet. Create your own, or ask to join one."
msgstr "Non hai ancora nessun blog. Crea il tuo, oppure chiedi di unirti ad uno esistente."
msgstr ""
"Non hai ancora nessun blog. Crea il tuo, oppure chiedi di unirti ad uno "
"esistente."
msgid "Start a new blog"
msgstr "Inizia un nuovo blog"
@ -250,7 +254,8 @@ msgid "You need to be logged in order to edit your profile"
msgstr "Devi effettuare l'accesso per modificare il tuo profilo"
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}"
msgstr "Per {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}"
msgstr ""
"Per {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}"
msgid "{{ data }} boosted your article"
msgstr "{{ data }} ha boostato il tuo articolo"
@ -321,7 +326,9 @@ msgstr[0] "Un autore in questo blog: "
msgstr[1] "{{ count }} autori in questo blog: "
msgid "Login or use your Fediverse account to interact with this article"
msgstr "Accedi o utilizza un tuo account del Fediverso per interagire con questo articolo"
msgstr ""
"Accedi o utilizza un tuo account del Fediverso per interagire con questo "
"articolo"
msgid "Optional"
msgstr "Opzionale"
@ -397,8 +404,12 @@ msgstr "Plume è un motore di blog decentralizzato."
msgid "Authors can manage various blogs from an unique website."
msgstr "Gli autori possono gestire vari blog da un unico sito."
msgid "Articles are also visible on other Plume websites, and you can interact with them directly from other platforms like Mastodon."
msgstr "Gli articoli sono visibili anche da altri siti Plume, e puoi interagire con loro direttamente da altre piattaforme come Mastodon."
msgid ""
"Articles are also visible on other Plume websites, and you can interact with "
"them directly from other platforms like Mastodon."
msgstr ""
"Gli articoli sono visibili anche da altri siti Plume, e puoi interagire con "
"loro direttamente da altre piattaforme come Mastodon."
msgid "Create your account"
msgstr "Crea il tuo account"
@ -487,8 +498,11 @@ msgstr "File"
msgid "Send"
msgstr "Invia"
msgid "Sorry, but registrations are closed on this instance. Try to find another one"
msgstr "Scusa, ma le registrazioni sono chiuse su questa istanza. Prova a cercarne un'altra"
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
"Scusa, ma le registrazioni sono chiuse su questa istanza. Prova a cercarne "
"un'altra"
msgid "Subtitle"
msgstr "Sottotitolo"
@ -541,8 +555,14 @@ msgstr "Non riusciamo a trovare questa pagina."
msgid "Invalid CSRF token."
msgstr "Token CSRF non valido."
msgid "Something is wrong with your CSRF token. Make sure cookies are enabled in you browser, and try reloading this page. If you continue to see this error message, please report it."
msgstr "Qualcosa è andato storto con il tuo token CSRF. Assicurati di aver abilitato i cookies nel tuo browser, e prova a ricaricare questa pagina. Se l'errore si dovesse ripresentare, per favore segnalacelo."
msgid ""
"Something is wrong with your CSRF token. Make sure cookies are enabled in "
"you browser, and try reloading this page. If you continue to see this error "
"message, please report it."
msgstr ""
"Qualcosa è andato storto con il tuo token CSRF. Assicurati di aver abilitato "
"i cookies nel tuo browser, e prova a ricaricare questa pagina. Se l'errore "
"si dovesse ripresentare, per favore segnalacelo."
msgid "Administration of {{ instance.name }}"
msgstr "Amministrazione di {{ instance.name }}"
@ -581,13 +601,15 @@ msgid "Danger zone"
msgstr "Zona pericolosa"
msgid "Be very careful, any action taken here can't be cancelled."
msgstr "Fai molta attenzione, qualsiasi azione fatta qui non può essere annullata."
msgstr ""
"Fai molta attenzione, qualsiasi azione fatta qui non può essere annullata."
msgid "Delete your account"
msgstr "Elimina il tuo account"
msgid "Sorry, but as an admin, you can't leave your instance."
msgstr "Scusa, ma essendo tu un amministratore, non puoi abbandonare la tua istanza."
msgstr ""
"Scusa, ma essendo tu un amministratore, non puoi abbandonare la tua istanza."
msgid "Users"
msgstr "Utenti"
@ -597,3 +619,10 @@ msgstr "Questo post non è ancora stato pubblicato."
msgid "There is currently no article with that tag"
msgstr "Attualmente non è ancora presente nessun articolo con quell'etichetta"
#, fuzzy
msgid "Illustration"
msgstr "Amministrazione"
msgid "None"
msgstr ""

@ -639,6 +639,13 @@ msgstr ""
msgid "There is currently no article with that tag"
msgstr ""
#, fuzzy
msgid "Illustration"
msgstr "Administrasjon"
msgid "None"
msgstr ""
#~ msgid "One reshare"
#~ msgid_plural "{{ count }} reshares"
#~ msgstr[0] "Én deling"

@ -629,6 +629,13 @@ msgstr "Ten wpis nie został jeszcze opublikowany."
msgid "There is currently no article with that tag"
msgstr ""
#, fuzzy
msgid "Illustration"
msgstr "Administracja"
msgid "None"
msgstr ""
#~ msgid "One reshare"
#~ msgid_plural "{{ count }} reshares"
#~ msgstr[0] "Jedno udostępnienie"

@ -597,3 +597,9 @@ msgstr ""
msgid "There is currently no article with that tag"
msgstr ""
msgid "Illustration"
msgstr ""
msgid "None"
msgstr ""

@ -16,6 +16,7 @@ use plume_models::{
db_conn::DbConn,
comments::Comment,
instance::Instance,
medias::Media,
mentions::Mention,
post_authors::*,
posts::*,
@ -101,6 +102,7 @@ fn new(blog: String, user: User, conn: DbConn) -> Option<Template> {
"error_message": "You are not author in this blog."
})))
} else {
let medias = Media::for_user(&*conn, user.id);
Some(Template::render("posts/new", json!({
"account": user.to_json(&*conn),
"instance": Instance::get_local(&*conn),
@ -108,6 +110,7 @@ fn new(blog: String, user: User, conn: DbConn) -> Option<Template> {
"errors": null,
"form": null,
"is_draft": true,
"medias": medias.into_iter().map(|m| m.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
})))
}
}
@ -128,6 +131,7 @@ fn edit(blog: String, slug: String, user: User, conn: DbConn) -> Option<Template
post.content.get().clone() // fallback to HTML if the markdown was not stored
};
let medias = Media::for_user(&*conn, user.id);
Some(Template::render("posts/new", json!({
"account": user.to_json(&*conn),
"instance": Instance::get_local(&*conn),
@ -144,8 +148,10 @@ fn edit(blog: String, slug: String, user: User, conn: DbConn) -> Option<Template
.join(", "),
license: post.license.clone(),
draft: true,
cover: post.cover_id,
},
"is_draft": !post.published
"is_draft": !post.published,
"medias": medias.into_iter().map(|m| m.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
})))
}
}
@ -206,9 +212,13 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
post.content = SafeString::new(&content);
post.source = form.content.clone();
post.license = license;
println!("Cover id from update: {:?}", form.cover);
post.cover_id = form.cover;
post.update(&*conn);
println!("Cover id after update: {:?}", post.cover_id);
let post = post.update_ap_url(&*conn);
println!("Cover id after after update: {:?}", post.cover_id);
if post.published {
post.update_mentions(&conn, mentions.into_iter().map(|m| Mention::build_activity(&conn, m)).collect());
}
@ -236,6 +246,7 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
Ok(Redirect::to(uri!(details: blog = blog, slug = new_slug)))
}
} else {
let medias = Media::for_user(&*conn, user.id);
Err(Some(Template::render("posts/new", json!({
"account": user.to_json(&*conn),
"instance": Instance::get_local(&*conn),
@ -243,6 +254,7 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
"errors": errors.inner(),
"form": form,
"is_draft": form.draft,
"medias": medias.into_iter().map(|m| m.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
}))))
}
}
@ -256,6 +268,7 @@ struct NewPostForm {
pub tags: String,
pub license: String,
pub draft: bool,
pub cover: Option<i32>,
}
fn valid_slug(title: &str) -> Result<(), ValidationError> {
@ -309,7 +322,7 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, user: User, conn: D
creation_date: None,
subtitle: form.subtitle.clone(),
source: form.content.clone(),
cover_id: None, // TODO
cover_id: form.cover,
});
let post = post.update_ap_url(&*conn);
PostAuthor::insert(&*conn, NewPostAuthor {
@ -346,13 +359,15 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, user: User, conn: D
Ok(Redirect::to(uri!(details: blog = blog_name, slug = slug)))
}
} else {
let medias = Media::for_user(&*conn, user.id);
Err(Some(Template::render("posts/new", json!({
"account": user.to_json(&*conn),
"instance": Instance::get_local(&*conn),
"editing": false,
"errors": errors.inner(),
"form": form,
"is_draft": form.draft
"is_draft": form.draft,
"medias": medias.into_iter().map(|m| m.to_json(&*conn)).collect::<Vec<serde_json::Value>>()
}))))
}
}

@ -27,7 +27,7 @@
{% endfor %}
{% endif %}
<label for="plume-editor">{{ "Content" | _ }}<small>{{ "Markdown is supported" | _ }}</small></label>
<label for="plume-editor">{{ "Content" | _ }}<small>{{ "Markdown is supported" | _ }}</small></label>
<textarea id="plume-editor" name="content" rows="20">{{ form.content | default(value="") }}</textarea>
{{ macros::input(name="tags", label="Tags, separated by commas", errors=errors, form=form, optional=true) }}
@ -35,6 +35,16 @@
{% 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) }}
<label for="cover">{{ "Illustration" | _ }}<small>{{ "Optional" | _ }}</small>{{ form.cover }}</label>
<select id="cover" name="cover">
<option value="none" {% if not form.cover %}selected{% endif %}>{{ "None" | _ }}</option>
{% for media in medias %}
<option value="{{ media.id }}" {% if form.cover == media.id %}selected{% endif %}>
{{ media.alt_text | default(value=media.content_warning) }}
</option>
{% endfor %}
</select>
{% if is_draft %}
<label for="draft">
<input type="checkbox" name="draft" id="draft" checked>

Loading…
Cancel
Save