Changeset 3771

Show
Ignore:
Timestamp:
09/02/08 16:36:21 (3 months ago)
Author:
ksprotte
Message:

POI edit handler is done. Added new generic function: poi-medium-creation-time (and a slot for poi-movie)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/bos/m2/packages.lisp

    r3759 r3771  
    211211           #:poi-medium 
    212212           #:poi-medium-poi 
     213           #:poi-medium-creation-time 
    213214           #:make-poi-medium 
    214215           #:poi-image 
  • trunk/projects/bos/m2/poi.lisp

    r3759 r3771  
    6161    (format stream "~D" (store-object-id object)))) 
    6262 
     63(defgeneric poi-medium-creation-time (medium) 
     64  (:method ((medium blob)) 
     65    (blob-timestamp medium))) 
     66 
    6367(defmethod destroy-object :before ((poi-medium poi-medium)) 
    6468  (with-slots (poi) poi-medium 
     
    8084;;; poi-movie 
    8185(defpersistent-class poi-movie (poi-medium) 
    82   ((url :accessor poi-movie-url :initarg :url :initform nil))) 
     86  ((url :accessor poi-movie-url :initarg :url :initform nil) 
     87   (created :initform (get-universal-time) :reader poi-medium-creation-time))) 
    8388 
    8489;;; poi 
     
    136141(defun poi-center-lon-lat (poi) 
    137142  (geo-utm:utm-x-y-to-lon-lat (+ +nw-utm-x+ (poi-center-x poi)) (- +nw-utm-y+ (poi-center-y poi)) +utm-zone+ t)) 
     143 
     144(defmethod (setf poi-media) :after (value (poi poi)) 
     145  (setf (slot-value poi 'media) (sort (slot-value poi 'media) #'> :key #'poi-medium-creation-time))) 
    138146 
    139147;;; POI media are stored in one list - for convenience we provide 
  • trunk/projects/bos/web/poi-handlers.lisp

    r3769 r3771  
    105105        (:tr (:td "icon") 
    106106             (:td (icon-chooser "icon" (poi-icon poi)))) 
    107         (:tr (:td "sat images") 
     107        (:tr (:td "images for sat-app") 
    108108             (:td 
    109109              ((:table) 
     
    154154       (dolist (medium (poi-media poi)) 
    155155         (html (:tr (:td (:princ-safe (medium-pretty-type-string medium))) 
    156                     (:td (:table (medium-handler-preview medium :small t) 
    157                                  (:tr (:td) 
    158                                       (:td (cmslink (format nil "/edit-poi-medium/~D?poi=~D" 
    159                                                             (store-object-id medium) (store-object-id poi)) 
    160                                              "edit")))))))))))) 
     156                    (:td (:table 
     157                          (:colgroup ((:col :width "80")) ((:col :width "400"))) 
     158                          (:tr (:td) 
     159                               (:td (:b (:princ-safe (slot-string medium 'title language "[no title]")))) 
     160                               (:td (:princ-safe (format-date-time (poi-medium-creation-time medium))))) 
     161                          (:tr (:td ((:p :style "text-align:center;") 
     162                                     (cmslink (format nil "/edit-poi-medium/~D?poi=~D" 
     163                                                      (store-object-id medium) (store-object-id poi)) 
     164                                       "edit")) 
     165                                    ((:p :style "text-align:center;") 
     166                                     (cmslink (format nil "/edit-poi-medium/~D?action=delete&ask-for-confirmation=on&poi=~D" 
     167                                                      (store-object-id medium) (store-object-id poi)) 
     168                                       "delete"))) 
     169                               ((:td :colspan "2") (medium-handler-preview medium :small t)))))))))))) 
    161170 
    162171(defmethod handle-object-form ((handler edit-poi-handler) 
     
    202211       (cmslink (edit-object-url (poi-medium-poi medium)) "Back to POI") 
    203212       (content-language-chooser) 
    204        (:table (medium-handler-preview medium
     213       (:table (:tr (:td) (:td (medium-handler-preview medium))
    205214               (:tr ((:td :colspan "2" :height "10"))) 
    206215               ((:form :method "post" :enctype "multipart/form-data") 
     
    227236 
    228237(defgeneric medium-pretty-type-string (medium) 
    229   (:method ((medium poi-image)) "POI Image") 
    230   (:method ((medium poi-panorama)) "POI Panorama") 
    231   (:method ((medium poi-airal)) "POI Airal") 
    232   (:method ((medium poi-movie)) "POI Movie")) 
     238  (:method ((medium poi-image)) "Image") 
     239  (:method ((medium poi-panorama)) "Panorama") 
     240  (:method ((medium poi-airal)) "Airal") 
     241  (:method ((medium poi-movie)) "Movie")) 
    233242 
    234243(defgeneric medium-handler-preview (medium &key small) 
    235   (:method ((medium t) &key small) 
     244  (:method ((medium poi-medium) &key small) 
    236245    (declare (ignore small)) 
    237     (html ((:tr :colspan "2") "No preview"))) 
     246    (html "No preview")) 
    238247  (:method ((medium store-image) &key small) 
    239248    "The default method for store-images." 
    240249    (html 
    241      (:tr (:td "thumbnail") 
    242           (:td ((:a :href (format nil "/image/~A" (store-object-id medium)) 
    243                     :target "_blank") 
    244                 ((:img :src (format nil "/image/~A/thumbnail,,55,55" (store-object-id medium))))))) 
     250     ((:a :href (format nil "/edit-poi-medium/~A?poi=~A" 
     251                        (store-object-id medium) (store-object-id (poi-medium-poi medium)))) 
     252      ((:img :src (format nil "/image/~A/thumbnail,,70,70" (store-object-id medium))))) 
    245253     (unless small 
    246254       (html 
    247         (:tr (:td "full image") 
    248              (:td ((:img :src (format nil "/image/~A" (store-object-id medium)))))))))) 
     255        (:p "Full size:" 
     256            (:br) 
     257            ((:img :src (format nil "/image/~A" (store-object-id medium))))))))) 
    249258  (:method ((medium poi-panorama) &key small) 
    250     (html 
    251      (:tr (:td "thumbnail") 
    252           (:td (if small 
    253                    (html 
    254                     ((:a :href (format nil "/image/~A" (store-object-id medium)) 
    255                          :target "_blank") 
    256                      ((:img :src (format nil "/image/~A/thumbnail,,500,100" (store-object-id medium)))))) 
    257                    (html 
    258                     ((:applet :archive "/static/ptviewer.jar" 
    259                               :code "ptviewer.class" 
    260                               :width "300" 
    261                               :height "150") 
    262                      ((:param :name "file" 
    263                               :value (format nil "/image/~A" (store-object-id medium)))) 
    264                      ((:param :name "quality" :value "3"))))))))) 
     259    (if small 
     260        (html 
     261         ((:a :href (format nil "/edit-poi-medium/~A?poi=~A" 
     262                            (store-object-id medium) (store-object-id (poi-medium-poi medium)))) 
     263          ((:img :src (format nil "/image/~A/thumbnail,,500,100" (store-object-id medium)))))) 
     264        (html 
     265         ((:applet :archive "/static/ptviewer.jar" 
     266                   :code "ptviewer.class" 
     267                   :width "300" 
     268                   :height "150") 
     269          ((:param :name "file" 
     270                   :value (format nil "/image/~A" (store-object-id medium)))) 
     271          ((:param :name "quality" :value "3")))))) 
    265272  (:method ((medium poi-movie) &key small) 
    266273    (if small 
    267274        (call-next-method) 
    268275        (html 
    269          (:tr (:td "movie") 
    270               (:td ((:embed :src (poi-movie-url medium) 
    271                             :type "application/x-shockwave-flash" 
    272                             :allowFullScreen "true" 
    273                             :width "425" :height "344")))))))) 
     276         ((:embed :src (poi-movie-url medium) 
     277                  :type "application/x-shockwave-flash" 
     278                  :allowFullScreen "true" 
     279                  :width "425" :height "344")))))) 
    274280 
    275281(defgeneric medium-handler-validate-image-size (medium-or-type width height) 
     
    301307 
    302308(defmethod handle-object-form ((handler edit-poi-medium-handler) (action (eql :delete)) (medium poi-medium)) 
    303   (let ((poi (poi-medium-poi medium)) 
    304         (type-string (medium-pretty-type-string medium))) 
    305     (delete-object medium) 
    306     (with-bos-cms-page (:title (format nil "~A has been deleted" type-string)) 
    307       (:h2 (format nil "The ~A has been deleted" type-string)) 
    308       "You may " (cmslink (edit-object-url poi) "continue editing the POI")))) 
     309  (with-query-params ((ask-for-confirmation nil boolean)) 
     310    (let ((poi (poi-medium-poi medium)) 
     311          (type-string (medium-pretty-type-string medium))) 
     312      (cond 
     313        (ask-for-confirmation 
     314         (with-bos-cms-page (:title (format nil "Really delete ~A?" type-string)) 
     315           (:h2 (format nil "Really delete ~A?" type-string)) 
     316           (:p "Yes, " (cmslink (format nil "/edit-poi-medium/~D?action=delete&poi=~D" 
     317                                        (store-object-id medium) (store-object-id poi)) 
     318                         "delete it.")) 
     319           (:p "No, take me " (cmslink (edit-object-url poi) "back to the POI")))) 
     320        (t 
     321         (delete-object medium) 
     322         (with-bos-cms-page (:title (format nil "~A has been deleted" type-string)) 
     323           (:h2 (format nil "The ~A has been deleted" type-string)) 
     324           "You may " (cmslink (edit-object-url poi) "continue editing the POI"))))))) 
    309325 
    310326(defmethod handle-object-form ((handler edit-poi-medium-handler) (action (eql :upload)) medium)