[bknr-cvs] hans changed trunk/projects/bos/

BKNR Commits bknr at bknr.net
Fri Nov 28 01:07:18 UTC 2008


Revision: 4092
Author: hans
URL: http://bknr.net/trac/changeset/4092

Checkpoint new POI microsite work.

A   trunk/projects/bos/payment-website/static/movie-icon.gif
A   trunk/projects/bos/payment-website/static/panorama-icon.gif
U   trunk/projects/bos/payment-website/static/poi-ms.css
U   trunk/projects/bos/payment-website/static/poi-ms.html
U   trunk/projects/bos/payment-website/static/poi-ms.js
U   trunk/projects/bos/web/poi-handlers.lisp

Added: trunk/projects/bos/payment-website/static/movie-icon.gif
===================================================================
(Binary files differ)


Property changes on: trunk/projects/bos/payment-website/static/movie-icon.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: trunk/projects/bos/payment-website/static/panorama-icon.gif
===================================================================
(Binary files differ)


Property changes on: trunk/projects/bos/payment-website/static/panorama-icon.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/projects/bos/payment-website/static/poi-ms.css
===================================================================
--- trunk/projects/bos/payment-website/static/poi-ms.css	2008-11-27 14:15:14 UTC (rev 4091)
+++ trunk/projects/bos/payment-website/static/poi-ms.css	2008-11-28 01:07:18 UTC (rev 4092)
@@ -2,13 +2,13 @@
 h2 { font-size: 160% }
 h3 { font-size: 120% }
 
-ul.media-list li {
+ul#media-list li {
     position: relative;
     height: 44px;
     margin-left: 42px;
 }
 
-ul.media-list li img {
+ul#media-list li img {
     position: absolute;
     left: -42px;
     top: 2px;

Modified: trunk/projects/bos/payment-website/static/poi-ms.html
===================================================================
--- trunk/projects/bos/payment-website/static/poi-ms.html	2008-11-27 14:15:14 UTC (rev 4091)
+++ trunk/projects/bos/payment-website/static/poi-ms.html	2008-11-28 01:07:18 UTC (rev 4092)
@@ -45,7 +45,7 @@
 	  </div>
 	</div>
 	<div class="yui-b">
-          <ul class="media-list">
+          <ul id="media-list">
             <li>
               <img src="/poi-image/sunbear-sanctuary/1" width="40" height="40"/>
               20.03.2004<br/>
@@ -80,13 +80,6 @@
         </div>
       </div>
       <div id="ft">
-	<p>
-          Footer - Lorem ipsum dolor sit amet, consectetuer adipiscing
-          elit. Maecenas sit amet metus. Nunc quam elit, posuere nec,
-          auctor in, rhoncus quis, dui. Aliquam erat volutpat. Ut
-          dignissim, massa sit amet dignissim cursus, quam lacus
-          feugiat.
-        </p>
       </div>
     </div>
   </body>

Modified: trunk/projects/bos/payment-website/static/poi-ms.js
===================================================================
--- trunk/projects/bos/payment-website/static/poi-ms.js	2008-11-27 14:15:14 UTC (rev 4091)
+++ trunk/projects/bos/payment-website/static/poi-ms.js	2008-11-28 01:07:18 UTC (rev 4092)
@@ -2,7 +2,69 @@
 
 $(document).ready(init);
 
+var poi_id;
+
+Date.prototype.renderDate = function() {
+    return this.getDate() + '.' + this.getMonth() + '.' + (1900 + this.getYear());
+}
+
+var makeMediumMenuEntry = {
+    image: function (medium) {
+        return LI(null,
+                  IMG({ src: '/image/' + medium.id, width: 40, height: 40 }),
+                  (new Date(medium.timestamp)).renderDate(),
+                  BR(),
+                  A({ href: '#' }, medium.title || medium.name));
+    },
+    panorama: function (medium) {
+        return LI(null,
+                  IMG({ src: '/static/panorama-icon.gif', width: 40, height: 40 }),
+                  (new Date(medium.timestamp)).renderDate(),
+                  BR(),
+                  A({ href: '#' }, medium.title || medium.name));
+    },
+    movie: function (medium) {
+        return LI(null,
+                  IMG({ src: '/static/movie-icon.gif', width: 40, height: 40 }),
+                  (new Date(medium.timestamp)).renderDate(),
+                  BR(),
+                  A({ href: '#' }, medium.title || medium.name));
+    }
+
+};
+
+function loadPoi(poi) {
+    document.title = poi.title;
+    $('#hd h1').html(poi.title);
+    $('#hd h2').html(poi.subtitle);
+    $('#content').empty().html(poi.description);
+    $('#media-list').empty();
+    map(function (medium) {
+        if (makeMediumMenuEntry[medium.mediumType]) {
+            $('#media-list').append(makeMediumMenuEntry[medium.mediumType](medium));
+        }
+    }, poi.media);
+}
+
+function loadData(data) {
+    var pois = data.pois;
+
+    for (var i in pois) {
+        if (pois[i].id == poi_id) {
+            loadPoi(pois[i]);
+            return;
+        }
+    }
+
+    alert('invalid poi id (not found)');
+}
+
 function init() {
+    poi_id = document.location.hash.replace(/#/, "");
 
-    alert('hey ho!');
+    if (poi_id.match(/^[0-9]+$/)) {
+        loadJSONDoc('/poi-json').addCallback(loadData);
+    } else {
+        alert('invalid poi id');
+    }
 }
\ No newline at end of file

Modified: trunk/projects/bos/web/poi-handlers.lisp
===================================================================
--- trunk/projects/bos/web/poi-handlers.lisp	2008-11-27 14:15:14 UTC (rev 4091)
+++ trunk/projects/bos/web/poi-handlers.lisp	2008-11-28 01:07:18 UTC (rev 4092)
@@ -388,15 +388,20 @@
           (or (sponsor-country (contract-sponsor contract)) "de")
           (length (contract-m2s contract))))
 
