Apart from writing a diff2html transform and maybe adding a user-admin

page, I'd say this is feature complete. Good enough for me, anyway!
This commit is contained in:
Simon Brooke 2015-01-11 15:02:08 +00:00
parent 62b325cb68
commit bc0dd75081
3 changed files with 24 additions and 5 deletions

View file

@ -12,7 +12,7 @@
<tr> <tr>
{% for entry in history %} {% for entry in history %}
<tr> <tr>
<td> <td>S
{{entry.time}} {{entry.time}}
</td> </td>
<td> <td>
@ -22,7 +22,7 @@
<a href="version?page={{page}}&amp;version={{entry.id}}">Show version</a> <a href="version?page={{page}}&amp;version={{entry.id}}">Show version</a>
</td> </td>
<td> <td>
<a href="diff?page={{page}}&amp;version={{entry.id}}">What's changed?</a> <a href="changes?page={{page}}&amp;version={{entry.id}}">What's changed?</a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -72,7 +72,8 @@
Based on JGit Cookbook ShowFileDiff." Based on JGit Cookbook ShowFileDiff."
([^String git-directory-path ^String file-path ^String version] ([^String git-directory-path ^String file-path ^String version]
"TODO: Doesn't work yet") (diff git-directory-path file-path version
(:id (first (find-history git-directory-path file-path)))))
([^String git-directory-path ^String file-path ^String older ^String newer] ([^String git-directory-path ^String file-path ^String older ^String newer]
(let [git-r (git/load-repo git-directory-path) (let [git-r (git/load-repo git-directory-path)
old-parse (prepare-tree-parser git-r older) old-parse (prepare-tree-parser git-r older)

View file

@ -26,11 +26,11 @@
[noir.session :as session] [noir.session :as session]
[taoensso.timbre :as timbre] [taoensso.timbre :as timbre]
[smeagol.authenticate :as auth] [smeagol.authenticate :as auth]
[smeagol.diff2html :as d2h]
[smeagol.layout :as layout] [smeagol.layout :as layout]
[smeagol.util :as util] [smeagol.util :as util]
[smeagol.history :as hist])) [smeagol.history :as hist]))
(defn local-links (defn local-links
"Rewrite text in `html-src` surrounded by double square brackets as a local link into this wiki." "Rewrite text in `html-src` surrounded by double square brackets as a local link into this wiki."
[html-src] [html-src]
@ -132,6 +132,23 @@
repo-path file-name version))) repo-path file-name version)))
:user (session/get :user)}))) :user (session/get :user)})))
(defn diff-page
"Render a diff between two versions 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 "Changes since 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 (d2h/diff2html (hist/diff repo-path file-name version))
:user (session/get :user)})))
(defn auth-page (defn auth-page
"Render the auth page" "Render the auth page"
@ -168,6 +185,7 @@
(POST "/edit" request (route/restricted (edit-page request))) (POST "/edit" request (route/restricted (edit-page request)))
(GET "/history" request (history-page request)) (GET "/history" request (history-page request))
(GET "/version" request (version-page request)) (GET "/version" request (version-page request))
(GET "/changes" request (diff-page request))
(GET "/auth" request (auth-page request)) (GET "/auth" request (auth-page request))
(POST "/auth" request (auth-page request)) (POST "/auth" request (auth-page request))
(GET "/about" [] (about-page))) (GET "/about" [] (about-page)))