Improve footer when article does not exist

This commit is contained in:
Magnus Hoff 2017-10-19 13:39:03 +02:00
parent 904bfd2a0b
commit 700cf42eb0
5 changed files with 11 additions and 8 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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,

View file

@ -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

View file

@ -33,7 +33,7 @@
<footer>
<ul class="dense"
><li class="last-updated">{{last_updated}}</li
><li class="last-updated {{^last_updated}}missing{{/last_updated}}">{{#last_updated}}{{.}}{{/last_updated}}</li
><li><a id="openEditor" href="?edit">Edit</a></li
></ul>
{{>footer/items.html}}