Changeset 3653
- Timestamp:
- 07/28/08 12:48:50 (4 months ago)
- Files:
-
- trunk/projects/bos/payment-website/static/MochiKit (added)
- trunk/projects/bos/payment-website/static/cms.js (modified) (1 diff)
- trunk/projects/bos/web/poi-handlers.lisp (modified) (19 diffs)
- trunk/projects/bos/web/webserver.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/payment-website/static/cms.js
r2160 r3653 93 93 } 94 94 } 95 96 function confirm_delete(field_name, value, confirm_string) 97 { 98 $(field_name).value = value; 99 return confirm(confirm_string); 100 } trunk/projects/bos/web/poi-handlers.lisp
r3652 r3653 1 2 1 (in-package :bos.web) 3 2 … … 6 5 (defclass make-poi-handler (page-handler) 7 6 ()) 8 7 9 8 (defmethod handle ((handler make-poi-handler)) 10 9 (with-query-params (name) … … 65 64 (setf (nth old-position new-images) (nth (+ shift-by old-position) new-images)) 66 65 (setf (nth (+ shift-by old-position) new-images) tmp) 67 (change-slot-values poi 'bos.m2::images new-images))) 66 (with-transaction ("setf poi-images") 67 (setf (poi-images poi) new-images)))) 68 68 (with-bos-cms-page (:title "Edit POI") 69 69 (content-language-chooser) … … 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"))))))))))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-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 127 (unless (eql 6 (length (poi-images poi))) 128 128 (html … … 140 140 :br 141 141 (submit-button "upload-airal" "upload-airal"))))) 142 (:tr (:td "panorama view") 142 (:tr (:td "panorama view" 143 ((:input :id "panorama-id" :type "hidden" :name "panorama-id"))) 143 144 (:td (dolist (panorama (poi-panoramas poi)) 144 145 (html (:princ-safe (format-date-time (blob-timestamp panorama))) 145 146 ((:a :href (format nil "/image/~D" (store-object-id panorama)) :target "_new" :class "cmslink") 146 147 " view ") 147 (submit-button "delete-panorama" "delete-panorama" :confirm "Really delete this panorama image?") 148 (submit-button "delete-panorama" "delete-panorama" 149 :formcheck #?"javascript:confirm_delete('panorama-id', $((store-object-id panorama)), 'Really delete this panorama image?')") 148 150 :br)) 149 151 (html "Upload new panorama view" … … 192 194 (error "no file uploaded in upload handler")) 193 195 (with-image-from-upload* (uploaded-file) 194 (unless (and (eql (cl-gd:image-width) *poi-image-width*) 195 (eql (cl-gd:image-height) *poi-image-height*)) 196 (with-bos-cms-page (:title "Invalid image size") 197 (:h2 "Invalid image size") 198 (:p "The image needs to be " 199 (:princ-safe *poi-image-width*) " pixels wide and " 200 (:princ-safe *poi-image-height*) " pixels high. Your uploaded image is " 201 (:princ-safe (cl-gd:image-width)) " pixels wide and " 202 (:princ-safe (cl-gd:image-height)) " pixels high. Please use an image editor " 203 "to resize the image and upload it again.") 204 (:p (cmslink (edit-object-url poi) "Back to POI"))) 205 (return-from handle-object-form t))) 206 (change-slot-values poi 'airals (list (import-image (upload-pathname uploaded-file) 207 :class-name 'store-image)))) 208 (redirect (format nil "/edit-poi/~D" 209 (store-object-id poi)))) 196 (cond 197 ((and (eql (cl-gd:image-width) *poi-image-width*) 198 (eql (cl-gd:image-height) *poi-image-height*)) 199 (with-transaction ("set airals") 200 (setf (poi-airals poi) (print (list (import-image uploaded-file :class-name 'store-image))))) 201 (redirect (format nil "/edit-poi/~D" 202 (store-object-id poi)))) 203 (t 204 (with-bos-cms-page (:title "Invalid image size") 205 (:h2 "Invalid image size") 206 (:p "The image needs to be " 207 (:princ-safe *poi-image-width*) " pixels wide and " 208 (:princ-safe *poi-image-height*) " pixels high. Your uploaded image is " 209 (:princ-safe (cl-gd:image-width)) " pixels wide and " 210 (:princ-safe (cl-gd:image-height)) " pixels high. Please use an image editor " 211 "to resize the image and upload it again.") 212 (:p (cmslink (edit-object-url poi) "Back to POI")))))))) 210 213 211 214 (defmethod handle-object-form ((handler edit-poi-handler) … … 213 216 (poi poi)) 214 217 (let ((airals (poi-airals poi))) 215 (change-slot-values poi 'airals nil) 218 (with-transaction ("setf poi-airals nil") 219 (setf (poi-airals poi) nil)) 216 220 (mapc #'delete-object airals)) 217 221 (redirect (format nil "/edit-poi/~D" … … 221 225 (action (eql :delete-movie)) 222 226 (poi poi)) 223 (change-slot-values poi 'movies nil) 227 (with-transaction ("setf poi-movies nil") 228 (setf (poi-movies poi) nil)) 224 229 (redirect (format nil "/edit-poi/~D" (store-object-id poi)))) 225 230 … … 230 235 (unless uploaded-file 231 236 (error "no file uploaded in upload handler")) 232 (with-image-from-upload* (uploaded-file) 233 ; just open the image to make sure that gd can process it 234 ) 235 (change-slot-values poi 'panoramas (cons (import-image (upload-pathname uploaded-file) 236 :class-name 'store-image) 237 (poi-panoramas poi)))) 237 ;; just open the image to make sure that gd can process it 238 (with-image-from-upload* (uploaded-file)) 239 (with-transaction ("add poi-panorama") 240 (push (import-image uploaded-file :class-name 'store-image) (poi-panoramas poi)))) 238 241 (redirect (format nil "/edit-poi/~D" 239 242 (store-object-id poi)))) … … 244 247 (with-query-params (panorama-id) 245 248 (let ((panorama (find-store-object (parse-integer panorama-id)))) 246 (change-slot-values poi 'panoramas (remove panorama (poi-panoramas poi))) 247 (mapc #'delete-object panorama))) 249 (with-transaction ("delete poi-panorama") 250 (alexandria:deletef (poi-panoramas poi) panorama)) 251 (delete-object panorama))) 248 252 (redirect (format nil "/edit-poi/~D" 249 253 (store-object-id poi)))) … … 293 297 (if poi-image 294 298 (blob-from-file poi-image uploaded-file) 295 (setq poi-image (import-image (upload-pathname uploaded-file)299 (setq poi-image (import-image uploaded-file 296 300 :class-name 'poi-image 297 301 :initargs `(:poi ,poi)))) … … 315 319 (:tr (:td "upload new image") 316 320 (:td ((:input :type "file" :name "image-file")) 317 :br318 (submit-button "upload" "upload")))321 :br 322 (submit-button "upload" "upload"))) 319 323 (:tr (:td "title") 320 324 (:td (text-field "title" … … 365 369 (reduce #'max last-paid-contracts 366 370 :key (lambda (contract) (store-object-last-change contract 0)))))) 367 (hunchentoot:handle-if-modified-since timestamp) 371 (hunchentoot:handle-if-modified-since timestamp) 368 372 (setf (hunchentoot:header-out :last-modified) 369 373 (hunchentoot:rfc-1123-date timestamp)) 370 (with-http-response (:content-type "text/html; charset=UTF-8") 374 (with-http-response (:content-type "text/html; charset=UTF-8") 371 375 (with-http-body () 372 376 (html … … 410 414 (with-element "image" 411 415 (attribute "id" (princ-to-string (store-object-id image))) 412 (when (typep image 'poi-image) 416 (when (typep image 'poi-image) 413 417 (attribute "title" (slot-string image 'title language)) 414 (attribute "subtitle" (slot-string image 'subtitle language)) 418 (attribute "subtitle" (slot-string image 'subtitle language)) 415 419 (with-element "description" (text (slot-string image 'description language)))) 416 420 (with-element "url" (text (format nil "http://createrainforest.org/image/~D" 417 (store-object-id image)))) 421 (store-object-id image)))) 418 422 (with-element "width" (text (princ-to-string (store-image-width image)))) 419 423 (with-element "height" (text (princ-to-string (store-image-height image))))))) … … 481 485 (with-element "tr" 482 486 (dolist (image images) 483 (img-td image))) 487 (img-td image))) 484 488 ;; titles 485 489 (with-element "tr" … … 488 492 (handler-case 489 493 (with-xml-output (make-string-sink) 490 (with-element "html" 494 (with-element "html" 491 495 (with-element "head") 492 496 (with-element "body" 493 497 (with-element "table" 494 498 (attribute "cellspacing" "0") (attribute "width" "500") (attribute "cellpadding" "5") (attribute "border" "0") 495 (attribute "style" "background-color: rgb(186, 186, 186);") 499 (attribute "style" "background-color: rgb(186, 186, 186);") 496 500 (with-element "tbody" 497 501 (with-element "tr" … … 567 571 (defmethod handle-object ((handler poi-xml-handler) poi) 568 572 (let ((timestamp (store-object-last-change poi 1))) 569 (hunchentoot:handle-if-modified-since timestamp) 573 (hunchentoot:handle-if-modified-since timestamp) 570 574 (setf (hunchentoot:header-out :last-modified) 571 575 (hunchentoot:rfc-1123-date timestamp)) … … 581 585 (defmethod handle-object ((handler poi-kml-handler) poi) 582 586 (with-query-params ((lang "en")) 583 (with-xml-response () 587 (with-xml-response () 584 588 (with-namespace (nil "http://earth.google.com/kml/2.1") 585 589 (with-element "kml" … … 611 615 (kml-region (make-rectangle2 (list 0 0 +width+ +width+)) '(:min 600 :max -1)) 612 616 (mapc #'(lambda (poi) (write-poi-kml poi lang)) relevant-pois)))))))) 613 614 trunk/projects/bos/web/webserver.lisp
r3644 r3653 226 226 :site-logo-url "/images/bos-logo.gif" 227 227 :style-sheet-urls '("/static/cms.css") 228 :javascript-urls '("/static/cms.js" "/static/tiny_mce/tiny_mce.js" ))228 :javascript-urls '("/static/cms.js" "/static/tiny_mce/tiny_mce.js" "/static/MochiKit/MochiKit.js")) 229 229 230 230 (publish-directory :prefix "/static/"
