[bknr-cvs] r1966 - in branches/xml-class-rework/projects/quickhoney: src website/static website/templates

bknr at bknr.net bknr at bknr.net
Sun Jul 16 13:41:48 UTC 2006


Author: hhubner
Date: 2006-07-16 09:41:47 -0400 (Sun, 16 Jul 2006)
New Revision: 1966

Modified:
   branches/xml-class-rework/projects/quickhoney/src/handlers.lisp
   branches/xml-class-rework/projects/quickhoney/website/static/javascript.js
   branches/xml-class-rework/projects/quickhoney/website/templates/index.xml
Log:
Make contact image user-replaceable.


Modified: branches/xml-class-rework/projects/quickhoney/src/handlers.lisp
===================================================================
--- branches/xml-class-rework/projects/quickhoney/src/handlers.lisp	2006-07-16 11:49:47 UTC (rev 1965)
+++ branches/xml-class-rework/projects/quickhoney/src/handlers.lisp	2006-07-16 13:41:47 UTC (rev 1966)
@@ -151,7 +151,7 @@
       (handler-case
 	  (progn
 	    (unless uploaded-file
-	      (error "no file uploaded in upload handler"))
+	      (error "no file uploaded"))
 	    (cl-gd:with-image-from-file* (uploaded-file)
 	      (let* ((color-table (make-hash-table :test #'eql))
 		     (width (cl-gd:image-width))
@@ -187,7 +187,7 @@
 		     (:body
 		      (:h2 "Error during upload")
 		      (:p "Error during upload:")
-		      (:pre (:princ-safe e))
+		      (:p (:princ-safe (apply #'format nil (simple-condition-format-control e) (simple-condition-format-arguments e))))
 		      (:p ((:a :href "javascript:window.close()") "ok"))))))))))))
 
 (defclass upload-animation-handler (admin-only-handler page-handler)
@@ -249,7 +249,7 @@
 			 (not (equal "" subdirectory)))
 	      (error "no subcategory selected, upload not accepted"))
 	    (unless uploaded-file
-	      (error "no file uploaded in upload handler"))
+	      (error "no file uploaded"))
 	    (cl-gd:with-image-from-file* (uploaded-file)
 	      (unless (and (eql 208 (cl-gd:image-width))
 			   (eql 208 (cl-gd:image-height)))
@@ -278,5 +278,5 @@
 		     (:body
 		      (:h2 "Error during upload")
 		      (:p "Error during upload:")
-		      (:pre (:princ-safe e))
+		      (:p (:princ-safe (apply #'format nil (simple-condition-format-control e) (simple-condition-format-arguments e))))
 		      (:p ((:a :href "javascript:window.close()") "ok"))))))))))))

Modified: branches/xml-class-rework/projects/quickhoney/website/static/javascript.js
===================================================================
--- branches/xml-class-rework/projects/quickhoney/website/static/javascript.js	2006-07-16 11:49:47 UTC (rev 1965)
+++ branches/xml-class-rework/projects/quickhoney/website/static/javascript.js	2006-07-16 13:41:47 UTC (rev 1966)
@@ -155,7 +155,7 @@
     document.getElementById("image_detail").innerHTML = '';
     if (current_directory == 'quickhoney') {
 	load_button_images();
-	setTimeout("if (current_directory == 'quickhoney') { show_cms_window('edit_quickhoney_form'); }", 2000);
+	setTimeout("if (current_directory == 'quickhoney') { show_cms_window('edit_quickhoney_form'); } else if (current_directory == 'contact') { show_cms_window('edit_contact_form'); }", 2000);
     } else {
 	setTimeout("if (!current_image) { show_cms_window('upload_form'); }", 2000);
 	do_query();
@@ -366,6 +366,12 @@
 	       ['000000', 'ffffff', '9900ff'],
 	       function() {
 		   footer_hide();
+
+		   if (button_images['contact/contact']) {
+		       document.getElementById("contactimage").src = button_images['contact/contact'];
+		   }
+
+		   current_directory = 'contact';
 	       });
 
 function preload_menu_images() {
@@ -425,6 +431,8 @@
     if (logged_in) {
 	if (current_directory == "quickhoney") {
 	    show_cms_window("edit_quickhoney_form");
+	} else if (current_directory == "contact") {
+	    show_cms_window("edit_contact_form");
 	} else if (current_directory && current_subdirectory) {
 	    if (current_image) {
 		show_cms_window('edit_form');
@@ -548,6 +556,22 @@
     }
 }
 
+/* contact image */
+
+function contact_loaded(image) {
+
+    debug('contact_loaded - image is ' + image + ' width: ' + image.width);
+
+    reveal_image(image);
+
+    if (logged_in) {
+	var current_contact_image = image.src.substring(image.src.indexOf('/image/') + 7);
+	if (current_contact_image != 'trans') {
+	    document.getElementById("delete_contactimage_form_element").setAttribute("action", "/edit-image-js/" + current_contact_image);
+	}
+    }
+}
+
 /* directory - first level category */
 
 var button_images = [];
@@ -557,10 +581,13 @@
     button_images = _button_images;
 
     if (current_directory == 'quickhoney'
+	|| current_directory == 'contact'
 	|| (document.getElementById("homeimage").src.indexOf("trans") != -1)) {
 
 	document.getElementById("homeimage").style.visibility = 'hidden';
 	document.getElementById("homeimage").src = button_images['home/home'];
+
+	document.getElementById("contactimage").src = button_images['contact/contact'];
     }
 }
 
@@ -570,7 +597,8 @@
 							       + '/home/home'
 							       + '/pixel/' + directory_button['pixel'].join(',')
 							       + '/vector/' + directory_button['vector'].join(',')
-							       + '/photo,000000/' + directory_button['photo'].join(','));
+							       + '/photo,000000/' + directory_button['photo'].join(',')
+							       + '/contact/contact');
 }
 
 function directory(directory_name) {

Modified: branches/xml-class-rework/projects/quickhoney/website/templates/index.xml
===================================================================
--- branches/xml-class-rework/projects/quickhoney/website/templates/index.xml	2006-07-16 11:49:47 UTC (rev 1965)
+++ branches/xml-class-rework/projects/quickhoney/website/templates/index.xml	2006-07-16 13:41:47 UTC (rev 1966)
@@ -105,7 +105,7 @@
 	
 			<div id="contact">
 				<div id="contact-bigimage">
-					<img src="/image/contact-peter-nana" />
+					<img id="contactimage" src="/image/trans" onload="contact_loaded(this);"/>
 				</div>
 				<img class="contact" src="/image/type_contact_email" />
 				<p class="contact">
@@ -238,6 +238,23 @@
 				</form>
 			</div>
 	
+			<div id="edit_contact_form" class="cms_form">
+				<div class="cms_title">Upload home image</div>
+				<form action="/upload-image/contact/button" method="post"
+						enctype="multipart/form-data" target="upload_result" onsubmit="do_upload(this.target);">
+					<p class="cms">
+						<input type="file" name="image-file" /><br />
+					</p>
+					<p class="cms">
+						<input type="submit" name="action" value="upload" />
+					</p>
+				</form>
+				<div class="cms_title">Delete this home image</div>
+				<form id="delete_contactimage_form_element" action="/edit-image-js" target="edit_iframe" method="post">
+					<input type="submit" name="action" value="delete" onclick="return confirm('Really delete this contact image?');" />
+				</form>
+			</div>
+	
 			<div id="saving_edits_form" class="cms_form">
 				<div class="cms_title">Saving Edits</div>
 				<p class="cms">




More information about the Bknr-cvs mailing list