+(defun poi-handle-if-modified-since (&optional (pois (class-instances 'poi)))
+  (let ((pois-last-change (reduce #'max pois
+                                  :key (lambda (poi) (store-object-last-change poi 1))
+                                  :initial-value 0)))
+    (hunchentoot:handle-if-modified-since pois-last-change)
+    (setf (hunchentoot:header-out :last-modified)
+          (hunchentoot:rfc-1123-date pois-last-change))))
+
 (defmethod handle ((handler poi-javascript-handler))
+  (poi-handle-if-modified-since)
   (let* ((last-paid-contracts (last-paid-contracts))
-         (timestamp (max (reduce #'max (class-instances 'poi)
-                                 :key (lambda (poi) (store-object-last-change poi 1)))
-                         (reduce #'max last-paid-contracts
-                                 :key (lambda (contract) (store-object-last-change contract 0))))))
+         (timestamp (reduce #'max last-paid-contracts
+                            :key (lambda (contract) (store-object-last-change contract 0)))))
     (hunchentoot:handle-if-modified-since timestamp)
-    (setf (hunchentoot:header-out :last-modified)
-          (hunchentoot:rfc-1123-date timestamp))
     (with-http-response (:content-type "text/html; charset=UTF-8")
       (with-http-body ()
         (html
@@ -617,13 +622,10 @@
   ())
 
 (defmethod handle ((handler poi-kml-all-handler))
+
   (let* ((relevant-pois (remove-if-not #'(lambda (poi) (and (poi-area poi) (poi-published-earth poi)))
-                                       (class-instances 'poi)))
-         (pois-last-change (reduce #'max relevant-pois :key (lambda (poi) (store-object-last-change poi 1))
-                                   :initial-value 0)))
-    (hunchentoot:handle-if-modified-since pois-last-change)
-    (setf (hunchentoot:header-out :last-modified)
-          (hunchentoot:rfc-1123-date pois-last-change))
+                                       (class-instances 'poi))))
+    (poi-handle-if-modified-since relevant-pois)
     (with-query-params ((lang "en"))
       (with-xml-response ()
         ;; (sax:processing-instruction cxml::*sink* "xml-stylesheet" "href=\"/static/tri.xsl\" type=\"text/xsl\"")
@@ -689,6 +691,7 @@
   ())
 
 (defmethod handle ((handler poi-json-handler))
+  (poi-handle-if-modified-since)
   (with-json-response ()
     (json:with-object-element ("pois")
       (bos.m2:pois-as-json (request-language)))))
\ No newline at end of file





More information about the Bknr-cvs mailing list