Bugletfixes

This commit is contained in:
Magnus Hoff 2017-09-21 12:11:08 +02:00
parent 9d0ca63aa9
commit cd784e34c3
3 changed files with 6 additions and 2 deletions

View file

@ -24,6 +24,7 @@ function openEditor() {
const cancel = editor.querySelector('.cancel'); const cancel = editor.querySelector('.cancel');
const footer = document.querySelector("footer"); const footer = document.querySelector("footer");
const articleId = footer.querySelector(".article-id");
const revision = footer.querySelector(".revision"); const revision = footer.querySelector(".revision");
const lastUpdated = footer.querySelector(".last-updated"); const lastUpdated = footer.querySelector(".last-updated");
@ -65,8 +66,9 @@ function openEditor() {
const result = await response.json(); const result = await response.json();
// Update url-bar, page title and footer // Update url-bar, page title and footer
window.history.replaceState(null, result.title, result.slug); window.history.replaceState(null, result.title, result.slug == "" ? "." : result.slug);
document.querySelector("title").textContent = result.title; document.querySelector("title").textContent = result.title;
if (result.article_id != null) articleId.textContent = result.article_id;
revision.textContent = result.revision; revision.textContent = result.revision;
lastUpdated.textContent = result.created; lastUpdated.textContent = result.created;

View file

@ -109,6 +109,7 @@ impl Resource for NewArticleResource {
#[derive(Serialize)] #[derive(Serialize)]
struct PutResponse<'a> { struct PutResponse<'a> {
slug: &'a str, slug: &'a str,
article_id: i32,
revision: i32, revision: i32,
title: &'a str, title: &'a str,
rendered: &'a str, rendered: &'a str,
@ -134,6 +135,7 @@ impl Resource for NewArticleResource {
.with_header(ContentType(APPLICATION_JSON.clone())) .with_header(ContentType(APPLICATION_JSON.clone()))
.with_body(serde_json::to_string(&PutResponse { .with_body(serde_json::to_string(&PutResponse {
slug: &updated.slug, slug: &updated.slug,
article_id: updated.article_id,
revision: updated.revision, revision: updated.revision,
title: &updated.title, title: &updated.title,
rendered: &Template { rendered: &Template {

View file

@ -31,7 +31,7 @@
<p><a id="openEditor" href="?editor">Edit</a></p> <p><a id="openEditor" href="?editor">Edit</a></p>
<dl> <dl>
<dt>Article ID</dt> <dt>Article ID</dt>
<dd>{{article_id}}</dd> <dd class="article-id">{{article_id}}</dd>
<dt>Revision</dt> <dt>Revision</dt>
<dd class="revision">{{revision}}</dd> <dd class="revision">{{revision}}</dd>