fixed: the complete of url shortcut.
This commit is contained in:
parent
d8ec6f5038
commit
c5a8d7084e
@ -47,7 +47,6 @@ impl Post {
|
||||
} else {
|
||||
NaiveDateTime::parse_from_str(&article.publish_at, "%Y-%m-%dT%H:%M").unwrap().timestamp()
|
||||
};
|
||||
println!("{:?}", timestamp);
|
||||
|
||||
Post {
|
||||
id: article.id.unwrap_or(-1),
|
||||
|
@ -78,9 +78,7 @@ fn archive_edit(admin: Admin, conn: DbConn, archive_id: i32) -> Result<Template,
|
||||
|
||||
#[post("/article", data="<article>")]
|
||||
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);
|
||||
println!("{:?}", post);
|
||||
let fetched_post: QueryResult<Post> = if post.id == -1 {
|
||||
// insert a new record
|
||||
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
|
||||
diesel::update(posts::table.find(post.id)).set(&post).get_result(&*conn)
|
||||
};
|
||||
println!("{:?}", fetched_post);
|
||||
|
||||
Ok(Flash::new(Redirect::to("/admin"), "success", "created"))
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
|
||||
<input type="hidden" name="id" value="{{ post.id }}">
|
||||
<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>
|
||||
<input type="datetime-local" name="publish_at" id="">
|
||||
<input type="checkbox" name="published" {% if post.published %}checked{% endif %}>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<p class="mate">{{ post.timestamp | date(format="%B %d, %Y") }}</p>
|
||||
<h2>{{ post.post.title }}</h2>
|
||||
<section class="content yue">
|
||||
{{ post.markdown_content }}
|
||||
{{ post.markdown_content | safe }}
|
||||
</section>
|
||||
</section>
|
||||
{% endblock body %}
|
Loading…
Reference in New Issue
Block a user