Changeset 2479
- Timestamp:
- 02/11/08 18:24:41 (1 year ago)
- Files:
-
- branches/trunk-reorg/projects/bos/m2/m2.lisp (modified) (2 diffs)
- branches/trunk-reorg/projects/bos/m2/mail-generator.lisp (modified) (3 diffs)
- branches/trunk-reorg/projects/bos/m2/packages.lisp (modified) (1 diff)
- branches/trunk-reorg/projects/bos/web/allocation-area-handlers.lisp (modified) (8 diffs)
- branches/trunk-reorg/projects/bos/web/allocation-cache-handlers.lisp (modified) (1 diff)
- branches/trunk-reorg/projects/bos/web/boi-handlers.lisp (modified) (5 diffs)
- branches/trunk-reorg/projects/bos/web/bos.web.asd (modified) (1 diff)
- branches/trunk-reorg/projects/bos/web/contract-handlers.lisp (modified) (1 diff)
- branches/trunk-reorg/projects/bos/web/contract-image-handler.lisp (modified) (1 diff)
- branches/trunk-reorg/projects/bos/web/kml-handlers.lisp (modified) (2 diffs)
- branches/trunk-reorg/projects/bos/web/languages-handler.lisp (modified) (2 diffs)
- branches/trunk-reorg/projects/bos/web/map-browser-handler.lisp (modified) (5 diffs)
- branches/trunk-reorg/projects/bos/web/map-handlers.lisp (modified) (5 diffs)
- branches/trunk-reorg/projects/bos/web/news-handlers.lisp (modified) (3 diffs)
- branches/trunk-reorg/projects/bos/web/packages.lisp (modified) (2 diffs)
- branches/trunk-reorg/projects/bos/web/poi-handlers.lisp (modified) (20 diffs)
- branches/trunk-reorg/projects/bos/web/reports-xml-handler.lisp (modified) (1 diff)
- branches/trunk-reorg/projects/bos/web/sponsor-handlers.lisp (modified) (15 diffs)
- branches/trunk-reorg/projects/bos/web/web-macros.lisp (modified) (3 diffs)
- branches/trunk-reorg/projects/bos/web/web-utils.lisp (modified) (3 diffs)
- branches/trunk-reorg/projects/bos/web/webserver.lisp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/trunk-reorg/projects/bos/m2/m2.lisp
r2418 r2479 190 190 ()) 191 191 192 (defmethod bknr.web:authorized-p ((handler editor-only-handler) req)193 (editor-p (bknr-request-user req)))192 (defmethod bknr.web:authorized-p ((handler editor-only-handler)) 193 (editor-p bknr.web:*user*)) 194 194 195 195 ;;;; CONTRACT … … 447 447 retval)) 448 448 449 (defun string-safe (string) 450 (if string 451 (escape-nl (with-output-to-string (s) 452 (net.html.generator::emit-safe s string))) 453 "")) 449 ;; trunk-reorg adaption 450 ;; (defun string-safe (string) 451 ;; (if string 452 ;; (escape-nl (with-output-to-string (s) 453 ;; (net.html.generator::emit-safe s string))) 454 ;; "")) 454 455 455 456 (defun make-m2-javascript (sponsor) branches/trunk-reorg/projects/bos/m2/mail-generator.lisp
r2405 r2479 252 252 (delete-file (contract-pdf-pathname contract :print t)))) 253 253 254 (defun mail-backoffice-sponsor-data (contract req)255 (with-query-params ( reqnumsqm country email name address date language)254 (defun mail-backoffice-sponsor-data (contract) 255 (with-query-params (numsqm country email name address date language) 256 256 (let ((parts (list (make-html-part (format nil " 257 257 <html> … … 295 295 296 296 (defun mail-manual-sponsor-data (req) 297 (with-query-params ( reqcontract-id vorname name strasse plz ort email telefon want-print donationcert-yearly)297 (with-query-params (contract-id vorname name strasse plz ort email telefon want-print donationcert-yearly) 298 298 (let* ((contract (store-object-with-id (parse-integer contract-id))) 299 299 (sponsor-id (store-object-id (contract-sponsor contract))) … … 364 364 365 365 (defun mail-worldpay-sponsor-data (req) 366 (with-query-params ( reqcontract-id)366 (with-query-params (contract-id) 367 367 (let* ((contract (store-object-with-id (parse-integer contract-id))) 368 368 (params (get-worldpay-params contract-id)) branches/trunk-reorg/projects/bos/m2/packages.lisp
r2418 r2479 55 55 :bknr.rss 56 56 :bos.m2.config 57 : net.post-office57 :cl-smtp 58 58 :kmrcl 59 59 :cxml branches/trunk-reorg/projects/bos/web/allocation-area-handlers.lisp
r2401 r2479 7 7 ()) 8 8 9 (defmethod handle-object-form ((handler allocation-area-handler) action (allocation-area (eql nil)) req)10 (with-bos-cms-page ( req:title "Allocation Areas")9 (defmethod handle-object-form ((handler allocation-area-handler) action (allocation-area (eql nil))) 10 (with-bos-cms-page (:title "Allocation Areas") 11 11 (html 12 12 (:h2 "Defined allocation areas") … … 28 28 (:p (cmslink "create-allocation-area" "Create new allocation area"))))) 29 29 30 (defmethod handle-object-form ((handler allocation-area-handler) action allocation-area req)31 (with-bos-cms-page ( req:title "Allocation Area")30 (defmethod handle-object-form ((handler allocation-area-handler) action allocation-area) 31 (with-bos-cms-page (:title "Allocation Area") 32 32 (with-slots (active-p left top width height) allocation-area 33 33 (html … … 76 76 ((:img :width "90" :height "90" :border "0" :src #?"/overview/$(tile-x)/$(tile-y)")))))))))))))) 77 77 78 (defmethod handle-object-form ((handler allocation-area-handler) (action (eql :delete)) allocation-area req)78 (defmethod handle-object-form ((handler allocation-area-handler) (action (eql :delete)) allocation-area) 79 79 (delete-object allocation-area) 80 (with-bos-cms-page ( req:title "Allocation area has been deleted")80 (with-bos-cms-page (:title "Allocation area has been deleted") 81 81 (:h2 "The allocation area has been deleted"))) 82 82 … … 84 84 ()) 85 85 86 (defmethod handle-object ((handler allocation-area-gfx-handler) allocation-area req)86 (defmethod handle-object ((handler allocation-area-gfx-handler) allocation-area) 87 87 (cl-gd:with-image* ((allocation-area-width allocation-area) 88 88 (allocation-area-height allocation-area) t) … … 129 129 ()) 130 130 131 (defmethod handle-form ((handler create-allocation-area-handler) action req)132 (with-query-params ( reqx y left top)131 (defmethod handle-form ((handler create-allocation-area-handler) action) 132 (with-query-params (x y left top) 133 133 (cond 134 134 ((and x y left top) … … 137 137 (<= x left) 138 138 (<= y top)) 139 (with-bos-cms-page ( req:title "Invalid area selected")139 (with-bos-cms-page (:title "Invalid area selected") 140 140 (:h2 "Choose upper left corner first, then lower-right corner")) 141 141 (redirect (format nil "/allocation-area/~D" (store-object-id 142 (make-allocation-rectangle left top (- x left) (- y top)))) 143 req)))) 142 (make-allocation-rectangle left top (- x left) (- y top)))))))) 144 143 ((and x y) 145 144 (redirect (format nil "/map-browser/~A/~A?heading=~A&chosen-url=~A&" … … 147 146 (uriencode-string "Choose lower right point of allocation area") 148 147 (uriencode-string (format nil "~A?left=~A&top=~A&" 149 (uri-path (request-uri req)) 150 x y))) 151 req)) 148 (uri-path (hunchentoot:request-uri)) 149 x y))))) 152 150 (t 153 (with-bos-cms-page ( req:title "Create allocation area")151 (with-bos-cms-page (:title "Create allocation area") 154 152 ((:form :method "POST" :enctype "multipart/form-data")) 155 153 ((:table :border "0") … … 164 162 (:tr (:td (submit-button "rectangle" "rectangle"))))))))) 165 163 166 (defmethod handle-form ((handler create-allocation-area-handler) (action (eql :rectangle)) req)167 (with-query-params ( reqstart-x start-y)164 (defmethod handle-form ((handler create-allocation-area-handler) (action (eql :rectangle))) 165 (with-query-params (start-x start-y) 168 166 (redirect (format nil "/map-browser/~A/~A?heading=~A&chosen-url=~A&" 169 167 start-x start-y 170 168 (uriencode-string "Choose upper left point of allocation area") 171 (uriencode-string (format nil "~A?" (uri-path (request-uri req))))) 172 req))) 173 174 (defmethod handle-form ((handler create-allocation-area-handler) (action (eql :upload)) req) 175 (let ((uploaded-text-file (cdr (find "text-file" (request-uploaded-files req) :test #'equal :key #'car)))) 169 (uriencode-string (format nil "~A?" (uri-path (hunchentoot:request-uri)))))))) 170 171 (defmethod handle-form ((handler create-allocation-area-handler) (action (eql :upload))) 172 (let ((uploaded-text-file (cdr (find "text-file" (request-uploaded-files) :test #'equal :key #'car)))) 176 173 (cond 177 174 ((not uploaded-text-file) 178 (with-bos-cms-page ( req:title "No Text file uploaded")175 (with-bos-cms-page (:title "No Text file uploaded") 179 176 (:h2 "File not uploaded") 180 177 (:p "Please upload your text file containing the allocation polygon UTM coordinates"))) 181 178 (t 182 (with-bos-cms-page ( req:title #?"Importing allocation polygons from text file $(uploaded-text-file)")179 (with-bos-cms-page (:title #?"Importing allocation polygons from text file $(uploaded-text-file)") 183 180 (handler-case 184 181 (let* ((vertices (polygon-from-text-file uploaded-text-file)) branches/trunk-reorg/projects/bos/web/allocation-cache-handlers.lisp
r2383 r2479 6 6 ()) 7 7 8 (defmethod handle ((handler allocation-cache-handler) req)9 (with-bos-cms-page ( req:title "Allocation Cache")8 (defmethod handle ((handler allocation-cache-handler)) 9 (with-bos-cms-page (:title "Allocation Cache") 10 10 (html 11 11 (:pre (:princ branches/trunk-reorg/projects/bos/web/boi-handlers.lisp
r2400 r2479 7 7 ()) 8 8 9 (defmethod authorized-p ((handler boi-handler) req)10 (bos.m2:editor-p (bknr-request-user req)))9 (defmethod authorized-p ((handler boi-handler)) 10 (bos.m2:editor-p bknr.web:*user*)) 11 11 12 12 (defclass create-contract-handler (boi-handler) … … 21 21 sponsor)) 22 22 23 (defmethod handle ((handler create-contract-handler) req)24 (with-xml-error-handler ( req)25 (with-query-params ( reqnum-sqm country sponsor-id name paid expires)23 (defmethod handle ((handler create-contract-handler)) 24 (with-xml-error-handler () 25 (with-query-params (num-sqm country sponsor-id name paid expires) 26 26 (setf num-sqm (ignore-errors (parse-integer num-sqm :junk-allowed t))) 27 27 (unless num-sqm … … 54 54 ()) 55 55 56 (defmethod handle ((handler pay-contract-handler) req)57 (with-xml-error-handler ( req)58 (with-query-params ( reqcontract-id name)56 (defmethod handle ((handler pay-contract-handler)) 57 (with-xml-error-handler () 58 (with-query-params (contract-id name) 59 59 (unless contract-id 60 60 (error "missing contract-id parameter")) … … 66 66 (contract-set-paidp contract (format nil "~A: manually set paid by ~A" 67 67 (format-date-time) 68 (user-login (bknr-request-user req))))68 (user-login bknr.web:*user*))) 69 69 (when name 70 70 (setf (user-full-name (contract-sponsor contract)) name)))) … … 78 78 ()) 79 79 80 (defmethod handle ((handler cancel-contract-handler) req)81 (with-xml-error-handler ( req)82 (with-query-params ( reqcontract-id)80 (defmethod handle ((handler cancel-contract-handler)) 81 (with-xml-error-handler () 82 (with-query-params (contract-id) 83 83 (unless contract-id 84 84 (error "missing contract-id parameter")) branches/trunk-reorg/projects/bos/web/bos.web.asd
r2473 r2479 17 17 :long-description "" 18 18 19 :depends-on (:bknr-web :bknr-modules :bos.m2 :cxml )19 :depends-on (:bknr-web :bknr-modules :bos.m2 :cxml :acl-compat) 20 20 21 21 :components ((:file "packages") branches/trunk-reorg/projects/bos/web/contract-handlers.lisp
r2343 r2479 10 10 (defparameter *show-m2s* 5) 11 11 12 (defmethod handle-object ((handler contract-handler) contract req)13 (with-bos-cms-page ( req:title "Displaying contract details")12 (defmethod handle-object ((handler contract-handler) contract) 13 (with-bos-cms-page (:title "Displaying contract details") 14 14 ((:table :border "0") 15 15 (:tr (:td "sponsor") branches/trunk-reorg/projects/bos/web/contract-image-handler.lisp
r2343 r2479 18 18 ;; a whole for performance reasons. The FFI is way too slow to manipulate individual pixels. 19 19 (let ((work-array (make-array (list width height) :element-type 'fixnum :initial-element 0)) 20 (color (parse-color (or (second (decoded-handler-path handler req)) "ffff00"))))20 (color (parse-color (or (second (decoded-handler-path handler)) "ffff00")))) 21 21 (flet ((set-pixel (x y) 22 22 (decf x left) branches/trunk-reorg/projects/bos/web/kml-handlers.lisp
r2425 r2479 41 41 ()) 42 42 43 (defmethod handle-object ((handler contract-kml-handler) (contract contract) req)43 (defmethod handle-object ((handler contract-kml-handler) (contract contract)) 44 44 (with-xml-response (:content-type "application/vnd.google-earth.kml+xml" :root-element "kml") 45 45 ;; when name is xmlns, the attribute does not show up - why (?) … … 78 78 (text (kml-format-points (list (contract-center-lon-lat c))))))))))))) 79 79 80 (defmethod handle-object ((handle-object contract-kml-handler) (object null) req)80 (defmethod handle-object ((handle-object contract-kml-handler) (object null)) 81 81 (error "Contract not found.")) branches/trunk-reorg/projects/bos/web/languages-handler.lisp
r2343 r2479 6 6 ()) 7 7 8 (defmethod handle-form ((handler languages-handler) action req)9 (with-bos-cms-page ( req:title "Languages")8 (defmethod handle-form ((handler languages-handler) action) 9 (with-bos-cms-page (:title "Languages") 10 10 (case action 11 11 (:add (handler-case 12 (with-query-params ( reqcode name)12 (with-query-params (code name) 13 13 (when (and code name) 14 14 (make-object 'website-language :code code :name name) … … 18 18 (:pre (:princ-safe e)))))) 19 19 (:delete (handler-case 20 (with-query-params ( reqdelete-code)20 (with-query-params (delete-code) 21 21 (when delete-code 22 22 (delete-object (language-with-code delete-code)) branches/trunk-reorg/projects/bos/web/map-browser-handler.lisp
r2343 r2479 19 19 ()) 20 20 21 (defun decode-coords-in-handler-path (handler req)21 (defun decode-coords-in-handler-path (handler) 22 22 (labels ((ensure-valid-coordinates (x y) 23 23 (setq x (parse-integer x)) … … 31 31 (error "invalid coordinates ~A/~A" x y)) 32 32 (list x y))) 33 (with-query-params ( reqxcoord ycoord)33 (with-query-params (xcoord ycoord) 34 34 (when (and xcoord ycoord) 35 35 (return-from decode-coords-in-handler-path (ensure-valid-coordinates xcoord ycoord)))) 36 (let ((handler-arguments (decoded-handler-path handler req)))36 (let ((handler-arguments (decoded-handler-path handler))) 37 37 (when (and handler-arguments 38 38 (< 1 (length handler-arguments))) 39 39 (apply #'ensure-valid-coordinates handler-arguments))))) 40 40 41 (defmethod handle ((handler map-browser-handler) req)42 (with-query-params ( reqchosen-url)41 (defmethod handle ((handler map-browser-handler)) 42 (with-query-params (chosen-url) 43 43 (when chosen-url 44 44 (setf (session-variable :chosen-url) chosen-url))) 45 (with-query-params ( reqview-x view-y)46 (destructuring-bind (&optional click-x click-y) (decode-ismap-query-string req)47 (destructuring-bind (&optional point-x point-y) (decode-coords-in-handler-path handler req)48 (with-query-params ( reqaction)45 (with-query-params (view-x view-y) 46 (destructuring-bind (&optional click-x click-y) (decode-ismap-query-string) 47 (destructuring-bind (&optional point-x point-y) (decode-coords-in-handler-path handler) 48 (with-query-params (action) 49 49 (when (equal action "save") 50 50 (if (session-variable :chosen-url) … … 52 52 (session-variable :chosen-url) 53 53 point-x 54 point-y) 55 req) 56 (with-bos-cms-page (req :title "Map Point Chooser") 54 point-y)) 55 (with-bos-cms-page (:title "Map Point Chooser") 57 56 (html (:princ-safe "You chose " point-x " / " point-y)))) 58 57 (return-from handle t))) … … 72 71 (setq point-x click-coord-x 73 72 point-y click-coord-y) 74 (redirect (format nil "/map-browser/~D/~D" click-coord-x click-coord-y) req)73 (redirect (format nil "/map-browser/~D/~D" click-coord-x click-coord-y)) 75 74 (return-from handle t))) 76 75 (cond 77 76 ((and click-y (not point-y)) 78 (redirect (format nil "/map-browser/~D/~D" (* 30 click-x) (* 30 click-y)) req))77 (redirect (format nil "/map-browser/~D/~D" (* 30 click-x) (* 30 click-y)))) 79 78 (point-y 80 (with-bos-cms-page ( req:title "Map Point Chooser")81 (with-query-params ( reqheading)79 (with-bos-cms-page (:title "Map Point Chooser") 80 (with-query-params (heading) 82 81 (when heading 83 82 (html (:h2 (:princ-safe heading))))) … … 134 133 (map-navigator req point-x point-y "/map-browser/" :formcheck "return updateCoords();"))) 135 134 (t 136 (with-bos-cms-page ( req:title "Map Point Chooser")135 (with-bos-cms-page (:title "Map Point Chooser") 137 136 (html 138 137 ((:a :href "/map-browser/") branches/trunk-reorg/projects/bos/web/map-handlers.lisp
r2343 r2479 35 35 (:tr ))) 36 36 (:td 37 (with-query-params ( reqbackground areas contracts)37 (with-query-params (background areas contracts) 38 38 ;; xxx should use tile-layers 39 39 (unless (or background areas contracts) … … 53 53 ()) 54 54 55 (defmethod object-handler-get-object ((handler image-tile-handler) req)56 (destructuring-bind (x y &rest operations) (decoded-handler-path handler req)55 (defmethod object-handler-get-object ((handler image-tile-handler)) 56 (destructuring-bind (x y &rest operations) (decoded-handler-path handler) 57 57 (declare (ignore operations)) 58 58 (setf x (parse-integer x)) … … 60 60 (ensure-map-tile x y))) 61 61 62 (defmethod handle-object ((handler image-tile-handler) (tile (eql nil)) req)63 (error-404 req))62 (defmethod handle-object ((handler image-tile-handler) (tile (eql nil))) 63 (error-404)) 64 64 65 65 (defun parse-operations (&rest operation-strings) … … 69 69 operation-strings)) 70 70 71 (defmethod handle-object ((handler image-tile-handler) tile req) 72 ;; xxx parse url another time - the parse result of 73 ;; object-handler-get-object should really be kept in the request 74 (destructuring-bind (x y &rest operation-strings) (decoded-handler-path handler req) 75 (declare (ignore x y)) 76 (let ((changed-time (image-tile-changed-time tile)) 77 (ims (header-slot-value req :if-modified-since))) 78 (setf (net.aserve::last-modified *ent*) changed-time) 79 #+(or) 80 (format t "; image-tile-handler handle-object: changed-time: ~A if-modified-since: ~A~%" (format-date-time changed-time) ims) 81 (if (or (not ims) 82 (> changed-time (date-to-universal-time ims))) 83 (let ((image (image-tile-image tile (apply #'parse-operations operation-strings)))) 84 (emit-image-to-browser req image :png 85 :date changed-time 86 :max-age 60) 87 (cl-gd:destroy-image image)) 88 (with-http-response (req *ent*) 89 (with-http-body (req *ent*) 90 ; do nothing 91 )))))) 71 ;; trunk-reorg adaption 72 ;; (defmethod handle-object ((handler image-tile-handler) tile) 73 ;; ;; xxx parse url another time - the parse result of 74 ;; ;; object-handler-get-object should really be kept in the request 75 ;; (destructuring-bind (x y &rest operation-strings) (decoded-handler-path handler) 76 ;; (declare (ignore x y)) 77 ;; (let ((changed-time (image-tile-changed-time tile)) 78 ;; (ims (header-slot-value req :if-modified-since))) 79 ;; (format t "Warning: not setting last-modified of *ent* to changed-time") 80 ;; #+(or) 81 ;; (format t "; image-tile-handler handle-object: changed-time: ~A if-modified-since: ~A~%" (format-date-time changed-time) ims) 82 ;; (if (or (not ims) 83 ;; (> changed-time (date-to-universal-time ims))) 84 ;; (let ((image (image-tile-image tile (apply #'parse-operations operation-strings)))) 85 ;; (emit-image-to-browser req image :png 86 ;; :date changed-time 87 ;; :max-age 60) 88 ;; (cl-gd:destroy-image image)) 89 ;; (with-http-response (*ent*) 90 ;; (with-http-body () 91 ;; ; do nothing 92 ;; )))))) 92 93 93 94 (defclass enlarge-tile-handler (image-tile-handler) 94 95 ()) 95 96 96 (defun tile-active-layers-from-request-params (tile req)97 (defun tile-active-layers-from-request-params (tile) 97 98 (let (active-layers 98 99 (all-layer-names (mapcar #'symbol-name (image-tile-layers tile)))) … … 102 103 (or (reverse active-layers) all-layer-names))) 103 104 104 (defun tile-url (tile x y req)105 (defun tile-url (tile x y) 105 106 (format nil "/overview/~D/~D~(~{/~A~}~)" 106 107 x y 107 (tile-active-layers-from-request-params tile req)))108 (tile-active-layers-from-request-params tile))) 108 109 109 (defmethod handle-object ((handler enlarge-tile-handler) tile req) 110 (let ((ismap-coords (decode-ismap-query-string req)) 111 (tile-x (tile-nw-x tile)) 112 (tile-y (tile-nw-y tile))) 113 (if ismap-coords 114 (let* ((x (+ (floor (first ismap-coords) 4) tile-x)) 115 (y (+ (floor (second ismap-coords) 4) tile-y)) 116 (m2 (get-m2 x y)) 117 (contract-id (and m2 (m2-contract m2) (store-object-id (m2-contract m2))))) 118 (if contract-id 119 (redirect #?"/contract/$(contract-id)" req) 120 (with-bos-cms-page (req :title "Not sold") 121 (html (:h2 "this square meter has not been sold yet"))))) 122 (with-bos-cms-page (req :title "Browsing tile") 123 (:a ((:a :href (uri-path (request-uri req))) 124 ((:img :width "360" :ismap "ismap" :height "360" :border "0" :src (tile-url tile tile-x tile-y req))))) 125 (map-navigator req tile-x tile-y "/enlarge-overview/"))))) 110 ;; trunk-reorg adaption 111 ;; (defmethod handle-object ((handler enlarge-tile-handler) tile) 112 ;; (let ((ismap-coords (decode-ismap-query-string req)) 113 ;; (tile-x (tile-nw-x tile)) 114 ;; (tile-y (tile-nw-y tile))) 115 ;; (if ismap-coords 116 ;; (let* ((x (+ (floor (first ismap-coords) 4) tile-x)) 117 ;; (y (+ (floor (second ismap-coords) 4) tile-y)) 118 ;; (m2 (get-m2 x y)) 119 ;; (contract-id (and m2 (m2-contract m2) (store-object-id (m2-contract m2))))) 120 ;; (if contract-id 121 ;; (redirect #?"/contract/$(contract-id)") 122 ;; (with-bos-cms-page (:title "Not sold") 123 ;; (html (:h2 "this square meter has not been sold yet"))))) 124 ;; (with-bos-cms-page (:title "Browsing tile") 125 ;; (:a ((:a :href (uri-path (hunchentoot:request-uri))) 126 ;; ((:img :width "360" :ismap "ismap" :height "360" :border "0" :src (tile-url tile tile-x tile-y req))))) 127 ;; (map-navigator req tile-x tile-y "/enlarge-overview/"))))) 128 branches/trunk-reorg/projects/bos/web/news-handlers.lisp
r2411 r2479 10 10 ()) 11 11 12 (defmethod handle-object-form ((handler edit-news-handler) action (news-item (eql nil)) req)12 (defmethod handle-object-form ((handler edit-news-handler) action (news-item (eql nil))) 13 13 (let ((language (session-variable :language))) 14 (with-bos-cms-page ( req:title "Edit news items")15 (content-language-chooser req)14 (with-bos-cms-page (:title "Edit news items") 15 (content-language-chooser) 16 16 (:h2 "Create new item") 17 17 ((:form :method "post") … … 30 30 (:h2 "No news items created yet")))))) 31 31 32 (defmethod handle-object-form ((handler edit-news-handler) (action (eql :new)) (news-item (eql nil)) req)33 (redirect (format nil "/edit-news/~D" (store-object-id (make-news-item))) req))32 (defmethod handle-object-form ((handler edit-news-handler) (action (eql :new)) (news-item (eql nil))) 33 (redirect (format nil "/edit-news/~D" (store-object-id (make-news-item))))) 34 34 35 (defmethod handle-object-form ((handler edit-news-handler) action news-item req)35 (defmethod handle-object-form ((handler edit-news-handler) action news-item) 36 36 (let ((language (session-variable :language))) 37 (with-bos-cms-page ( req:title "Edit news item")38 (content-language-chooser req)37 (with-bos-cms-page (:title "Edit news item") 38 (content-language-chooser) 39 39 ((:script :type "text/javascript") 40 40 "tinyMCE.init({ mode : 'textareas', theme : 'advanced' });") … … 49 49 (:tr (:td (submit-button "save" "save") (submit-button "delete" "delete" :confirm "Really delete the news item?")))))))) 50 50 51 (defmethod handle-object-form ((handler edit-news-handler) (action (eql :save)) news-item req)51 (defmethod handle-object-form ((handler edit-news-handler) (action (eql :save)) news-item) 52 52 (let ((language (session-variable :language))) 53 (with-query-params ( reqtitle text)53 (with-query-params (title text) 54 54 (update-news-item news-item language :title title :text text) 55 (with-bos-cms-page ( req:title "News item updated")55 (with-bos-cms-page (:title "News item updated") 56 56 (:h2 "Your changes have been saved") 57 57 "You may " (cmslink (edit-object-url news-item) "continue editing the news item"))))) 58 58 59 (defmethod handle-object-form ((handler edit-news-handler) (action (eql :delete)) news-item req)59 (defmethod handle-object-form ((handler edit-news-handler) (action (eql :delete)) news-item) 60 60 (delete-object news-item) 61 (with-bos-cms-page ( req:title "News item has been deleted")61 (with-bos-cms-page (:title "News item has been deleted") 62 62 (:h2 "The news item has been deleted"))) branches/trunk-reorg/projects/bos/web/packages.lisp
r2345 r2479 9 9 :cl-interpol 10 10 :cl-ppcre 11 :net.aserve12 :net.aserve.client13 11 :xhtml-generator 14 12 :cxml … … 28 26 (:nicknames :web :worldpay-test) 29 27 (:shadowing-import-from :cl-interpol #:quote-meta-chars) 30 (:shadowing-import-from :acl-compat.mp #:process-kill #:process-wait) 31 (:import-from :net.html.generator #:*html-stream*) 28 (:shadowing-import-from :acl-compat.mp #:process-kill #:process-wait) 32 29 (:export)) branches/trunk-reorg/projects/bos/web/poi-handlers.lisp
r2343 r2479 7 7 ()) 8 8 9 (defmethod handle ((handler make-poi-handler) req)10 (with-query-params ( reqname)9 (defmethod handle ((handler make-poi-handler)) 10 (with-query-params (name) 11 11 (cond 12 12 ((find-store-object name :class 'poi) 13 (with-bos-cms-page ( req:title "Duplicate POI name")13 (with-bos-cms-page (:title "Duplicate POI name") 14 14 (html (:h2 "Duplicate POI name") 15 15 "A POI with that name exists already, please choose a unique name"))) 16 16 ((not (scan #?r"(?i)^[a-z][-a-z0-9_]+$" name)) 17 (with-bos-cms-page ( req:title "Bad technical name")17 (with-bos-cms-page (:title "Bad technical name") 18 18 (html (:h2 "Bad technical name") 19 19 "Please use only alphanumerical characters, - and _ for technical POI names"))) 20 20 (t 21 (redirect (edit-object-url (make-poi (session-variable :language) name)) req)))))21 (redirect (edit-object-url (make-poi (session-variable :language) name))))))) 22 22 23 23 (defclass edit-poi-handler (editor-only-handler edit-object-handler) … … 25 25 (:default-initargs :object-class 'poi :query-function #'find-poi)) 26 26 27 (defmethod handle-object-form ((handler edit-poi-handler) action (object (eql nil)) req)28 (with-bos-cms-page ( req:title "Choose POI")27 (defmethod handle-object-form ((handler edit-poi-handler) action (object (eql nil))) 28 (with-bos-cms-page (:title "Choose POI") 29 29 (if (store-objects-with-class 'poi) 30 30 (html … … 51 51 52 52 (defmethod handle-object-form ((handler edit-poi-handler) 53 action (poi poi) req)54 (with-query-params ( reqlanguage shift shift-by)53 action (poi poi)) 54 (with-query-params (language shift shift-by) 55 55 (unless language (setq language (session-variable :language))) 56 56 (when shift … … 67 67 (change-slot-values poi 'bos.m2::images new-images))) 68 68 (setf (session-variable :language) language) 69 (with-bos-cms-page ( req:title "Edit POI")70 (content-language-chooser req)69 (with-bos-cms-page (:title "Edit POI") 70 (content-language-chooser) 71 71 (unless (poi-complete poi language) 72 72 (html (:h2 "This POI is not complete in the current language - Please check that " … … 96 96 (cmslink (format nil "map-browser/~A/~A?chosen-url=~A" 97 97 (first (poi-area poi)) (second (poi-area poi)) 98 (uriencode-string (format nil "~A?action=save&" (uri-path ( request-uri req)))))98 (uriencode-string (format nil "~A?action=save&" (uri-path (hunchentoot:request-uri))))) 99 99 "[relocate]")) 100 100 (t 101 101 (cmslink (format nil "map-browser/?chosen-url=~A" 102 (uriencode-string (format nil "~A?action=save&" (uri-path ( request-uri req)))))102 (uriencode-string (format nil "~A?action=save&" (uri-path (hunchentoot:request-uri))))) 103 103 "[choose]"))))) 104 104 (:tr (:td "icon") … … 168 168 169 169 (defmethod handle-object-form ((handler edit-poi-handler) 170 (action (eql :save)) (poi poi) req)171 (with-query-params ( reqpublished title subtitle description language x y icon movie)170 (action (eql :save)) (poi poi)) 171 (with-query-params (published title subtitle description language x y icon movie) 172 172 (unless language (setq language (session-variable :language))) 173 173 (let ((args (list :title title … … 181 181 (setq args (append args (list :movies (list movie))))) 182 182 (apply #'update-poi poi language args)) 183 (with-bos-cms-page ( req:title "POI has been updated")183 (with-bos-cms-page (:title "POI has been updated") 184 184 (html (:h2 "Your changes have been saved") 185 185 "You may " (cmslink (edit-object-url poi) "continue editing the POI") ".")))) … … 187 187 (defmethod handle-object-form ((handler edit-poi-handler) 188 188 (action (eql :upload-airal)) 189 (poi poi) 190 req) 191 (let ((uploaded-file (cdr (find "image-file" (request-uploaded-files req) :test #'equal :key #'car)))) 189 (poi poi)) 190 (let ((uploaded-file (cdr (find "image-file" (request-uploaded-files) :test #'equal :key #'car)))) 192 191 (unless uploaded-file 193 192 (error "no file uploaded in upload handler")) … … 195 194 (unless (and (eql (cl-gd:image-width) *poi-image-width*) 196 195 (eql (cl-gd:image-height) *poi-image-height*)) 197 (with-bos-cms-page ( req:title "Invalid image size")196 (with-bos-cms-page (:title "Invalid image size") 198 197 (:h2 "Invalid image size") 199 198 (:p "The image needs to be " … … 208 207 :class-name 'store-image)))) 209 208 (redirect (format nil "/edit-poi/~D" 210 (store-object-id poi)) req))209 (store-object-id poi)))) 211 210 212 211 (defmethod handle-object-form ((handler edit-poi-handler) 213 212 (action (eql :delete-airal)) 214 (poi poi) 215 req) 213 (poi poi)) 216 214 (let ((airals (poi-airals poi))) 217 215 (change-slot-values poi 'airals nil) 218 216 (mapc #'delete-object airals)) 219 217 (redirect (format nil "/edit-poi/~D" 220 (store-object-id poi)) req))218 (store-object-id poi)))) 221 219 222 220 (defmethod handle-object-form ((handler edit-poi-handler) 223 221 (action (eql :delete-movie)) 224 (poi poi) 225 req) 222 (poi poi)) 226 223 (change-slot-values poi 'movies nil) 227 (redirect (format nil "/edit-poi/~D" (store-object-id poi)) req))224 (redirect (format nil "/edit-poi/~D" (store-object-id poi)))) 228 225 229 226 (defmethod handle-object-form ((handler edit-poi-handler) 230 227 (action (eql :upload-panorama)) 231 (poi poi) 232 req) 233 (let ((uploaded-file (cdr (find "image-file" (request-uploaded-files req) :test #'equal :key #'car)))) 228 (poi poi)) 229 (let ((uploaded-file (cdr (find "image-file" (request-uploaded-files) :test #'equal :key #'car)))) 234 230 (unless uploaded-file 235 231 (error "no file uploaded in upload handler")) … … 241 237 (poi-panoramas poi)))) 242 238 (redirect (format nil "/edit-poi/~D" 243 (store-object-id poi)) req))239 (store-object-id poi)))) 244 240 245 241 (defmethod handle-object-form ((handler edit-poi-handler) 246 242 (action (eql :delete-panorama)) 247 (poi poi) 248 req) 249 (with-query-params (req panorama-id) 243 (poi poi)) 244 (with-query-params (panorama-id) 250 245 (let ((panorama (find-store-object (parse-integer panorama-id)))) 251 246 (change-slot-values poi 'panoramas (remove panorama (poi-panoramas poi))) 252 247 (mapc #'delete-object panorama))) 253 248 (redirect (format nil "/edit-poi/~D" 254 (store-object-id poi)) req))255 256 (defmethod handle-object-form ((handler edit-poi-handler) 257 (action (eql :delete)) (poi poi) req)249 (store-object-id poi)))) 250 251 (defmethod handle-object-form ((handler edit-poi-handler) 252 (action (eql :delete)) (poi poi)) 258 253 (delete-object poi) 259 (with-bos-cms-page ( req:title "POI has been deleted")254 (with-bos-cms-page (:title "POI has been deleted") 260 255 (html (:h2 "POI has been deleted") 261 256 "The POI has been deleted"))) … … 267 262 (:default-initargs :object-class 'poi-image)) 268 263 269 (defmethod handle-object-form ((handler edit-poi-image-handler) action (object (eql nil)) req)270 (with-query-params ( reqpoi)271 (with-bos-cms-page ( req:title "Upload new POI image")264 (defmethod handle-object-form ((handler edit-poi-image-handler) action (object (eql nil))) 265 (with-query-params (poi) 266 (with-bos-cms-page (:title "Upload new POI image") 272 267 (html 273 268 (:h2 "Upload new image") … … 277 272 (:p (submit-button "upload" "upload")))))) 278 273 279 (defmethod handle-object-form ((handler edit-poi-image-handler) (action (eql :upload)) poi-image req)280 (with-query-params ( reqpoi)274 (defmethod handle-object-form ((handler edit-poi-image-handler) (action (eql :upload)) poi-image) 275 (with-query-params (poi) 281 276 (setq poi (find-store-object (parse-integer poi) :class 'poi)) 282 (let ((uploaded-file (cdr (find "image-file" (request-uploaded-files req) :test #'equal :key #'car))))277 (let ((uploaded-file (cdr (find "image-file" (request-uploaded-files) :test #'equal :key #'car)))) 283 278 (unless uploaded-file 284 279 (error "no file uploaded in upload handler")) … … 286 281 (unless (and (eql (cl-gd:image-width) *poi-image-width*) 287 282 (eql (cl-gd:image-height) *poi-image-height*)) 288 (with-bos-cms-page ( req:title "Invalid image size")283 (with-bos-cms-page (:title "Invalid image size") 289 284 (:h2 "Invalid image size") 290 285 (:p "The image needs to be " … … 303 298 (redirect (format nil "/edit-poi-image/~D?poi=~D" 304 299 (store-object-id poi-image) 305 (store-object-id poi)) req))))306 307 (defmethod handle-object-form ((handler edit-poi-image-handler) action poi-image req)308 (with-query-params ( reqlanguage poi)300 (store-object-id poi)))))) 301 302 (defmethod handle-object-form ((handler edit-poi-image-handler) action poi-image) 303 (with-query-params (language poi) 309 304 (unless language (setq language (session-variable :language))) 310 (with-bos-cms-page ( req:title "Edit POI Image")305
