diff --git a/assets/script.js b/assets/script.js index 4e28959..7572809 100644 --- a/assets/script.js +++ b/assets/script.js @@ -24,6 +24,7 @@ function openEditor() { const cancel = editor.querySelector('.cancel'); const footer = document.querySelector("footer"); + const articleId = footer.querySelector(".article-id"); const revision = footer.querySelector(".revision"); const lastUpdated = footer.querySelector(".last-updated"); @@ -65,8 +66,9 @@ function openEditor() { const result = await response.json(); // 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; + if (result.article_id != null) articleId.textContent = result.article_id; revision.textContent = result.revision; lastUpdated.textContent = result.created; diff --git a/src/new_article_resource.rs b/src/new_article_resource.rs index 1f5fa09..b9c52cd 100644 --- a/src/new_article_resource.rs +++ b/src/new_article_resource.rs @@ -109,6 +109,7 @@ impl Resource for NewArticleResource { #[derive(Serialize)] struct PutResponse<'a> { slug: &'a str, + article_id: i32, revision: i32, title: &'a str, rendered: &'a str, @@ -134,6 +135,7 @@ impl Resource for NewArticleResource { .with_header(ContentType(APPLICATION_JSON.clone())) .with_body(serde_json::to_string(&PutResponse { slug: &updated.slug, + article_id: updated.article_id, revision: updated.revision, title: &updated.title, rendered: &Template { diff --git a/templates/article_revision.html b/templates/article_revision.html index b920330..f734472 100644 --- a/templates/article_revision.html +++ b/templates/article_revision.html @@ -31,7 +31,7 @@

Edit

Article ID
-
{{article_id}}
+
{{article_id}}
Revision
{{revision}}