parent
7653551d57
commit
94a386ea2c
2
migrations/2018-09-04-104828_posts_add_subtitle/down.sql
Normal file
2
migrations/2018-09-04-104828_posts_add_subtitle/down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE posts DROP COLUMN subtitle;
|
2
migrations/2018-09-04-104828_posts_add_subtitle/up.sql
Normal file
2
migrations/2018-09-04-104828_posts_add_subtitle/up.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE posts ADD COLUMN subtitle TEXT NOT NULL DEFAULT '';
|
@ -33,7 +33,8 @@ pub struct Post {
|
||||
pub published: bool,
|
||||
pub license: String,
|
||||
pub creation_date: NaiveDateTime,
|
||||
pub ap_url: String
|
||||
pub ap_url: String,
|
||||
pub subtitle: String,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
@ -46,7 +47,8 @@ pub struct NewPost {
|
||||
pub published: bool,
|
||||
pub license: String,
|
||||
pub creation_date: Option<NaiveDateTime>,
|
||||
pub ap_url: String
|
||||
pub ap_url: String,
|
||||
pub subtitle: String,
|
||||
}
|
||||
|
||||
impl Post {
|
||||
@ -185,6 +187,7 @@ impl Post {
|
||||
article.object_props.set_attributed_to_link_vec::<Id>(authors).expect("Article::into_activity: attributedTo error");
|
||||
article.object_props.set_content_string(self.content.get().clone()).expect("Article::into_activity: content error");
|
||||
article.object_props.set_published_utctime(Utc.from_utc_datetime(&self.creation_date)).expect("Article::into_activity: published error");
|
||||
article.object_props.set_summary_string(self.subtitle.clone()).expect("Article::into_activity: summary error");
|
||||
article.object_props.set_tag_link_vec(mentions).expect("Article::into_activity: tag error");
|
||||
article.object_props.set_url_string(self.ap_url.clone()).expect("Article::into_activity: url error");
|
||||
article.object_props.set_to_link_vec::<Id>(to.into_iter().map(Id::new).collect()).expect("Article::into_activity: to error");
|
||||
@ -250,7 +253,8 @@ impl FromActivity<Article, PgConnection> for Post {
|
||||
license: String::from("CC-0"), // TODO
|
||||
// FIXME: This is wrong: with this logic, we may use the display URL as the AP ID. We need two different fields
|
||||
ap_url: article.object_props.url_string().unwrap_or(article.object_props.id_string().expect("Post::from_activity: url + id error")),
|
||||
creation_date: Some(article.object_props.published_utctime().expect("Post::from_activity: published error").naive_utc())
|
||||
creation_date: Some(article.object_props.published_utctime().expect("Post::from_activity: published error").naive_utc()),
|
||||
subtitle: article.object_props.summary_string().expect("Post::from_activity: summary error")
|
||||
});
|
||||
|
||||
for author in authors.into_iter() {
|
||||
|
@ -125,6 +125,7 @@ table! {
|
||||
license -> Varchar,
|
||||
creation_date -> Timestamp,
|
||||
ap_url -> Varchar,
|
||||
subtitle -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
|
4
po/de.po
4
po/de.po
@ -508,5 +508,9 @@ msgid ""
|
||||
"Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgid "Subtitle"
|
||||
msgstr "Titel"
|
||||
|
||||
#~ msgid "Your password should be at least 8 characters long"
|
||||
#~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"
|
||||
|
3
po/en.po
3
po/en.po
@ -497,3 +497,6 @@ msgstr ""
|
||||
msgid ""
|
||||
"Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr ""
|
||||
|
||||
msgid "Subtitle"
|
||||
msgstr ""
|
||||
|
8
po/fr.po
8
po/fr.po
@ -503,4 +503,10 @@ msgstr "Envoyer"
|
||||
|
||||
msgid ""
|
||||
"Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr "Désolé, mais les inscriptions sont fermées sur cette instance. Essayez d'en trouver une autre."
|
||||
msgstr ""
|
||||
"Désolé, mais les inscriptions sont fermées sur cette instance. Essayez d'en "
|
||||
"trouver une autre."
|
||||
|
||||
#, fuzzy
|
||||
msgid "Subtitle"
|
||||
msgstr "Titre"
|
||||
|
7
po/gl.po
7
po/gl.po
@ -496,4 +496,9 @@ msgstr "Enviar"
|
||||
msgid ""
|
||||
"Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr ""
|
||||
"Lamentámolo, pero o rexistro en esta instancia está pechado. Inténteo en outra instancia"
|
||||
"Lamentámolo, pero o rexistro en esta instancia está pechado. Inténteo en "
|
||||
"outra instancia"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Subtitle"
|
||||
msgstr "Título"
|
||||
|
4
po/nb.po
4
po/nb.po
@ -512,6 +512,10 @@ msgid ""
|
||||
"Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgid "Subtitle"
|
||||
msgstr "Tittel"
|
||||
|
||||
#~ msgid "One reshare"
|
||||
#~ msgid_plural "{{ count }} reshares"
|
||||
#~ msgstr[0] "Én deling"
|
||||
|
4
po/pl.po
4
po/pl.po
@ -523,6 +523,10 @@ msgid ""
|
||||
"Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgid "Subtitle"
|
||||
msgstr "Tytuł"
|
||||
|
||||
#~ msgid "One reshare"
|
||||
#~ msgid_plural "{{ count }} reshares"
|
||||
#~ msgstr[0] "Jedno udostępnienie"
|
||||
|
@ -486,3 +486,6 @@ msgstr ""
|
||||
|
||||
msgid "Sorry, but registrations are closed on this instance. Try to find another one"
|
||||
msgstr ""
|
||||
|
||||
msgid "Subtitle"
|
||||
msgstr ""
|
||||
|
@ -98,6 +98,7 @@ fn new(blog: String, user: User, conn: DbConn) -> Template {
|
||||
struct NewPostForm {
|
||||
#[validate(custom(function = "valid_slug", message = "Invalid title"))]
|
||||
pub title: String,
|
||||
pub subtitle: String,
|
||||
pub content: String,
|
||||
pub license: String
|
||||
}
|
||||
@ -150,7 +151,8 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, user: User, conn: D
|
||||
Instance::get_local(&*conn).map(|i| i.default_license).unwrap_or(String::from("CC-0"))
|
||||
},
|
||||
ap_url: "".to_string(),
|
||||
creation_date: None
|
||||
creation_date: None,
|
||||
subtitle: form.subtitle.clone()
|
||||
});
|
||||
let post = post.update_ap_url(&*conn);
|
||||
PostAuthor::insert(&*conn, NewPostAuthor {
|
||||
|
@ -131,6 +131,13 @@ main h2 {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
main h2.article {
|
||||
max-width: 40rem;
|
||||
margin: 0.5em auto 1em;
|
||||
color: rgba(36, 36, 36, 0.6);
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
/*
|
||||
* == Article ==
|
||||
*/
|
||||
|
@ -2,7 +2,13 @@
|
||||
<div class="card">
|
||||
<h3><a href="{{ article.url }}">{{ article.post.title }}</a></h3>
|
||||
<main
|
||||
<p>{{ article.post.content | safe | striptags | truncate(length=200) }}</p>
|
||||
<p>
|
||||
{% if article.post.subtitle | length > 0 %}
|
||||
{{ article.post.subtitle }}
|
||||
{% else %}
|
||||
{{ article.post.content | safe | striptags | truncate(length=200) }}
|
||||
{% endif %}
|
||||
</p>
|
||||
</main>
|
||||
<p class="author">
|
||||
{{ "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}" | _(
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
{% block content %}
|
||||
<h1 class="article">{{ article.post.title }}</h1>
|
||||
<h2 class="article">{{ article.post.subtitle }}</h2>
|
||||
<p class="article-info">
|
||||
<span class="author">{{ "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" | _(
|
||||
link_1='<a href="/@/',
|
||||
|
@ -9,6 +9,7 @@
|
||||
<h1>{{ "Create a post" | _ }}</h1>
|
||||
<form class="new-post" method="post">
|
||||
{{ macros::input(name="title", label="Title", errors=errors, form=form, props="required") }}
|
||||
{{ macros::input(name="subtitle", label="Subtitle", errors=errors, form=form, optional=true) }}
|
||||
|
||||
{% if errors is defined and errors.content %}
|
||||
{% for err in errors.content %}
|
||||
|
Loading…
Reference in New Issue
Block a user