source: trunk/src/rest_interface/publish_feeds.lisp @ 78

Last change on this file since 78 was 26, checked in by lgiessmann, 16 years ago

added a license header to all files where the isidorus license is mentioned and referenced, in the ajax file there is also a reference to the MIT-license; an edit/create template for fragments is implemented in the ajax module, but it\'s really terrible and not really useable - this should be only the initial idea of realizing such a functionality\!

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1;;+-----------------------------------------------------------------------------
2;;+  Isidorus
3;;+  (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann
4;;+
5;;+  Isidorus is freely distributable under the LGPL license.
6;;+  You can find a detailed description in trunk/docs/LGPL-LICENSE.txt.
7;;+-----------------------------------------------------------------------------
8
9
10(in-package :rest-interface)
11
12(defgeneric publish-feed (feed)
13  (:documentation "Register feed urls with hunchentoot"))
14
15(defmacro as-feed (feed)
16  `(setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
17  `(cxml:with-xml-output (cxml:make-string-sink :canonical t)
18     (atom:feed-to-elem ,feed)))
19
20(defun overview-feed ()
21  "Interface function to the corresponding Atom method"
22  (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
23  (as-feed atom:*tm-feed*))
24
25
26(defmethod publish-feed ((feed atom:feed))
27  (push 
28   (create-regex-dispatcher
29    (format nil "~a~a" (path feed) "/?$") #'overview-feed)
30   hunchentoot:*dispatch-table*)
31  (mapc #'publish-feed (atom:subfeeds feed)))
32
33(defmethod publish-feed ((feed atom:collection-feed))
34  (push 
35   (create-regex-dispatcher 
36    (format nil "~a~a" (path feed) "/?$") 
37    (lambda () 
38      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
39      (as-feed feed)))
40   hunchentoot:*dispatch-table*)
41  (mapc #'publish-feed (atom:subfeeds feed)))
42
43(defmethod publish-feed ((feed atom:fragments-feed))
44  (push 
45   (create-regex-dispatcher 
46    (format nil "~a~a" (path feed) "/?$") 
47    (lambda () 
48      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
49      (as-feed feed)))
50   hunchentoot:*dispatch-table*)
51  ;and now register the general fragments method
52  (push 
53   (create-regex-dispatcher 
54    (format nil "~a~a" (path feed) "/([0-9]+)$") 
55    (lambda (&optional unique-id) 
56      (setf (hunchentoot:content-type*) "application/x-tm+xml;version=1.0; charset=utf-8")
57      (let 
58          ((fragment 
59            (d:get-fragment (parse-integer unique-id))))
60        (if fragment
61            (exporter:export-xtm-fragment fragment :xtm-format '1.0)
62            (format nil "<t:topicMap xmlns:t=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/>")))))
63   hunchentoot:*dispatch-table*))
64
65(defmethod publish-feed ((feed snapshots-feed))
66  (push 
67   (create-regex-dispatcher 
68    (format nil "~a~a" (path feed) "/?$") 
69    (lambda () 
70      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
71      (as-feed feed)))
72   hunchentoot:*dispatch-table*)
73  ;and now register the general snapshots method
74  (push 
75   (create-regex-dispatcher 
76    (format nil "~a~a" (path feed) "/([0-9]+)$") 
77    (lambda (&optional revision) 
78      (setf (hunchentoot:content-type*) "application/x-tm+xml;version=1.0; charset=utf-8")
79      (exporter:export-xtm-to-string 
80       :revision (parse-integer revision) 
81       :tm-id (atom:tm-id feed)
82       :xtm-format '1.0)))
83   hunchentoot:*dispatch-table*))
84
85
86
87
Note: See TracBrowser for help on using the repository browser.