Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 35ec483e35
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (62 sloc) 2.96 KB
(in-package #:cliki2)
(in-readtable cliki2)
(defun output-undo-link (revision)
(unless (youre-banned?)
#H[<input type="hidden" name="r" value="${(store-object-id revision)}" />
(<input type="submit" name="undo" value="undo" class="undo" />)]))
(defun output-compare-link (old new text)
#H[(<a class="internal" href="$(#/site/compare-revisions?old={(store-object-id old)}&diff={(store-object-id new)})">${text}</a>)])
(defpage /site/history () (title)
(awhen (find-article-any title)
(setf *title* #?'History of article: "${title}"')
#H[<h1>History of article ] (pprint-article-link title) #H[</h1>
<form method="post" action="$(#/site/history-special)">
<input type="submit" value="Compare selected versions" />
<table id="pagehistory">]
(loop for rhead on (revisions it)
for revision = (car rhead)
for author = (author revision)
for first = t then nil do
(flet ((radio (x)
#H[<td><input type="radio" name="${x}" value="${(store-object-id revision)}" /></td>]))
(awhen (cadr rhead)
(output-compare-link it revision "prev"))
(radio "old") (radio "diff")
#H[<td>] (pprint-revision-link revision)
#H[ ${(format-account-link author)} (<em>${(summary revision)}</em>) ]
(when first
(output-undo-link revision))
<input type="submit" value="Compare selected versions" />
(setf *footer* #?[<li><a href="${(link-to it)}">Current version</a></li>])))
;;; undo
(defun check-banned ()
(when (youre-banned?) #H[Your account/IP is banned from editing]))
(defpage /site/not-latest "Revision not the latest" (title)
#H[Can't undo this revision because it is not the latest.
<a href="$(#/site/history?title={title})">Go back to history page</a>.])
(defhandler /site/history-special (old diff undo r)
(if undo
(let* ((revision (find-revision r))
(article (article revision))
(latest-revision (latest-revision article)))
(cond ((check-banned))
((typep article 'deleted-article)
(link-to (toggle-delete (store-object-id article)
((eq revision latest-revision)
(prog1 (link-to article)
(if (or (typep latest-revision 'revision-undelete)
(not (cdr (revisions article))))
(toggle-delete (store-object-id article)
#?"undid last revision by ${(name (author revision))}"
(revision-content (second (revisions article)))))))
(t #/site/not-latest?title={(title article)})))
Jump to Line
Something went wrong with that request. Please try again.