Improve footer when article does not exist
This commit is contained in:
parent
904bfd2a0b
commit
700cf42eb0
5 changed files with 11 additions and 8 deletions
|
@ -24,8 +24,6 @@ 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 lastUpdated = footer.querySelector(".last-updated");
|
const lastUpdated = footer.querySelector(".last-updated");
|
||||||
|
|
||||||
textarea.style.height = rendered.clientHeight + "px";
|
textarea.style.height = rendered.clientHeight + "px";
|
||||||
|
@ -68,6 +66,7 @@ function openEditor() {
|
||||||
window.history.replaceState(null, result.title, result.slug == "" ? "." : result.slug);
|
window.history.replaceState(null, result.title, result.slug == "" ? "." : result.slug);
|
||||||
document.querySelector("title").textContent = result.title;
|
document.querySelector("title").textContent = result.title;
|
||||||
lastUpdated.textContent = result.last_updated;
|
lastUpdated.textContent = result.last_updated;
|
||||||
|
lastUpdated.classList.remove("missing");
|
||||||
|
|
||||||
// Update body:
|
// Update body:
|
||||||
rendered.innerHTML = result.rendered;
|
rendered.innerHTML = result.rendered;
|
||||||
|
|
|
@ -214,6 +214,10 @@ footer dd:last-child::after {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li.missing, ul.dense>li.missing {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
input:focus, textarea:focus {
|
input:focus, textarea:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl Resource for ArticleResource {
|
||||||
#[template="templates/article_revision.html"]
|
#[template="templates/article_revision.html"]
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
revision: i32,
|
revision: i32,
|
||||||
last_updated: &'a str,
|
last_updated: Option<&'a str>,
|
||||||
|
|
||||||
edit: bool,
|
edit: bool,
|
||||||
cancel_url: Option<&'a str>,
|
cancel_url: Option<&'a str>,
|
||||||
|
@ -81,10 +81,10 @@ impl Resource for ArticleResource {
|
||||||
title: &data.title,
|
title: &data.title,
|
||||||
body: &Template {
|
body: &Template {
|
||||||
revision: data.revision,
|
revision: data.revision,
|
||||||
last_updated: &last_updated(
|
last_updated: Some(&last_updated(
|
||||||
&Local.from_utc_datetime(&data.created),
|
&Local.from_utc_datetime(&data.created),
|
||||||
data.author.as_ref().map(|x| &**x)
|
data.author.as_ref().map(|x| &**x)
|
||||||
),
|
)),
|
||||||
edit: self.edit,
|
edit: self.edit,
|
||||||
cancel_url: Some(&data.slug),
|
cancel_url: Some(&data.slug),
|
||||||
title: &data.title,
|
title: &data.title,
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl Resource for NewArticleResource {
|
||||||
#[template="templates/article_revision.html"]
|
#[template="templates/article_revision.html"]
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
revision: &'a str,
|
revision: &'a str,
|
||||||
last_updated: &'a str,
|
last_updated: Option<&'a str>,
|
||||||
|
|
||||||
edit: bool,
|
edit: bool,
|
||||||
cancel_url: Option<&'a str>,
|
cancel_url: Option<&'a str>,
|
||||||
|
@ -75,7 +75,7 @@ impl Resource for NewArticleResource {
|
||||||
title: &title,
|
title: &title,
|
||||||
body: &Template {
|
body: &Template {
|
||||||
revision: NDASH,
|
revision: NDASH,
|
||||||
last_updated: NDASH,
|
last_updated: None,
|
||||||
|
|
||||||
// Implicitly start in edit-mode when no slug is given. This
|
// Implicitly start in edit-mode when no slug is given. This
|
||||||
// currently directly corresponds to the /_new endpoint
|
// currently directly corresponds to the /_new endpoint
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<ul class="dense"
|
<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
|
><li><a id="openEditor" href="?edit">Edit</a></li
|
||||||
></ul>
|
></ul>
|
||||||
{{>footer/items.html}}
|
{{>footer/items.html}}
|
||||||
|
|
Loading…
Reference in a new issue