source: project/release/4/qwiki/trunk/qwiki-sxml.scm @ 15367

Last change on this file since 15367 was 15367, checked in by sjamaan, 11 years ago

Add history viewing functionality

File size: 3.2 KB
Line 
1;;
2;; qwiki-sxml - SXML rules and tools for qwiki
3;;
4;; Copyright (c) 2009 Peter Bex
5;;
6;;  Redistribution and use in source and binary forms, with or without
7;;  modification, are permitted provided that the following conditions
8;;  are met:
9;;
10;;  - Redistributions of source code must retain the above copyright
11;;  notice, this list of conditions and the following disclaimer.
12;;
13;;  - Redistributions in binary form must reproduce the above
14;;  copyright notice, this list of conditions and the following
15;;  disclaimer in the documentation and/or other materials provided
16;;  with the distribution.
17;;
18;;  - Neither name of the copyright holders nor the names of its
19;;  contributors may be used to endorse or promote products derived
20;;  from this software without specific prior written permission.
21;;
22;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE
23;;  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24;;  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25;;  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26;;  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR THE
27;;  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28;;  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29;;  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30;;  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31;;  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32;;  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33;;  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34;;  POSSIBILITY OF SUCH DAMAGE.
35
36(provide 'qwiki-sxml)
37
38(module qwiki-sxml
39  (qwiki-basic-transformation-rules)
40
41(import chicken scheme)
42
43(use posix sxpath-lolevel sxml-transforms doctype uri-generic)
44
45(define qwiki-basic-transformation-rules
46  `((wiki-page
47     *macro* . ,(lambda page
48                  `((xhtml-1.0-strict)
49                    (html
50                     (head
51                      (title ,(or (sxml:attr 'title page) "qwiki")))
52                     (body
53                      (page-specific-links)
54                      ,@(sxml:content-raw page))))))
55    ;; Maybe this should be done in multiple steps to make it more "hookable"
56    (history
57     *macro* . ,(lambda (history items)
58                  `(table
59                    (tr (th "revision")
60                        (th "author")
61                        (th "date")
62                        (th "description"))
63                    ,@(map (lambda (item)
64                             `(tr (td (url ,(string-append
65                                             "?action=show&rev="
66                                             (number->string (car item)))
67                                           ,(car item)))
68                                  (td ,(cadr item))
69                                  (td ,(time->string (caddr item)))
70                                  (td ,(cadddr item))))
71                           items))))
72    (page-specific-links
73     *macro* . ,(lambda _
74                  `(ul (@ (class "page-specific-links"))
75                       (li (url "?action=show" "show"))
76                       (li (url "?action=edit" "edit"))
77                       (li (url "?action=history" "history")))))
78    ,@alist-conv-rules))
79
80)
Note: See TracBrowser for help on using the repository browser.