From 700cf42eb0144ba703d7e1732fe8fe8a88863527 Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Thu, 19 Oct 2017 13:39:03 +0200 Subject: [PATCH] Improve footer when article does not exist --- assets/script.js | 3 +-- assets/style.css | 4 ++++ src/resources/article_resource.rs | 6 +++--- src/resources/new_article_resource.rs | 4 ++-- templates/article_revision.html | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/assets/script.js b/assets/script.js index b1710f9..f004dd3 100644 --- a/assets/script.js +++ b/assets/script.js @@ -24,8 +24,6 @@ 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"); textarea.style.height = rendered.clientHeight + "px"; @@ -68,6 +66,7 @@ function openEditor() { window.history.replaceState(null, result.title, result.slug == "" ? "." : result.slug); document.querySelector("title").textContent = result.title; lastUpdated.textContent = result.last_updated; + lastUpdated.classList.remove("missing"); // Update body: rendered.innerHTML = result.rendered; diff --git a/assets/style.css b/assets/style.css index e219dd2..b3421b3 100644 --- a/assets/style.css +++ b/assets/style.css @@ -214,6 +214,10 @@ footer dd:last-child::after { margin: 0; } +li.missing, ul.dense>li.missing { + display: none; +} + input:focus, textarea:focus { outline: none; } diff --git a/src/resources/article_resource.rs b/src/resources/article_resource.rs index 1d99135..43713f2 100644 --- a/src/resources/article_resource.rs +++ b/src/resources/article_resource.rs @@ -58,7 +58,7 @@ impl Resource for ArticleResource { #[template="templates/article_revision.html"] struct Template<'a> { revision: i32, - last_updated: &'a str, + last_updated: Option<&'a str>, edit: bool, cancel_url: Option<&'a str>, @@ -81,10 +81,10 @@ impl Resource for ArticleResource { title: &data.title, body: &Template { revision: data.revision, - last_updated: &last_updated( + last_updated: Some(&last_updated( &Local.from_utc_datetime(&data.created), data.author.as_ref().map(|x| &**x) - ), + )), edit: self.edit, cancel_url: Some(&data.slug), title: &data.title, diff --git a/src/resources/new_article_resource.rs b/src/resources/new_article_resource.rs index f007506..cd106c1 100644 --- a/src/resources/new_article_resource.rs +++ b/src/resources/new_article_resource.rs @@ -53,7 +53,7 @@ impl Resource for NewArticleResource { #[template="templates/article_revision.html"] struct Template<'a> { revision: &'a str, - last_updated: &'a str, + last_updated: Option<&'a str>, edit: bool, cancel_url: Option<&'a str>, @@ -75,7 +75,7 @@ impl Resource for NewArticleResource { title: &title, body: &Template { revision: NDASH, - last_updated: NDASH, + last_updated: None, // Implicitly start in edit-mode when no slug is given. This // currently directly corresponds to the /_new endpoint diff --git a/templates/article_revision.html b/templates/article_revision.html index a67726a..6a3626f 100644 --- a/templates/article_revision.html +++ b/templates/article_revision.html @@ -33,7 +33,7 @@