Restructure footer.
Less irrelevant information. Refactor rendering of "last updated"
This commit is contained in:
parent
f923b5b6c0
commit
904bfd2a0b
5 changed files with 44 additions and 41 deletions
|
@ -67,9 +67,7 @@ function openEditor() {
|
||||||
// Update url-bar, page title and footer
|
// Update url-bar, page title and footer
|
||||||
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;
|
||||||
if (result.article_id != null) articleId.textContent = result.article_id;
|
lastUpdated.textContent = result.last_updated;
|
||||||
revision.textContent = result.revision;
|
|
||||||
lastUpdated.textContent = result.created;
|
|
||||||
|
|
||||||
// Update body:
|
// Update body:
|
||||||
rendered.innerHTML = result.rendered;
|
rendered.innerHTML = result.rendered;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use chrono::{TimeZone, DateTime, Local};
|
||||||
use futures::{self, Future};
|
use futures::{self, Future};
|
||||||
use hyper;
|
use hyper;
|
||||||
use hyper::header::ContentType;
|
use hyper::header::ContentType;
|
||||||
|
@ -25,6 +26,20 @@ impl ArticleResource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn last_updated(created: &DateTime<Local>, author: Option<&str>) -> String {
|
||||||
|
#[derive(BartDisplay)]
|
||||||
|
#[template_string = "Last updated {{created}}{{#author}} by {{.}}{{/author}}"]
|
||||||
|
struct Template<'a> {
|
||||||
|
created: &'a str,
|
||||||
|
author: Option<&'a str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
Template {
|
||||||
|
created: &created.to_rfc2822(),
|
||||||
|
author
|
||||||
|
}.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
impl Resource for ArticleResource {
|
impl Resource for ArticleResource {
|
||||||
fn allow(&self) -> Vec<hyper::Method> {
|
fn allow(&self) -> Vec<hyper::Method> {
|
||||||
use hyper::Method::*;
|
use hyper::Method::*;
|
||||||
|
@ -39,15 +54,11 @@ impl Resource for ArticleResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get(self: Box<Self>) -> ResponseFuture {
|
fn get(self: Box<Self>) -> ResponseFuture {
|
||||||
use chrono::{TimeZone, Local};
|
|
||||||
|
|
||||||
#[derive(BartDisplay)]
|
#[derive(BartDisplay)]
|
||||||
#[template="templates/article_revision.html"]
|
#[template="templates/article_revision.html"]
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
article_id: i32,
|
|
||||||
revision: i32,
|
revision: i32,
|
||||||
created: &'a str,
|
last_updated: &'a str,
|
||||||
author: Option<&'a str>,
|
|
||||||
|
|
||||||
edit: bool,
|
edit: bool,
|
||||||
cancel_url: Option<&'a str>,
|
cancel_url: Option<&'a str>,
|
||||||
|
@ -69,10 +80,11 @@ impl Resource for ArticleResource {
|
||||||
base: None, // Hmm, should perhaps accept `base` as argument
|
base: None, // Hmm, should perhaps accept `base` as argument
|
||||||
title: &data.title,
|
title: &data.title,
|
||||||
body: &Template {
|
body: &Template {
|
||||||
article_id: data.article_id,
|
|
||||||
revision: data.revision,
|
revision: data.revision,
|
||||||
created: &Local.from_utc_datetime(&data.created).to_rfc2822(),
|
last_updated: &last_updated(
|
||||||
author: data.author.as_ref().map(|x| &**x),
|
&Local.from_utc_datetime(&data.created),
|
||||||
|
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,
|
||||||
|
@ -88,7 +100,6 @@ impl Resource for ArticleResource {
|
||||||
fn put(self: Box<Self>, body: hyper::Body, identity: Option<String>) -> ResponseFuture {
|
fn put(self: Box<Self>, body: hyper::Body, identity: Option<String>) -> ResponseFuture {
|
||||||
// TODO Check incoming Content-Type
|
// TODO Check incoming Content-Type
|
||||||
|
|
||||||
use chrono::{TimeZone, Local};
|
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -111,7 +122,7 @@ impl Resource for ArticleResource {
|
||||||
revision: i32,
|
revision: i32,
|
||||||
title: &'a str,
|
title: &'a str,
|
||||||
rendered: &'a str,
|
rendered: &'a str,
|
||||||
created: &'a str,
|
last_updated: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
Box::new(body
|
Box::new(body
|
||||||
|
@ -136,7 +147,10 @@ impl Resource for ArticleResource {
|
||||||
title: &updated.title,
|
title: &updated.title,
|
||||||
rendered: render_markdown(&updated.body),
|
rendered: render_markdown(&updated.body),
|
||||||
}.to_string(),
|
}.to_string(),
|
||||||
created: &Local.from_utc_datetime(&updated.created).to_rfc2822(),
|
last_updated: &last_updated(
|
||||||
|
&Local.from_utc_datetime(&updated.created),
|
||||||
|
updated.author.as_ref().map(|x| &**x)
|
||||||
|
),
|
||||||
}).expect("Should never fail"))
|
}).expect("Should never fail"))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -52,10 +52,8 @@ impl Resource for NewArticleResource {
|
||||||
#[derive(BartDisplay)]
|
#[derive(BartDisplay)]
|
||||||
#[template="templates/article_revision.html"]
|
#[template="templates/article_revision.html"]
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
article_id: &'a str,
|
|
||||||
revision: &'a str,
|
revision: &'a str,
|
||||||
created: &'a str,
|
last_updated: &'a str,
|
||||||
author: Option<&'a str>,
|
|
||||||
|
|
||||||
edit: bool,
|
edit: bool,
|
||||||
cancel_url: Option<&'a str>,
|
cancel_url: Option<&'a str>,
|
||||||
|
@ -76,10 +74,8 @@ impl Resource for NewArticleResource {
|
||||||
base: None, // Hmm, should perhaps accept `base` as argument
|
base: None, // Hmm, should perhaps accept `base` as argument
|
||||||
title: &title,
|
title: &title,
|
||||||
body: &Template {
|
body: &Template {
|
||||||
article_id: NDASH,
|
|
||||||
revision: NDASH,
|
revision: NDASH,
|
||||||
created: NDASH,
|
last_updated: NDASH,
|
||||||
author: 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
|
||||||
|
@ -98,6 +94,7 @@ impl Resource for NewArticleResource {
|
||||||
|
|
||||||
fn put(self: Box<Self>, body: hyper::Body, identity: Option<String>) -> ResponseFuture {
|
fn put(self: Box<Self>, body: hyper::Body, identity: Option<String>) -> ResponseFuture {
|
||||||
// TODO Check incoming Content-Type
|
// TODO Check incoming Content-Type
|
||||||
|
// TODO Refactor. Reduce duplication with ArticleResource::put
|
||||||
|
|
||||||
use chrono::{TimeZone, Local};
|
use chrono::{TimeZone, Local};
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
|
@ -123,7 +120,7 @@ impl Resource for NewArticleResource {
|
||||||
revision: i32,
|
revision: i32,
|
||||||
title: &'a str,
|
title: &'a str,
|
||||||
rendered: &'a str,
|
rendered: &'a str,
|
||||||
created: &'a str,
|
last_updated: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
Box::new(body
|
Box::new(body
|
||||||
|
@ -152,7 +149,10 @@ impl Resource for NewArticleResource {
|
||||||
title: &updated.title,
|
title: &updated.title,
|
||||||
rendered: render_markdown(&updated.body),
|
rendered: render_markdown(&updated.body),
|
||||||
}.to_string(),
|
}.to_string(),
|
||||||
created: &Local.from_utc_datetime(&updated.created).to_string(),
|
last_updated: &super::article_resource::last_updated(
|
||||||
|
&Local.from_utc_datetime(&updated.created),
|
||||||
|
updated.author.as_ref().map(|x| &**x)
|
||||||
|
),
|
||||||
}).expect("Should never fail"))
|
}).expect("Should never fail"))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -32,18 +32,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<ul class="dense">
|
<ul class="dense"
|
||||||
<li><a id="openEditor" href="?edit">Edit</a></li>
|
><li class="last-updated">{{last_updated}}</li
|
||||||
</ul>
|
><li><a id="openEditor" href="?edit">Edit</a></li
|
||||||
<dl>
|
></ul>
|
||||||
<dt>Article ID</dt>
|
|
||||||
<dd class="article-id">{{article_id}}</dd>
|
|
||||||
|
|
||||||
<dt>Revision</dt>
|
|
||||||
<dd class="revision">{{revision}}</dd>
|
|
||||||
|
|
||||||
<dt>Last updated</dt>
|
|
||||||
<dd class="last-updated">{{created}}{{#author}} by {{.}}{{/author}}</dd>
|
|
||||||
</dl>
|
|
||||||
{{>footer/items.html}}
|
{{>footer/items.html}}
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<ul class="dense">
|
<ul class="dense"
|
||||||
<li><a href=".">Home</a></li>
|
><li><a href=".">Home</a></li
|
||||||
<li><a href="_new">Create article</a></li>
|
><li><a href="_new">Create article</a></li
|
||||||
<li><a href="_sitemap">Sitemap</a></li>
|
><li><a href="_sitemap">Sitemap</a></li
|
||||||
<li><a href="_changes">Recent changes</a></li>
|
><li><a href="_changes">Recent changes</a></li
|
||||||
</ul>
|
></ul>
|
||||||
<p>Powered by <a href="https://github.com/maghoff/sausagewiki">Sausagewiki</a></p>
|
<p>Powered by <a href="https://github.com/maghoff/sausagewiki">Sausagewiki</a></p>
|
||||||
|
|
Loading…
Reference in a new issue