source: trunk/src/rest_interface/publish_feeds.lisp

Last change on this file was 450, checked in by lgiessmann, 14 years ago

fixed ticket #108 and #109 => all exporters and importers have the same name-conventions

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1;;+-----------------------------------------------------------------------------
2;;+  Isidorus
3;;+  (c) 2008-2010 Marc Kuester, Christoph Ludwig, Lukas Georgieff
4;;+
5;;+  Isidorus is freely distributable under the LLGPL license.
6;;+  You can find a detailed description in trunk/docs/LLGPL-LICENSE.txt and
7;;+  trunk/docs/LGPL-LICENSE.txt.
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            (with-reader-lock
60              (d:get-fragment (parse-integer unique-id)))))
61        (if fragment
62            (xtm-exporter:export-construct-as-xtm-string fragment :xtm-format :1.0)
63            (format nil "<t:topicMap xmlns:t=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/>")))))
64   hunchentoot:*dispatch-table*))
65
66
67(defmethod publish-feed ((feed snapshots-feed))
68  (push 
69   (create-regex-dispatcher 
70    (format nil "~a~a" (path feed) "/?$") 
71    (lambda () 
72      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
73      (as-feed feed)))
74   hunchentoot:*dispatch-table*)
75  ;and now register the general snapshots method
76  (push 
77   (create-regex-dispatcher 
78    (format nil "~a~a" (path feed) "/([0-9]+)$") 
79    (lambda (&optional revision) 
80      (setf (hunchentoot:content-type*) "application/x-tm+xml;version=1.0; charset=utf-8")
81      (xtm-exporter:export-as-xtm-string
82       :revision (parse-integer revision) 
83       :tm-id (atom:tm-id feed)
84       :xtm-format :1.0)))
85   hunchentoot:*dispatch-table*))
86
87
88
89
Note: See TracBrowser for help on using the repository browser.