diff --git a/resources/templates/history.html b/resources/templates/history.html
index 8679eec..c73f5b8 100644
--- a/resources/templates/history.html
+++ b/resources/templates/history.html
@@ -5,6 +5,11 @@
| When | What | Version | Changes |
+
+ | Now | |
+ [current] |
+ [no changes] |
+
{% for entry in history %}
|
@@ -14,10 +19,10 @@
{{entry.message}}
|
- Show version
+ Show version
|
- What's changed?
+ What's changed?
|
{% endfor %}
diff --git a/resources/templates/wiki.html b/resources/templates/wiki.html
index 78dfd80..c04c918 100644
--- a/resources/templates/wiki.html
+++ b/resources/templates/wiki.html
@@ -2,7 +2,7 @@
{% block content %}
diff --git a/src/smeagol/history.clj b/src/smeagol/history.clj
index 77b0c3d..cf52fc7 100644
--- a/src/smeagol/history.clj
+++ b/src/smeagol/history.clj
@@ -70,9 +70,9 @@
`git-directory-path` between versions `older` and `newer` or between the specified
`version` and the current version of the file. Returns the diff as a string.
- Based on JGit Cookbook ShowFileDiff.
- TODO: This is certainly not very far wrong but is currently not working."
- ([^String git-directory-path ^String file-path ^String version])
+ Based on JGit Cookbook ShowFileDiff."
+ ([^String git-directory-path ^String file-path ^String version]
+ "TODO: Doesn't work yet")
([^String git-directory-path ^String file-path ^String older ^String newer]
(let [git-r (git/load-repo git-directory-path)
old-parse (prepare-tree-parser git-r older)
diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj
index 4054578..4ba4ae8 100644
--- a/src/smeagol/routes/wiki.clj
+++ b/src/smeagol/routes/wiki.clj
@@ -19,6 +19,7 @@
(:use clojure.walk)
(:require [compojure.core :refer :all]
[clj-jgit.porcelain :as git]
+ [markdown.core :as md]
[noir.io :as io]
[noir.response :as response]
[noir.util.route :as route]
@@ -70,7 +71,7 @@
(cond src-text (process-source params)
true
(layout/render "edit.html"
- {:title content
+ {:title (str "Edit " content)
:left-bar (local-links (util/md->html "/content/_edit-left-bar.md"))
:header (local-links (util/md->html "/content/_header.md"))
:content (if exists? (io/slurp-resource file-name) "")
@@ -88,6 +89,7 @@
(cond exists?
(layout/render "wiki.html"
{:title content
+ :page content
:left-bar (local-links (util/md->html "/content/_left-bar.md"))
:header (local-links (util/md->html "/content/_header.md"))
:content (local-links (util/md->html file-name))
@@ -95,7 +97,8 @@
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?"
+ "Render the history for the markdown page specified in this `request`,
+ if any. If none, error?"
[request]
(let [params (keywordize-keys (:params request))
page (or (:page params) "Introduction")
@@ -103,10 +106,33 @@
repo-path (str (io/resource-path) "/content/")]
(layout/render "history.html"
{:title (str "History of " page)
+ :page page
:left-bar (local-links (util/md->html "/content/_left-bar.md"))
:header (local-links (util/md->html "/content/_header.md"))
:history (hist/find-history repo-path file-name)})))
+(defn version-page
+ "Render a specific historical version of a page"
+ [request]
+ (let [params (keywordize-keys (:params request))
+ page (or (:page params) "Introduction")
+ version (:version params)
+ file-name (str page ".md")
+ repo-path (str (io/resource-path) "/content/")]
+ (layout/render "wiki.html"
+ {:title (str "Version " version " of " page)
+ :page page
+ :left-bar (local-links
+ (util/md->html "/content/_left-bar.md"))
+ :header (local-links
+ (util/md->html "/content/_header.md"))
+ :content (local-links
+ (md/md-to-html-string
+ (hist/fetch-version
+ repo-path file-name version)))
+ :user (session/get :user)})))
+
+
(defn auth-page
"Render the auth page"
[request]
@@ -141,6 +167,7 @@
(GET "/edit" request (route/restricted (edit-page request)))
(POST "/edit" request (route/restricted (edit-page request)))
(GET "/history" request (history-page request))
+ (GET "/version" request (version-page request))
(GET "/auth" request (auth-page request))
(POST "/auth" request (auth-page request))
(GET "/about" [] (about-page)))