[bknr-cvs] r2504 - in branches/trunk-reorg/projects/quickhoney: src website/static website/templates

hhubner at common-lisp.net hhubner at common-lisp.net
Fri Feb 15 16:33:57 UTC 2008


Author: hhubner
Date: Fri Feb 15 11:33:56 2008
New Revision: 2504

Modified:
   branches/trunk-reorg/projects/quickhoney/src/handlers.lisp
   branches/trunk-reorg/projects/quickhoney/src/tags.lisp
   branches/trunk-reorg/projects/quickhoney/website/static/javascript.js
   branches/trunk-reorg/projects/quickhoney/website/templates/index.xml
Log:
Fix Javascript handling so that it works with current CXML.
Fix direct navigation to category page.
Reformats.


Modified: branches/trunk-reorg/projects/quickhoney/src/handlers.lisp
==============================================================================
--- branches/trunk-reorg/projects/quickhoney/src/handlers.lisp	(original)
+++ branches/trunk-reorg/projects/quickhoney/src/handlers.lisp	Fri Feb 15 11:33:56 2008
@@ -5,13 +5,17 @@
 (defclass javascript-handler ()
   ())
 
+(defvar *js-stream*)
+
 (defmethod handle :around ((handler javascript-handler))
   (with-http-response (:content-type "text/html; charset=UTF-8")
     (no-cache)
     (with-http-body ()
-      (format *html-stream* "<script language=\"JavaScript\">~%")
-      (call-next-method)
-      (format *html-stream* "~%</script>~%"))))
+      (html
+       ((:script :language "JavaScript")
+        (:princ
+         (with-output-to-string (*js-stream*)
+           (call-next-method))))))))
 
 (defclass random-image-handler (object-handler)
   ())
@@ -29,7 +33,7 @@
   (let ((content-type (blob-type (quickhoney-animation-image-animation animation))))
     (with-http-response (:content-type content-type)
       (with-http-body ()
-	(blob-to-stream (quickhoney-animation-image-animation animation) *html-stream*)))))
+	(blob-to-stream (quickhoney-animation-image-animation animation) *js-stream*)))))
 
 (defclass image-query-js-handler (javascript-handler object-handler)
   ())
@@ -62,19 +66,19 @@
     (format t "]~%")))
 
 (defmethod handle-object ((handler image-query-js-handler) images)
-  (format *html-stream* "parent.process_query_result(~%")
+  (format *js-stream* "parent.process_query_result(~%")
   (with-query-params (layout)
     (princ (layout-to-javascript (make-instance (case (make-keyword-from-string layout)
 						  (:smallworld 'quickhoney-name-layout)
 						  (t 'quickhoney-standard-layout))
-						:objects images)) *html-stream*))
-  (format *html-stream* ");~%"))
+						:objects images)) *js-stream*))
+  (format *js-stream* ");~%"))
 
 (defclass login-js-handler (javascript-handler page-handler)
   ())
 
 (defmethod handle ((handler login-js-handler))
-  (format *html-stream* "parent.login_complete(~A, ~S);~%"
+  (format *js-stream* "parent.login_complete(~A, ~S);~%"
 	  (if (admin-p (bknr-session-user)) "true" "false")
 	  (user-login (bknr-session-user))))
 
@@ -84,7 +88,7 @@
 (defmethod handle ((handler clients-js-handler))
   (let ((clients (sort (remove "" (all-clients) :test #'equal)
 		       #'string-lessp)))
-    (format *html-stream* "parent.set_clients([~S~{, ~S~}]);~%"
+    (format *js-stream* "parent.set_clients([~S~{, ~S~}]);~%"
 	    (car clients) (cdr clients))))
 
 (defclass edit-image-js-handler (admin-only-handler javascript-handler edit-object-handler)
@@ -97,11 +101,11 @@
 (defmethod handle-object-form ((handler edit-image-js-handler) (action (eql :edit)) image)
   (with-query-params (client)
     (change-slot-values image 'client client)
-    (format *html-stream* "parent.image_edited()~%")))
+    (format *js-stream* "parent.image_edited()~%")))
 
 (defmethod handle-object-form ((handler edit-image-js-handler) (action (eql :delete)) (image quickhoney-image))
   (delete-object image)
-  (format *html-stream* "parent.image_deleted();~%"))
+  (format *js-stream* "parent.image_deleted();~%"))
 
 (defclass buttons-js-handler (javascript-handler prefix-handler)
   ())
@@ -138,11 +142,11 @@
 		       collect (list category subcategory (button-for-category category subcategory background-color))))))
 
 (defmethod handle ((handler buttons-js-handler))
-  (format *html-stream* "var buttons = [];~%")
+  (format *js-stream* "var buttons = [];~%")
   (loop for (category subcategory image-url) in (find-button-images (decoded-handler-path handler))
 	when image-url
-	do (format *html-stream* "buttons['~(~A/~A~)'] = ~S;~%" category subcategory image-url))
-  (format *html-stream* "parent.set_button_images(buttons);~%"))
+	do (format *js-stream* "buttons['~(~A/~A~)'] = ~S;~%" category subcategory image-url))
+  (format *js-stream* "parent.set_button_images(buttons);~%"))
 
 (defclass upload-image-handler (admin-only-handler prefix-handler)
   ())
