diff --git a/resources/templates/history.html b/resources/templates/history.html
new file mode 100644
index 0000000..30a63ad
--- /dev/null
+++ b/resources/templates/history.html
@@ -0,0 +1,32 @@
+{% extends "templates/base.html" %}
+{% block content %}
+
+
+ {{left-bar|safe}}
+
+
+
+
+ | Who | When | What | Which |
+
+ {% for entry in history %}
+
+ |
+ {{entry.author}}
+ |
+
+ {{entry.time}}
+ |
+
+ {{entry.message}}
+ |
+
+ {{entry.id}}
+ |
+
+
+
+{% endblock %}
diff --git a/src/smeagol/history.clj b/src/smeagol/history.clj
new file mode 100644
index 0000000..6b8419b
--- /dev/null
+++ b/src/smeagol/history.clj
@@ -0,0 +1,24 @@
+(ns smeagol.history
+ (:require [clj-jgit.porcelain :as git]
+ [clj-jgit.querying :as q]))
+
+(defn entry-contains
+ "If this `log-entry` contains a reference to this `file-path`, return the entry;
+ else nil."
+ [^String log-entry ^String file-path]
+ (cond
+ (not
+ (empty?
+ (filter
+ #(= (first %) file-path)
+ (:changed_files log-entry))))
+ log-entry))
+
+(defn find-history [^String git-directory-path ^String file-path]
+ "Return the log entries in the repository at this `git-directory-path`
+ which refer to changes to the file at this `file-path`."
+ (let [repository (git/load-repo git-directory-path)]
+ (filter
+ #(entry-contains % file-path)
+ (map #(q/commit-info repository %)
+ (git/git-log repository)))))
diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj
index 730733f..ef50e08 100644
--- a/src/smeagol/routes/wiki.clj
+++ b/src/smeagol/routes/wiki.clj
@@ -25,7 +25,8 @@
[noir.session :as session]
[smeagol.authenticate :as auth]
[smeagol.layout :as layout]
- [smeagol.util :as util]))
+ [smeagol.util :as util]
+ [smeagol.history :as hist]))
(defn local-links
@@ -91,6 +92,22 @@
:user (session/get :user)})
true (response/redirect (str "/edit?content=" content)))))
+(defn history-page
+ "Render the history for the markdown page specified in this `request`, if any. If none, error?"
+ [request]
+ (let [params (keywordize-keys (:params request))
+ content (or (:content params) "Introduction")
+ file-name (str "/content/" content ".md")
+ file-path (str (io/resource-path) file-name)
+ exists? (.exists (clojure.java.io/as-file file-path))]
+ (layout/render "history.html"
+ {:title content
+ :left-bar (local-links (util/md->html "/content/_left-bar.md"))
+ :header (local-links (util/md->html "/content/_header.md"))
+ :history (hist/find-history (io/resource-path) file-name)})))
+
+
+
(defn auth-page
"Render the auth page"
[request]