summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2015-06-25 22:07:52 -0400
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2015-06-25 22:07:52 -0400
commit3232f8e796a8be37bc60e04d247bd9142cdba2b4 (patch)
tree4d9d7c1c4d7a90d2ae68bd982697498df767615b
parent8ff581de207f3c07d2e965d0307460db2f688c28 (diff)
Add last modified timeHEADmaster
-rw-r--r--main.ur27
-rw-r--r--urwiki.css8
2 files changed, 28 insertions, 7 deletions
diff --git a/main.ur b/main.ur
index 02ad98b..25ca417 100644
--- a/main.ur
+++ b/main.ur
@@ -45,9 +45,10 @@ fun current_revision title =
WHERE commit.Title = {[title]}
ORDER BY commit.Created ASC);
return (case commits of
- Nil => {Title = title, Body = "Not found."}
+ Nil => {Title = title, Body = "Not found.", Modified = None}
| art :: _ => {Title = art.Title,
- Body = show art.Content})
+ Body = show art.Content,
+ Modified = Some art.Created})
fun create_commit title text : transaction unit =
id <- nextval commit_id_next;
@@ -55,16 +56,24 @@ fun create_commit title text : transaction unit =
dml (INSERT INTO commit (Id, Created, Title, Content)
VALUES ({[id]}, {[creation_time]}, {[title]}, {[text]}))
-style article_text
+fun report_last_modified date =
+ <xml>
+ This page was last modified at
+ {[timef "%l:%M:%S %P %Z on %A, %e %B %Y" date]}.
+ </xml>
+
+style content
+style footer
style button_group
style top_bar
fun wiki requested_article_title =
(* Look up the article. *)
article <- current_revision requested_article_title;
- (* Stuff the article text in a source so we can live-update it as the user
- edits. *)
+ (* Stuff article information into sources so we can live-update them as the
+ user edits. *)
article_body_source <- source article.Body;
+ article_modified_source <- source article.Modified;
(* Initially, we're in View mode, and we can switch to Edit mode on user
request. *)
page_mode <- source View;
@@ -115,7 +124,7 @@ fun wiki requested_article_title =
</div>
</div>
(* Article *)
- <div class={article_text}>
+ <div class={content}>
(* Editing window *)
<div dynClass={only_in page_mode Edit}>
<ctextarea source={article_body_source} /><br />
@@ -123,6 +132,12 @@ fun wiki requested_article_title =
(* Article text (or live preview) *)
<dyn signal={text <- signal article_body_source;
return <xml>{[text]}</xml>} />
+ <div class={footer}>
+ <dyn signal={modified <- signal article_modified_source;
+ return (case article.Modified of
+ None => <xml></xml>
+ | Some date => report_last_modified date)} />
+ </div>
</div>
</body>
</xml>
diff --git a/urwiki.css b/urwiki.css
index 574177e..f6a443d 100644
--- a/urwiki.css
+++ b/urwiki.css
@@ -90,7 +90,7 @@ div {
height: 45px;
}
-.Main_article_text {
+.Main_content {
margin: 0 auto;
padding: 0 15px;
max-width: 62.5em;
@@ -103,6 +103,12 @@ div {
resize: vertical;
}
+.Main_footer {
+ margin-top: 3em;
+ font-size: 0.8em;
+ color: #888;
+}
+
.Style_invisible {
display: none;
}