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

BKNR Commits bknr at bknr.net
Sat Jul 19 18:56:26 UTC 2008


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

Checkpoint buy/hey widget in partly working state.

U   trunk/projects/quickhoney/src/handlers.lisp
U   trunk/projects/quickhoney/upgrade-stuff/import.lisp
U   trunk/projects/quickhoney/website/static/javascript.js
U   trunk/projects/quickhoney/website/static/styles.css
U   trunk/projects/quickhoney/website/templates/index.xml

Modified: trunk/projects/quickhoney/src/handlers.lisp
===================================================================
--- trunk/projects/quickhoney/src/handlers.lisp	2008-07-19 18:30:26 UTC (rev 3524)
+++ trunk/projects/quickhoney/src/handlers.lisp	2008-07-19 18:56:26 UTC (rev 3525)
@@ -108,19 +108,20 @@
 (defmethod handle-object-form ((handler edit-image-js-handler) action image)
   (format t "; invalid action ~A or invalid object ~A~%" action image))
 
-(defun set-image-keywords-from-request-parameters (image)
-  (setf (store-image-keywords image)
-        (set-difference (store-image-keywords image) *editable-keywords*))
-  (dolist (keyword *editable-keywords*)
-    (when (query-param (string-downcase (symbol-name keyword)))
-      (push keyword (store-image-keywords image))))
-  (store-image-keywords image))
-
+(defun image-keywords-from-request-parameters ()
+  (let (retval)
+    (dolist (keyword *editable-keywords* retval)
+      (when (query-param (string-downcase (symbol-name keyword)))
+        (push keyword retval)))))
+  
 (defmethod handle-object-form ((handler edit-image-js-handler) (action (eql :edit)) image)
   (with-query-params (client spider-keywords)
     (with-transaction (:edit-image)
       (setf (quickhoney-image-client image) client
-            (quickhoney-image-spider-keywords image) spider-keywords)
+            (quickhoney-image-spider-keywords image) spider-keywords
+            (store-image-keywords image)
+            (append (set-difference (store-image-keywords image) *editable-keywords*)
+                    (image-keywords-from-request-parameters)))
       (set-image-keywords-from-request-parameters image))
     (format *js-stream* "parent.image_edited()~%")))
 
