mirror of
https://github.com/journeyman-cc/smeagol.git
synced 2026-04-12 18:05:06 +00:00
History feature now fully working; Diff feature close but not there yet.
This commit is contained in:
parent
b0619a58d0
commit
62b325cb68
4 changed files with 40 additions and 8 deletions
|
|
@ -5,6 +5,11 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>When</th><th>What</th><th>Version</th><th>Changes</th>
|
<th>When</th><th>What</th><th>Version</th><th>Changes</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Now</td><td></td>
|
||||||
|
<td><a href="wiki?content={{page}}">[current]</a></td>
|
||||||
|
<td>[no changes]</td>
|
||||||
|
<tr>
|
||||||
{% for entry in history %}
|
{% for entry in history %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
@ -14,10 +19,10 @@
|
||||||
{{entry.message}}
|
{{entry.message}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="history-version?id={{entry.id}}">Show version</a>
|
<a href="version?page={{page}}&version={{entry.id}}">Show version</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="history-changes?id={{entry.id}}">What's changed?</a>
|
<a href="diff?page={{page}}&version={{entry.id}}">What's changed?</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="content" class="wiki">
|
<div id="content" class="wiki">
|
||||||
<div class="minor-controls">
|
<div class="minor-controls">
|
||||||
<a href="history?page={{title}}">History</a>
|
<a href="history?page={{page}}">History</a>
|
||||||
</div>
|
</div>
|
||||||
{{content|safe}}
|
{{content|safe}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@
|
||||||
`git-directory-path` between versions `older` and `newer` or between the specified
|
`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.
|
`version` and the current version of the file. Returns the diff as a string.
|
||||||
|
|
||||||
Based on JGit Cookbook ShowFileDiff.
|
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]
|
||||||
([^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]
|
([^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)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
(:use clojure.walk)
|
(:use clojure.walk)
|
||||||
(:require [compojure.core :refer :all]
|
(:require [compojure.core :refer :all]
|
||||||
[clj-jgit.porcelain :as git]
|
[clj-jgit.porcelain :as git]
|
||||||
|
[markdown.core :as md]
|
||||||
[noir.io :as io]
|
[noir.io :as io]
|
||||||
[noir.response :as response]
|
[noir.response :as response]
|
||||||
[noir.util.route :as route]
|
[noir.util.route :as route]
|
||||||
|
|
@ -70,7 +71,7 @@
|
||||||
(cond src-text (process-source params)
|
(cond src-text (process-source params)
|
||||||
true
|
true
|
||||||
(layout/render "edit.html"
|
(layout/render "edit.html"
|
||||||
{:title content
|
{:title (str "Edit " content)
|
||||||
:left-bar (local-links (util/md->html "/content/_edit-left-bar.md"))
|
:left-bar (local-links (util/md->html "/content/_edit-left-bar.md"))
|
||||||
:header (local-links (util/md->html "/content/_header.md"))
|
:header (local-links (util/md->html "/content/_header.md"))
|
||||||
:content (if exists? (io/slurp-resource file-name) "")
|
:content (if exists? (io/slurp-resource file-name) "")
|
||||||
|
|
@ -88,6 +89,7 @@
|
||||||
(cond exists?
|
(cond exists?
|
||||||
(layout/render "wiki.html"
|
(layout/render "wiki.html"
|
||||||
{:title content
|
{:title content
|
||||||
|
:page content
|
||||||
:left-bar (local-links (util/md->html "/content/_left-bar.md"))
|
:left-bar (local-links (util/md->html "/content/_left-bar.md"))
|
||||||
:header (local-links (util/md->html "/content/_header.md"))
|
:header (local-links (util/md->html "/content/_header.md"))
|
||||||
:content (local-links (util/md->html file-name))
|
:content (local-links (util/md->html file-name))
|
||||||
|
|
@ -95,7 +97,8 @@
|
||||||
true (response/redirect (str "/edit?content=" content)))))
|
true (response/redirect (str "/edit?content=" content)))))
|
||||||
|
|
||||||
(defn history-page
|
(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]
|
[request]
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
page (or (:page params) "Introduction")
|
page (or (:page params) "Introduction")
|
||||||
|
|
@ -103,10 +106,33 @@
|
||||||
repo-path (str (io/resource-path) "/content/")]
|
repo-path (str (io/resource-path) "/content/")]
|
||||||
(layout/render "history.html"
|
(layout/render "history.html"
|
||||||
{:title (str "History of " page)
|
{:title (str "History of " page)
|
||||||
|
:page page
|
||||||
:left-bar (local-links (util/md->html "/content/_left-bar.md"))
|
:left-bar (local-links (util/md->html "/content/_left-bar.md"))
|
||||||
:header (local-links (util/md->html "/content/_header.md"))
|
:header (local-links (util/md->html "/content/_header.md"))
|
||||||
:history (hist/find-history repo-path file-name)})))
|
: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
|
(defn auth-page
|
||||||
"Render the auth page"
|
"Render the auth page"
|
||||||
[request]
|
[request]
|
||||||
|
|
@ -141,6 +167,7 @@
|
||||||
(GET "/edit" request (route/restricted (edit-page request)))
|
(GET "/edit" request (route/restricted (edit-page request)))
|
||||||
(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 "/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)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue