Changeset 3294
- Timestamp:
- 06/18/08 17:46:36 (7 months ago)
- Files:
-
- trunk/projects/bos/payment-website/templates/da/dictionary.xml (modified) (1 diff)
- trunk/projects/bos/payment-website/templates/de/dictionary.xml (modified) (1 diff)
- trunk/projects/bos/payment-website/templates/en/dictionary.xml (modified) (1 diff)
- trunk/projects/bos/web/bos.web.asd (modified) (1 diff)
- trunk/projects/bos/web/contract-tree.lisp (modified) (1 diff)
- trunk/projects/bos/web/image-tree.lisp (modified) (3 diffs)
- trunk/projects/bos/web/kml-handlers.lisp (modified) (5 diffs)
- trunk/projects/bos/web/poi-handlers.lisp (modified) (1 diff)
- trunk/projects/bos/web/sat-tree.lisp (modified) (2 diffs)
- trunk/projects/bos/web/web-macros.lisp (modified) (1 diff)
- trunk/projects/bos/web/web-utils.lisp (modified) (1 diff)
- trunk/projects/bos/web/webserver.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/payment-website/templates/da/dictionary.xml
r3292 r3294 2 2 <dictionary> 3 3 <!-- in /usr/home/paul/src/bknr-svn/projects/bos/web/poi-handlers.lisp --> 4 <entry> 5 <key> 6 Machen Sie mit! 7 </key> 8 <value> 9 </value> 10 </entry> 4 <entry><key>Join in!</key><value></value></entry> 11 5 <!-- in /usr/home/paul/src/bknr-svn/projects/bos/web/poi-handlers.lisp --> 12 <entry> 13 <key> 14 learn more 15 </key> 16 <value> 17 </value> 18 </entry> 6 <entry><key>learn more</key><value></value></entry> 7 8 <!-- kml-root --> 9 <entry><key>Squaremetre Area</key><value></value></entry> 10 <entry><key>sat-2007</key><value>Satellitenbild von 2007</value></entry> 11 <entry><key>POIs</key><value>Points of Interest</value></entry> 19 12 13 20 14 <!-- --> 21 15 <!-- country names --> trunk/projects/bos/payment-website/templates/de/dictionary.xml
r3292 r3294 2 2 <dictionary> 3 3 <!-- in /usr/home/paul/src/bknr-svn/projects/bos/web/poi-handlers.lisp --> 4 <entry><key> Machen Sie mit!</key><value>Machen Sie mit!</value></entry>4 <entry><key>Join in!</key><value>Machen Sie mit!</value></entry> 5 5 <!-- in /usr/home/paul/src/bknr-svn/projects/bos/web/poi-handlers.lisp --> 6 6 <entry><key>learn more</key><value></value></entry> 7 7 <!-- in /home/paul/src/bknr-svn/projects/bos/web/kml-handlers.lisp --> 8 9 <!-- kml-root --> 10 <entry><key>Squaremetre Area</key><value>Quadratmetergebiet</value></entry> 11 <entry><key>sat-2007</key><value>Satellitenbild von 2007</value></entry> 12 <entry><key>POIs</key><value>Interessante Orte</value></entry> 13 14 <!-- GE contract balloon --> 15 <entry><key>Donor ID:</key><value>Sponsor-ID:</value></entry> 16 <entry><key>Name:</key><value>Name:</value></entry> 17 <entry><key>Country:</key><value>Land:</value></entry> 18 <entry><key>donated:</key><value>gesponsort:</value></entry> 19 <entry><key>since:</key><value>seit:</value></entry> 20 21 8 22 <entry><key>Country-Stats</key><value>LÀnderstatistik</value></entry> 9 23 <entry><key>BOS says thank you to all sponsors!</key> trunk/projects/bos/payment-website/templates/en/dictionary.xml
r3292 r3294 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <dictionary> 3 <!-- in /usr/home/paul/src/bknr-svn/projects/bos/web/poi-handlers.lisp --> 4 <entry> 5 <key> 6 Machen Sie mit! 7 </key> 8 <value> 9 </value> 10 </entry> 11 <!-- in /usr/home/paul/src/bknr-svn/projects/bos/web/poi-handlers.lisp --> 12 <entry> 13 <key> 14 learn more 15 </key> 16 <value> 17 </value> 18 </entry> 3 <entry><key>sat-2007</key><value>Satellite Image 2007</value></entry> 4 <entry><key>POIs</key><value>Points of Interest</value></entry> 19 5 <!-- --> 20 6 <!-- country names --> trunk/projects/bos/web/bos.web.asd
r3291 r3294 38 38 (:file "sat-tree" :depends-on ("quad-tree" "contract-tree")) 39 39 (:file "countries" :depends-on ("packages")) 40 (:file "kml-handlers" :depends-on ("packages" "web-macros" "countries" "dictionary")) 40 (:file "kml-handlers" :depends-on ("packages" 41 "web-macros" 42 "countries" 43 "dictionary")) 41 44 (:file "sponsor-handlers" :depends-on ("web-utils")) 42 45 (:file "news-handlers" :depends-on ("web-utils")) trunk/projects/bos/web/contract-tree.lisp
r3261 r3294 187 187 (if (and rmcpath 188 188 (= (car rmcpath) i)) 189 (format nil "http://~A/contract-tree-kml?path=~{~D~}~d&rmcid=~D&rmcpath=~{~D~} "190 (website-host) path i rmcid (cdr rmcpath) )191 (format nil "http://~A/contract-tree-kml?path=~{~D~}~D " (website-host) path i))189 (format nil "http://~A/contract-tree-kml?path=~{~D~}~d&rmcid=~D&rmcpath=~{~D~}&lang=~A" 190 (website-host) path i rmcid (cdr rmcpath) lang) 191 (format nil "http://~A/contract-tree-kml?path=~{~D~}~D&lang=~A" (website-host) path i lang)) 192 192 :rect (geo-box-rectangle (geo-box child)) 193 193 :lod (node-lod child))))))))))) trunk/projects/bos/web/image-tree.lisp
r3261 r3294 256 256 (format nil "~2,'0X~{~2,'0X~}" opacity (reverse color))) 257 257 258 (defmethod kml-link ((href string) &key (http-query "lang=[language]"))258 (defmethod kml-link ((href string) &key http-query) 259 259 (with-element "Link" 260 260 (with-element "href" (text href)) … … 268 268 ;; (kml-link string))) 269 269 270 (defun kml-network-link (href &key rect lod name (http-query "lang=[language]")) 270 (defun kml-network-link (href &key rect lod name http-query 271 fly-to-view) 271 272 (with-element "NetworkLink" 272 273 (when name (with-element "name" (text name))) 273 274 (when rect (kml-region rect lod)) 274 (kml-link href :http-query http-query))) 275 (when fly-to-view (with-element "flyToView" (text "1"))) 276 (kml-link href))) 275 277 276 278 (defun kml-lat-lon-box (rect &optional (element "LatLonBox")) … … 631 633 :rect (make-rectangle2 (list (geo-x child) (geo-y child) 632 634 (geo-width child) (geo-height child))) 633 :lod `(:min ,(lod-min child) :max ,(lod-max child)) 634 :http-query nil)))))) 635 :lod `(:min ,(lod-min child) :max ,(lod-max child)))))))) 635 636 636 637 (defclass image-tree-kml-latest-handler (page-handler) trunk/projects/bos/web/kml-handlers.lisp
r3291 r3294 18 18 (defun contract-description (contract language) 19 19 (let* ((sponsor (contract-sponsor contract)) 20 (name (user-full-name sponsor)) 21 (language (if (member language '("en" "de") :test #'equal) 22 language 23 "en"))) 24 (flet ((sponsor-id () 25 (cdr (assoc language '(("de" . "Sponsor-ID:") ("en" . "Donor ID:")) :test #'equal))) 26 (name () 27 (cdr (assoc language '(("de" . "Name:") ("en" . "Name:")) :test #'equal))) 28 (country () 29 (cdr (assoc language '(("de" . "Land:") ("en" . "Country:")) :test #'equal))) 30 (donated () 31 (cdr (assoc language '(("de" . "gesponsort:") ("en" . "donated:")) :test #'equal))) 32 (since () 33 (cdr (assoc language '(("de" . "seit:") ("en" . "since:")) :test #'equal)))) 20 (name (user-full-name sponsor))) 21 (flet ((donor-id () (dictionary-entry "Donor ID:" language)) 22 (name () (dictionary-entry "Name:" language)) 23 (country () (dictionary-entry "Country:" language)) 24 (donated () (dictionary-entry "donated:" language)) 25 (since () (dictionary-entry "since:" language))) 34 26 (with-xml-output (cxml:make-string-sink) 35 27 (with-element "div" 36 28 (with-element "table" 37 29 (with-element "tr" 38 (with-element "td" (text ( sponsor-id)))30 (with-element "td" (text (donor-id))) 39 31 (with-element "td" (text (princ-to-string (store-object-id sponsor))))) 40 32 (with-element "tr" … … 44 36 (with-element "td" (text (country))) 45 37 (with-element "td" 46 (text (sponsor-country sponsor)) 38 (text (dictionary-entry (second (assoc (make-keyword-from-string (sponsor-country sponsor)) 39 *country-english-names*)) language)) 47 40 (text " ") 48 41 (with-element "img" … … 77 70 (with-query-params ((lang "en")) 78 71 (with-element "Document" 79 (with-element "name" (text "bos-kml"))72 (with-element "name" (text (format nil "BOS [~A]" lang))) 80 73 (when contract 81 74 (with-element "Style" … … 100 93 :rect (make-rectangle2 (geo-location image-tree)) 101 94 :lod `(:min ,(lod-min image-tree) :max ,(lod-max image-tree)) 102 :name "old-image-tree" 103 :http-query nil)) 95 :name "old-image-tree")) 104 96 (dolist (sat-layer (class-instances 'sat-layer)) 105 97 (kml-network-link (format nil "http://~a/sat-root-kml?name=~A" (website-host) (name sat-layer)) 106 98 :rect (geo-box-rectangle *m2-geo-box*) 107 99 :lod '(:min 0 :max -1) 108 :name (princ-to-string (name sat-layer)) 109 :http-query nil)) 100 :name (dictionary-entry (princ-to-string (name sat-layer)) lang))) 110 101 (let ((href (if (not contract) 111 (format nil "http://~a/contract-tree-kml " (website-host))102 (format nil "http://~a/contract-tree-kml?lang=~A" (website-host) lang) 112 103 (let* ((node (find-contract-node *contract-tree* contract)) 113 104 (path (node-path node)) 114 105 (contract-id (store-object-id contract))) 115 (format nil "http://~a/contract-tree-kml?rmcid=~D&rmcpath=~{~D~} "116 (website-host) contract-id path )))))106 (format nil "http://~a/contract-tree-kml?rmcid=~D&rmcpath=~{~D~}&lang=~A" 107 (website-host) contract-id path lang))))) 117 108 (kml-network-link href 118 109 :rect (geo-box-rectangle (geo-box *contract-tree*)) 119 110 :lod (node-lod *contract-tree*) 120 :name "contracts"))121 (kml-network-link (format nil "http://~a/poi-kml-all " (website-host))122 :name "POIs"111 :name (dictionary-entry "Squaremetre Area" lang))) 112 (kml-network-link (format nil "http://~a/poi-kml-all?lang=~A" (website-host) lang) 113 :name (dictionary-entry "POIs" lang) 123 114 :rect (make-rectangle :x 0 :y 0 :width +width+ :height +width+) 124 115 :lod '(:min 0 :max -1)) 125 ;; Country-Stats 126 (with-element "Folder" 127 (with-element "name" (text "Country-Stats")) 128 (with-element "Style" 129 (attribute "id" "countryStatsStyle") 130 (with-element "IconStyle" 131 (with-element "Icon" 132 ;; (with-element "href" (text "http://maps.google.com/mapfiles/kml/pal3/icon23.png")) 133 (with-element "href" (text (format nil "http://~a/static/Orang_weiss.png" (website-host))))))) 134 (dolist (country-contracts (sort (group-on (all-contracts) 135 :test #'equal 136 :key (lambda (contract) 137 (string-upcase (sponsor-country (contract-sponsor contract))))) 138 #'> :key (lambda (entry) (length (cdr entry))))) 139 (let ((coords (cdr (assoc (make-keyword-from-string (car country-contracts)) *country-coords*)))) 140 (when coords 141 (destructuring-bind (lon lat) 142 coords 143 (let ((contracts (cdr country-contracts))) 144 (with-element "Placemark" 145 ;; (with-element "name" (text (format nil "~a ~a" (car country-contracts) (length (cdr country-contracts))))) 146 (with-element "styleUrl" (text "#countryStatsStyle")) 147 (with-element "description" 148 (text (format nil "<p>~d sponsors from ~a have supported the activities of 149 <a href='http://createrainforest.com/'>BOS</a>.</p> 150 <p>In total, they have contributed ~d m².</p><br>" 151 (length contracts) 152 (dictionary-entry 153 (second (assoc (make-keyword-from-string (car country-contracts)) *country-english-names*)) lang) 154 (reduce #'+ contracts :key #'contract-area)))) 155 (with-element "Point" 156 (with-element "coordinates" 157 (text (format nil "~,20F,~,20F,0" lat lon)))))))))))))))) 116 (kml-network-link (format nil "http://~a/country-stats?lang=~A" (website-host) lang) 117 :name (dictionary-entry "Country-Stats" lang))))))) 158 118 159 119 (defmethod handle-object ((handler kml-root-handler) (object sponsor)) … … 166 126 (write-root-kml handler nil)) 167 127 128 (defclass country-stats-handler (page-handler) 129 ()) 130 131 (defmethod handle ((handler country-stats-handler)) 132 (handle-every-n-seconds (1) 133 (with-xml-response (:content-type #+nil "text/xml" "application/vnd.google-earth.kml+xml; charset=utf-8" 134 :root-element "kml") 135 (with-query-params ((lang "en")) 136 (with-element "Document" 137 (with-element "name" (text "Country-Stats")) 138 (with-element "LookAt" 139 (with-element "longitude" (text "8.297592139883164")) 140 (with-element "latitude" (text "49.89989439494514")) 141 (with-element "altitude" (text "0")) 142 (with-element "range" (text "5400715.913126094")) 143 (with-element "tilt" (text "0")) 144 (with-element "heading" (text "0"))) 145 (with-element "Style" 146 (attribute "id" "countryStatsStyle") 147 (with-element "IconStyle" 148 (with-element "Icon" 149 ;; (with-element "href" (text "http://maps.google.com/mapfiles/kml/pal3/icon23.png")) 150 (with-element "href" (text (format nil "http://~a/static/Orang_weiss.png" (website-host))))))) 151 (dolist (country-contracts (sort (group-on (all-contracts) 152 :test #'equal 153 :key (lambda (contract) 154 (string-upcase (sponsor-country (contract-sponsor contract))))) 155 #'> :key (lambda (entry) (length (cdr entry))))) 156 (let ((coords (cdr (assoc (make-keyword-from-string (car country-contracts)) *country-coords*)))) 157 (when coords 158 (destructuring-bind (lon lat) 159 coords 160 (let* ((contracts (cdr country-contracts)) 161 (number-contracts (length contracts))) 162 (with-element "Placemark" 163 ;; (with-element "name" (text (format nil "~a ~a" (car country-contracts) (length (cdr country-contracts))))) 164 (with-element "styleUrl" (text "#countryStatsStyle")) 165 (with-element "description" 166 (text (format nil "<p>~A</p><table><tbody><tr><td>~A:</td><td>~D ~A</td></tr> 167 <tr><td>~A:</td><td>~D m²</td></tr></tbody></table>" 168 (dictionary-entry "BOS says thank you to all sponsors!" lang) 169 (dictionary-entry 170 (second (assoc (make-keyword-from-string (car country-contracts)) *country-english-names*)) lang) 171 number-contracts 172 (if (= 1 number-contracts) 173 (dictionary-entry "sponsor" lang) 174 (dictionary-entry "sponsors" lang)) 175 (dictionary-entry "total contribution" lang) 176 (reduce #'+ contracts :key #'contract-area)))) 177 (with-element "Point" 178 (with-element "coordinates" 179 (text (format nil "~,20F,~,20F,0" lat lon))))))))))))))) 180 181 182 trunk/projects/bos/web/poi-handlers.lisp
r3288 r3294 507 507 (with-element "p" (with-element "a" 508 508 (attribute "href" (website-path "/~a/bestellung" language)) 509 (text (dictionary-entry " Machen Sie mit!" language)))))509 (text (dictionary-entry "Join in!" language))))) 510 510 (t 511 511 (with-element "br") trunk/projects/bos/web/sat-tree.lisp
r3261 r3294 224 224 (website-host) (name layer) (append path (list i))) 225 225 :rect (geo-box-rectangle (geo-box child)) 226 :lod (node-lod child) 227 :http-query nil))))))))))))) 226 :lod (node-lod child)))))))))))))) 228 227 229 228 (defclass sat-root-kml-handler (page-handler) … … 247 246 (website-host) (name layer) (node-path node)) 248 247 :rect (geo-box-rectangle (geo-box node)) 249 :lod (node-lod node) 250 :http-query nil)))))))) 251 248 :lod (node-lod node))))))))) 249 trunk/projects/bos/web/web-macros.lisp
r2653 r3294 16 16 (text (princ-to-string e))))))) 17 17 18 (defmacro handle-every-n-seconds ((n-seconds) &body body) 19 (let ((=time= (gensym "TIME")) 20 (=timestamp= (gensym "TIMESTAMP"))) 21 `(let* ((,=time= (get-universal-time)) 22 (,=timestamp= (- ,=time= (mod ,=time= ,n-seconds)))) 23 (hunchentoot:handle-if-modified-since ,=timestamp=) 24 (setf (hunchentoot:header-out :last-modified) 25 (hunchentoot:rfc-1123-date ,=timestamp=)) 26 ,@body))) 18 27 trunk/projects/bos/web/web-utils.lisp
r3271 r3294 62 62 (mapcar #'parse-integer (split "," coord-string))))) 63 63 64 65 trunk/projects/bos/web/webserver.lisp
r3271 r3294 204 204 ("/image-tree-kml" image-tree-kml-handler) 205 205 ("/image-tree" image-tree-handler) 206 ("/country-stats" country-stats-handler) 206 207 ("/contract-tree-kml" contract-tree-kml-handler) 207 ("/contract-tree-image" contract-tree-image-handler) 208 ("/contract-tree-image" contract-tree-image-handler) 208 209 ("/contract-image" contract-image-handler) 209 210 ("/contract" contract-handler)
