fixed: the complete of url shortcut.

This commit is contained in:
Kilerd Chan 2018-10-22 21:55:03 +08:00
parent d8ec6f5038
commit c5a8d7084e
4 changed files with 2 additions and 6 deletions

View File

@ -47,7 +47,6 @@ impl Post {
} else { } else {
NaiveDateTime::parse_from_str(&article.publish_at, "%Y-%m-%dT%H:%M").unwrap().timestamp() NaiveDateTime::parse_from_str(&article.publish_at, "%Y-%m-%dT%H:%M").unwrap().timestamp()
}; };
println!("{:?}", timestamp);
Post { Post {
id: article.id.unwrap_or(-1), id: article.id.unwrap_or(-1),

View File

@ -78,9 +78,7 @@ fn archive_edit(admin: Admin, conn: DbConn, archive_id: i32) -> Result<Template,
#[post("/article", data="<article>")] #[post("/article", data="<article>")]
fn save_article(admin:Admin, conn: DbConn, article: Form<ArticleEditForm>) -> Result<Flash<Redirect>, Failure> { fn save_article(admin:Admin, conn: DbConn, article: Form<ArticleEditForm>) -> Result<Flash<Redirect>, Failure> {
println!("{:?}", article);
let post = Post::form_article_edit_form(article.get(), admin.id); let post = Post::form_article_edit_form(article.get(), admin.id);
println!("{:?}", post);
let fetched_post: QueryResult<Post> = if post.id == -1 { let fetched_post: QueryResult<Post> = if post.id == -1 {
// insert a new record // insert a new record
diesel::insert_into(posts::table).values(&post).get_result(&*conn) diesel::insert_into(posts::table).values(&post).get_result(&*conn)
@ -90,7 +88,6 @@ fn save_article(admin:Admin, conn: DbConn, article: Form<ArticleEditForm>) -> Re
// TODO only update record with id // TODO only update record with id
diesel::update(posts::table.find(post.id)).set(&post).get_result(&*conn) diesel::update(posts::table.find(post.id)).set(&post).get_result(&*conn)
}; };
println!("{:?}", fetched_post);
Ok(Flash::new(Redirect::to("/admin"), "success", "created")) Ok(Flash::new(Redirect::to("/admin"), "success", "created"))
} }

View File

@ -13,7 +13,7 @@
<input type="hidden" name="id" value="{{ post.id }}"> <input type="hidden" name="id" value="{{ post.id }}">
<input type="text" name="title" placeholder="title" required value="{{ post.title }}"> <input type="text" name="title" placeholder="title" required value="{{ post.title }}">
<input type="text" name="url" placeholder="url" {{ post.url }}> <input type="text" name="url" placeholder="url" value="{{ post.url }}">
<textarea name="body" id="" cols="30" rows="10" placeholder="body">{{ post.body }}</textarea> <textarea name="body" id="" cols="30" rows="10" placeholder="body">{{ post.body }}</textarea>
<input type="datetime-local" name="publish_at" id=""> <input type="datetime-local" name="publish_at" id="">
<input type="checkbox" name="published" {% if post.published %}checked{% endif %}> <input type="checkbox" name="published" {% if post.published %}checked{% endif %}>

View File

@ -6,7 +6,7 @@
<p class="mate">{{ post.timestamp | date(format="%B %d, %Y") }}</p> <p class="mate">{{ post.timestamp | date(format="%B %d, %Y") }}</p>
<h2>{{ post.post.title }}</h2> <h2>{{ post.post.title }}</h2>
<section class="content yue"> <section class="content yue">
{{ post.markdown_content }} {{ post.markdown_content | safe }}
</section> </section>
</section> </section>
{% endblock body %} {% endblock body %}