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>
|
||||
<th>When</th><th>What</th><th>Version</th><th>Changes</th>
|
||||
</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 %}
|
||||
<tr>
|
||||
<td>
|
||||
|
|
@ -14,10 +19,10 @@
|
|||
{{entry.message}}
|
||||
</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>
|
||||
<a href="history-changes?id={{entry.id}}">What's changed?</a>
|
||||
<a href="diff?page={{page}}&version={{entry.id}}">What's changed?</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
{% block content %}
|
||||
<div id="content" class="wiki">
|
||||
<div class="minor-controls">
|
||||
<a href="history?page={{title}}">History</a>
|
||||
<a href="history?page={{page}}">History</a>
|
||||
</div>
|
||||
{{content|safe}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue