Changeset 3706
- Timestamp:
- 07/31/08 10:54:27 (4 months ago)
- Files:
-
- trunk/projects/bos/m2/packages.lisp (modified) (1 diff)
- trunk/projects/bos/m2/poi.lisp (modified) (3 diffs)
- trunk/projects/bos/web/poi-handlers.lisp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/m2/packages.lisp
r3695 r3706 230 230 #:poi-center-lon-lat 231 231 #:poi-images 232 #:poi-sat-images 233 #:poi-sat-images-exchange-neighbours 232 234 #:poi-airals 233 235 #:poi-panoramas trunk/projects/bos/m2/poi.lisp
r3700 r3706 118 118 (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)) 119 119 120 ;;; POI media are stored in one list - for convenience we provide 121 ;;; accessors by type. POI-IMAGES e.g. returns a list of all 122 ;;; POI-IMAGES in the same order as they appear in the media list. The 123 ;;; second value is a list of corresponding positions in that list. 120 124 (macrolet ((define-poi-medium-reader (name) 121 125 (let ((type (find-symbol (subseq (symbol-name name) 0 (1- (length (symbol-name name))))))) 122 126 (assert type) 123 127 `(defun ,name (poi) 124 (remove-if-not (lambda (medium) (typep medium ',type)) (poi-media poi)))))) 128 ;; this surely could be optimized 129 (let ((media-of-type (remove-if-not (lambda (medium) (typep medium ',type)) (poi-media poi)))) 130 (values media-of-type 131 (mapcar (lambda (medium) (position medium (poi-media poi))) media-of-type))))))) 125 132 (define-poi-medium-reader poi-images) 126 133 (define-poi-medium-reader poi-airals) 127 134 (define-poi-medium-reader poi-panoramas) 128 135 (define-poi-medium-reader poi-movies)) 136 137 (defun poi-sat-images (poi) 138 "We use the 6 last (oldest) images of POI as images for the 139 satellite application." 140 (multiple-value-bind (images positions) 141 (poi-images poi) 142 (let* ((length (length images)) 143 (start (max 0 (- length 6)))) 144 (values (subseq images start length) 145 (subseq positions start length))))) 146 147 ;;; Provides for the shifting of images in the edit-poi handler. 148 ;;; Exchanges (nth index (poi-sat-images poi)) with 149 ;;; (nth (1+ index) (poi-sat-images poi)). 150 (deftransaction poi-sat-images-exchange-neighbours (poi index) 151 (check-type index (integer 0 4)) 152 (multiple-value-bind (images positions) 153 (poi-images poi) 154 (declare (ignore images)) 155 (let ((media-index-a (nth index positions)) 156 (media-index-b (nth (1+ index) positions))) 157 (rotatef (nth media-index-a (poi-media poi)) 158 (nth media-index-b (poi-media poi)))))) 129 159 130 160 (defun make-poi-javascript (language) … … 156 186 (poi-center-x poi) 157 187 (poi-center-y poi) 158 (length (poi- images poi)))159 (format t "poi.thumbnail = ~D;~%" (length (poi- images poi)))188 (length (poi-sat-images poi))) 189 (format t "poi.thumbnail = ~D;~%" (length (poi-sat-images poi))) 160 190 (when (poi-airals poi) 161 191 … … 169 199 for slot-values = (mapcar (lambda (image) 170 200 (escape-nl (slot-string image slot-name language))) 171 (poi- images poi))201 (poi-sat-images poi)) 172 202 when slot-values 173 203 do (format t "poi.~A = [ ~{~S~^, ~} ];~%" javascript-name slot-values)) trunk/projects/bos/web/poi-handlers.lisp
r3704 r3706 57 57 (setq shift (find-store-object (parse-integer shift))) 58 58 (setq shift-by (parse-integer shift-by)) 59 (let* ((new-images (poi- images poi))59 (let* ((new-images (poi-sat-images poi)) 60 60 (old-position (position shift new-images)) 61 61 (tmp (nth old-position new-images))) … … 64 64 (setf (nth old-position new-images) (nth (+ shift-by old-position) new-images)) 65 65 (setf (nth (+ shift-by old-position) new-images) tmp) 66 (with-transaction ("setf poi- images")67 (setf (poi- images poi) new-images))))66 (with-transaction ("setf poi-sat-images") 67 (setf (poi-sat-images poi) new-images)))) 68 68 (with-bos-cms-page (:title "Edit POI") 69 69 (content-language-chooser) … … 108 108 ((:table) 109 109 (:tr 110 (loop for image in (poi- images poi)110 (loop for image in (poi-sat-images poi) 111 111 for index from 1 by 1 112 112 do (html (:td ((:a :href (format nil "/edit-poi-image/~a?poi=~A" (store-object-id image) (store-object-id poi))) 113 113 ((:img :border "0" :src (format nil "/image/~a/thumbnail,,55,55" (store-object-id image))))) 114 :br115 (if (eql index 1)116 (html ((:img :src "/images/trans.gif" :width "16")))117 (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=-1"118 (store-object-id poi)119 (store-object-id image)))120 ((:img :border "0" :src "/images/pfeil-l.gif")))))121 ((:img :src "/images/trans.gif" :width "23"))122 (unless (eql index (length (poi-images poi)))123 (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=1"124 (store-object-id poi)125 (store-object-id image)))126 ((:img :border "0" :src "/images/pfeil-r.gif"))))))))))127 (unless (eql 6 (length (poi- images poi)))114 :br 115 (if (eql index 1) 116 (html ((:img :src "/images/trans.gif" :width "16"))) 117 (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=-1" 118 (store-object-id poi) 119 (store-object-id image))) 120 ((:img :border "0" :src "/images/pfeil-l.gif"))))) 121 ((:img :src "/images/trans.gif" :width "23")) 122 (unless (eql index (length (poi-sat-images poi))) 123 (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=1" 124 (store-object-id poi) 125 (store-object-id image))) 126 ((:img :border "0" :src "/images/pfeil-r.gif")))))))))) 127 (unless (eql 6 (length (poi-sat-images poi))) 128 128 (html 129 129 :br … … 343 343 (:tr (:td "upload new image") 344 344 (:td ((:input :type "file" :name "image-file")) 345 :br346 (submit-button "upload" "upload")))345 :br 346 (submit-button "upload" "upload"))) 347 347 (:tr (:td "title") 348 348 (:td (text-field "title" … … 417 417 (let ((image-index (1- (parse-integer image-index-string)))) 418 418 (if (and (not (minusp image-index)) 419 (< image-index (length (poi- images poi))))419 (< image-index (length (poi-sat-images poi)))) 420 420 (redirect (format nil "/image/~D~@[~{/~a~}~]" 421 (store-object-id (nth image-index (poi- images poi)))421 (store-object-id (nth image-index (poi-sat-images poi))) 422 422 imageproc-arguments)) 423 423 (error "image index ~a out of bounds for poi ~a" image-index poi))))) … … 437 437 ((:param :name "allowFullScreen" :value "true")) 438 438 ((:embed :src (poi-movie-url poi-movie) :type "application/x-shockwave-flash" 439 :allowFullScreen "true"440 :width "425" :height "344")))))439 :allowFullScreen "true" 440 :width "425" :height "344"))))) 441 441 442 442 (defun write-poi-xml (poi language) … … 468 468 (description poi-description) 469 469 (airals poi-airals) 470 (images poi- images)470 (images poi-sat-images) 471 471 (panoramas poi-panoramas) 472 472 (movies poi-movies)) poi … … 565 565 (with-element "table" 566 566 (with-element "tbody" 567 (let ((images (poi- images poi)))567 (let ((images (poi-sat-images poi))) 568 568 (images-2trs (subseq images 0 (min 3 (length images)))) 569 569 (when (> (length images) 3)
