Changeset 2763

Show
Ignore:
Timestamp:
03/19/08 15:31:41 (10 months ago)
Author:
ksprotte
Message:

added poi-xml-handler

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/bos/web/poi-handlers.lisp

    r2660 r2763  
    389389          (error "image index ~a out of bounds for poi ~a" image-index poi))))) 
    390390 
     391(defclass poi-xml-handler (object-handler) 
     392  () 
     393  (:default-initargs :object-class 'poi :query-function #'find-poi)) 
     394 
     395 
     396(defmethod handle-object ((handler poi-xml-handler) poi) 
     397  (labels ((format-hash-table (element-name hash-table) 
     398             (with-element element-name 
     399               (maphash (lambda (k v)                         
     400                          (with-element "content" 
     401                            (attribute "lang" k) 
     402                            (text v))) 
     403                        hash-table))) 
     404           (format-store-image (element-name store-image) 
     405             (with-element element-name 
     406               (with-element "id" (text (princ-to-string (store-object-id store-image)))) 
     407               (with-element "name" (text (store-image-name store-image))) 
     408               (with-element "width" (text (princ-to-string (store-image-width store-image)))) 
     409               (with-element "height" (text (princ-to-string (store-image-height store-image))))))) 
     410    (with-accessors ((id store-object-id) 
     411                     (name poi-name) 
     412                     (title poi-title) 
     413                     (subtitle poi-subtitle) 
     414                     (description poi-description) 
     415                     (airals poi-airals) 
     416                     (images poi-images) 
     417                     (panoramas poi-panoramas) 
     418                     (movies poi-movies)) poi 
     419      (with-xml-response (:root-element "poi") 
     420        (with-element "id" (text (princ-to-string id))) 
     421        (with-element "name" (text name)) 
     422        (format-hash-table "title" title) 
     423        (format-hash-table "subtitle" subtitle) 
     424        (format-hash-table "description" description)         
     425        (with-element "airals" 
     426          (mapc (alexandria:curry #'format-store-image "airal") airals)) 
     427        (with-element "images" 
     428          (mapc (alexandria:curry #'format-store-image "image") images)) 
     429        (with-element "panoramas" 
     430          (mapc (alexandria:curry #'format-store-image "panorama") panoramas)) 
     431        (with-element "movies" 
     432          (dolist (url movies) 
     433            (with-element "movie" 
     434              (with-element "url" (text url))))))))) 
     435 
  • trunk/projects/bos/web/webserver.lisp

    r2755 r2763  
    210210                                        ("/edit-news" edit-news-handler) 
    211211                                        ("/make-poi" make-poi-handler) 
    212                                         ("/poi-image" poi-image-handler)  
     212                                        ("/poi-image" poi-image-handler) 
     213                                        ("/poi-xml" poi-xml-handler) 
    213214                                        ("/map-browser" map-browser-handler) 
    214215                                        ("/poi-javascript" poi-javascript-handler)