diff -ru cliki_0.4.3/cliki-instance.lisp cliki_0.4.3-diff/cliki-instance.lisp --- cliki_0.4.3/cliki-instance.lisp Mon May 10 12:26:20 2004 +++ cliki_0.4.3-diff/cliki-instance.lisp Thu Feb 24 00:37:51 2005 @@ -188,6 +188,10 @@ (merge-url (parse-urlstring "http://ww.telent.net/cclan/") (caar d))) t))) + ((url-query-param u "diff") + (view-page-diff handler request page title + (integer-for (car (url-query-param u "va"))) + (integer-for (car (url-query-param u "vb"))))) (t (view-page handler request page title :version version))))))) diff -ru cliki_0.4.3/cliki.asd cliki_0.4.3-diff/cliki.asd --- cliki_0.4.3/cliki.asd Mon May 10 05:55:11 2004 +++ cliki_0.4.3-diff/cliki.asd Thu Feb 24 11:31:33 2005 @@ -3,7 +3,7 @@ (in-package :cliki-system) (defsystem cliki - :depends-on (ARANEIDA net-telent-date xmls) + :depends-on (ARANEIDA net-telent-date xmls cl-html-diff) :version "0.4.3" :components ((:file "defpackage") (:file "utilities" :depends-on ("defpackage")) diff -ru cliki_0.4.3/view.lisp cliki_0.4.3-diff/view.lisp --- cliki_0.4.3/view.lisp Mon May 10 12:26:20 2004 +++ cliki_0.4.3-diff/view.lisp Thu Feb 24 11:39:18 2005 @@ -51,22 +51,39 @@ :default (car (page-versions page))))) (defun version-links (cliki page request) - (let ((ver (request-for-version page request))) - (loop for v in (reverse - (subseq (page-versions page) - 0 (min 5 (length (page-versions page))))) - if (= ver v) - collect `((b :title - ,(universal-time-to-http-date - (file-write-date (page-pathname page :version ver)))) - ,ver) - else - collect `((a :href ,(format nil "~A?v=~A" - (urlstring (page-url cliki page)) v) - :title - ,(universal-time-to-http-date - (file-write-date (page-pathname page :version v)))) - ,v)))) + (let ((ver (request-for-version page request)) + (recent-versions (reverse + (subseq (page-versions page) + 0 (min 5 (length (page-versions page))))))) + (let ((links '())) + (do ((versions recent-versions (cdr versions)) + (next-versions (cdr recent-versions) (cdr next-versions))) + ((endp versions) (reverse links)) + (let ((v (car versions)) + (next-v (car next-versions))) + (if (= ver v) + (push `((b :title + ,(universal-time-to-http-date + (file-write-date (page-pathname page :version ver)))) + ,ver) + links) + (push `((a :href ,(format nil "~A?v=~A" + (urlstring (page-url cliki page)) v) + :title + ,(universal-time-to-http-date + (file-write-date (page-pathname page :version v)))) + ,v) + links)) + (when next-v + (push `((a :href ,(format nil "~A?diff&va=~A&vb=~A" + (urlstring (page-url cliki page)) + v + next-v) + :title ,(format nil "Highlight differences between versions ~A and ~A" + v next-v)) + "<") + links))))))) + (defmethod cliki-page-footer ((cliki cliki-view) request title) @@ -194,6 +211,50 @@ (format out "This page doesn't exist yet. Please create it if you want to")))) + t) + + +(defun page-contents (cliki page &key (version :newest)) + (with-output-to-string (s) + (cliki::write-page-contents-to-stream cliki page s :version version))) + +(defun diff-page-versions (cliki page version1 version2) + (let ((a (page-contents cliki page :version version1)) + (b (page-contents cliki page :version version2))) + (html-diff:html-diff a b))) + +(defun view-page-diff (cliki request page title version1 version2) + (request-send-headers request) + (with-page-surround (cliki + request + title + '(((META :NAME "ROBOTS" :CONTENT "NOFOLLOW")))) + (if page + (progn + (let* ((topics + (sort (delete page (copy-list (page-topics page))) + #'string-lessp + :key #'page-title)) + (backlinks + (sort (set-difference + (delete page (copy-list (page-backlinks page))) + topics) + #'string-lessp :key #'page-title))) + (format out "~A" (diff-page-versions cliki page version1 version2)) + (when topics + (format out "
Page~p in this topic: " + (length topics)) + (dolist (c topics) + (format out "~A " + (write-a-href cliki (page-title c) nil)))) + (when backlinks + (format out "
~A linked from: " + (if topics "Also" "This page is")) + (dolist (c backlinks) + (format out "~A " + (write-a-href cliki (page-title c) nil)))))) + (format out + "This page doesn't exist yet. Please create it if you want to"))) t)