@@ -259,7 +263,9 @@
 		(error "invalid image size, buttons must be 208 by 208 pixels"))
 	      (let* ((image (make-store-image :name (pathname-name uploaded-file)
 					      :class-name 'store-image
-					      :keywords (list :button (make-keyword-from-string directory) (make-keyword-from-string subdirectory)))))
+					      :keywords (list :button
+                                                              (make-keyword-from-string directory)
+                                                              (make-keyword-from-string subdirectory)))))
 		(with-http-response ()
 		  (with-http-body ()
 		    (html (:html

Modified: branches/trunk-reorg/projects/quickhoney/src/tags.lisp
==============================================================================
--- branches/trunk-reorg/projects/quickhoney/src/tags.lisp	(original)
+++ branches/trunk-reorg/projects/quickhoney/src/tags.lisp	Fri Feb 15 11:33:56 2008
@@ -1,7 +1,6 @@
 (in-package :quickhoney.tags)
 
 (define-bknr-tag version-and-last-change (&rest args)
-  (format *debug-io* "hello world: ~A~%" args)
   (html "v1.1 | updated "
         (:princ-safe (string-downcase
                       (substitute #\Space #\-

Modified: branches/trunk-reorg/projects/quickhoney/website/static/javascript.js
==============================================================================
--- branches/trunk-reorg/projects/quickhoney/website/static/javascript.js	(original)
+++ branches/trunk-reorg/projects/quickhoney/website/static/javascript.js	Fri Feb 15 11:33:56 2008
@@ -607,8 +607,10 @@
 	var components = document.jump_to.split("/");
 	document.jump_to = null;
 	show_page(components[0]);
-	subdirectory(components[1]);
-	document.show_picture = components[2];
+        if (components[1]) {
+            subdirectory(components[1]);
+        }
+        document.show_picture = components[2];
     }
 }
 

Modified: branches/trunk-reorg/projects/quickhoney/website/templates/index.xml
==============================================================================
--- branches/trunk-reorg/projects/quickhoney/website/templates/index.xml	(original)
+++ branches/trunk-reorg/projects/quickhoney/website/templates/index.xml	Fri Feb 15 11:33:56 2008
@@ -127,7 +127,7 @@
 			</div>
 	
 			<div id="footer" class="text">
-				©1998-2006 QuickHoney Nana Rausch & Peter Stemmler. No part of
+				©1998-2008 QuickHoney Nana Rausch & Peter Stemmler. No part of
 				this website may be reproduced in any manner without permission.
 				Programming by Hübner/Odendahl <a href="http://headcraft.de/" target="_new">
 				headcraft</a>



More information about the Bknr-cvs mailing list