@@ -233,9 +234,10 @@
   ())
 
 (defmethod handle ((handler upload-image-handler))
-  (with-query-params (client spider-keywords explicit)
+  (with-query-params (client spider-keywords)
     (let ((uploaded-file (request-uploaded-file "image-file"))
-	  (keywords (mapcar #'make-keyword-from-string (decoded-handler-path handler))))
+	  (keywords (append (mapcar #'make-keyword-from-string (decoded-handler-path handler))
+                            (image-keywords-from-request-parameters))))
       (handler-case
 	  (progn
 	    (unless uploaded-file
@@ -254,8 +256,7 @@
 						:class-name 'quickhoney-image
 						:keywords (cons :upload keywords)
 						:initargs (list :client client
-                                                                :spider-keywords spider-keywords
-                                                                :explicit (when explicit t)))))
+                                                                :spider-keywords spider-keywords))))
 		  (with-http-response ()
 		    (with-http-body ()
 		      (html (:html

Modified: trunk/projects/quickhoney/upgrade-stuff/import.lisp
===================================================================
--- trunk/projects/quickhoney/upgrade-stuff/import.lisp	2008-07-19 18:30:26 UTC (rev 3524)
+++ trunk/projects/quickhoney/upgrade-stuff/import.lisp	2008-07-19 18:56:26 UTC (rev 3525)
@@ -4,7 +4,8 @@
   (import-image name :keywords '(:type)))
 
 (dolist (name '(#P"overlay-close.gif"
-                #P"hey.gif" #P"buy-print.gif" #P"buy-file.gif" #P"buy-t-shirt.gif"
+                #P"hey.gif"
+                #P"buy.gif" #P"buy_print.gif" #P"buy_file.gif" #P"buy_t_shirt.gif"
                 #P"button-bottom.gif" #P"add-to-cart.gif" #P"checkout.gif"))
   (handler-case
       (import-image name)

Modified: trunk/projects/quickhoney/website/static/javascript.js
===================================================================
--- trunk/projects/quickhoney/website/static/javascript.js	2008-07-19 18:30:26 UTC (rev 3524)
+++ trunk/projects/quickhoney/website/static/javascript.js	2008-07-19 18:56:26 UTC (rev 3525)
@@ -711,6 +711,8 @@
 
     debug('subdirectory: ', subdirectory);
 
+    $('explicit').checked = (subdirectory == 'nudes');
+
     $("thumbnails").innerHTML = '';
 
     $("directory_page").style.visibility = 'hidden';
@@ -994,7 +996,9 @@
 	$("edit_form_element").setAttribute("action", "/edit-image-js/" + current_image.id);
 	$("edit_client").value = current_image.client;
         $("edit_keywords").value = current_image.spider_keywords;
-        $("edit_explicit").checked = current_image.keywords.explicit ? "checked" : null;
+        map(function(keyword) {
+                $('edit_' + keyword).checked = current_image.keywords[keyword] ? true : false;
+            }, ['explicit', 'buy_file', 'buy_print', 'buy_t_shirt']);
 	show_cms_window("edit_form");
     }
 }
@@ -1214,7 +1218,7 @@
 
 function make_image_action_button(name, action, height)
 {
-    var div = DIV(null, IMG({ src: recolored_image_path(name), width: 126, height: height }));
+    var div = DIV(null, IMG({ src: recolored_image_path(name), width: 127, height: height }));
     div.onclick = function() { action(); return false; };
     return div;
 }
@@ -1222,15 +1226,22 @@
 function make_image_action_buttons()
 {
     var buttons = [];
-    if (1 || current_image.download_product) {
-        buttons.push(make_image_action_button('buy-file', make_buy_form, 22));
-    }
+    var buyable = false;
+    map(function (keyword) {
+            if (current_image.keywords[keyword]) {
+                buyable = true;
+                buttons.push(make_image_action_button(keyword, make_buy_form, 22));
+            }
+        }, ['buy_file', 'buy_print', 'buy_t_shirt']);
     buttons.push(make_image_action_button('hey', make_hey_form, 23));
     replaceChildNodes('image_action_buttons', buttons);
+    if (buyable) {
+        appendChildNodes('image_action_buttons', IMG({ id: 'buy', src: recolored_image_path('buy'), width: 127, height: 22}));
+    }
     $('image_action_buttons').onmouseover = function () {
         var e = $('image_action_buttons');
         e.style.left = '518px';
-        e.style.width = '126px';
+        e.style.width = '127px';
     }
     $('image_action_buttons').onmouseout = function () {
         var e = $('image_action_buttons');

Modified: trunk/projects/quickhoney/website/static/styles.css
===================================================================
--- trunk/projects/quickhoney/website/static/styles.css	2008-07-19 18:30:26 UTC (rev 3524)
+++ trunk/projects/quickhoney/website/static/styles.css	2008-07-19 18:56:26 UTC (rev 3525)
@@ -520,6 +520,13 @@
         z-index: 100;
 }
 
+#image_action_buttons #buy {
+        z-index: 110;
+        position: absolute;
+        left: 0px;
+        top: 0px;
+}
+
 #overlay #hey {
          padding: 10px 15px 10px 10px;
 }

Modified: trunk/projects/quickhoney/website/templates/index.xml
===================================================================
--- trunk/projects/quickhoney/website/templates/index.xml	2008-07-19 18:30:26 UTC (rev 3524)
+++ trunk/projects/quickhoney/website/templates/index.xml	2008-07-19 18:56:26 UTC (rev 3525)
@@ -197,7 +197,10 @@
             </div>
             Keywords:<br />
             <input type="text" id="upload_keywords" name="spider-keywords" value="" /><br />
-            <input type="checkbox" name="explicit" value="1" /> Explicit<br/>
+            <input type="checkbox" id="explicit" name="explicit" value="1" /> Explicit<br/>
+            <input type="checkbox" name="buy-file" value="1"/> Sell as file<br/>
+            <input type="checkbox" name="buy-print" value="1"/> Sell as print<br/>
+            <input type="checkbox" name="buy-t-shirt" value="1"/> Sell as t-shirt<br/>
           </p>
           <p class="cms">
             <input type="submit" name="upload" value="upload" />
@@ -264,9 +267,9 @@
             Keywords:<br />
             <input type="text" id="edit_keywords" name="spider-keywords" value="" /><br />
             <input type="checkbox" id="edit_explicit" name="explicit" value="1" /> Explicit<br/>
-            <input type="checkbox" name="buy-file" value="1"/> Sell as file<br/>
-            <input type="checkbox" name="buy-print" value="1"/> Sell as print<br/>
-            <input type="checkbox" name="buy-t-shirt" value="1"/> Sell as t-shirt<br/>
+            <input type="checkbox" id="edit_buy_file" name="buy-file" value="1"/> Sell as file<br/>
+            <input type="checkbox" id="edit_buy_print" name="buy-print" value="1"/> Sell as print<br/>
+            <input type="checkbox" id="edit_buy_t_shirt" name="buy-t-shirt" value="1"/> Sell as t-shirt<br/>
           </p>
           <p class="cms">
             <input type="submit" name="action" value="edit" />




More information about the Bknr-cvs mailing list