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

BKNR Commits bknr at bknr.net
Sat Sep 6 16:33:40 UTC 2008


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

Reworked and enhanced non-JS image browser to support site indexing by
search engines.

U   trunk/projects/quickhoney/src/tags.lisp
U   trunk/projects/quickhoney/website/templates/frontpage.xml
U   trunk/projects/quickhoney/website/templates/image-browse.xml
U   trunk/projects/quickhoney/website/templates/index.xml

Modified: trunk/projects/quickhoney/src/tags.lisp
===================================================================
--- trunk/projects/quickhoney/src/tags.lisp	2008-09-06 16:31:28 UTC (rev 3819)
+++ trunk/projects/quickhoney/src/tags.lisp	2008-09-06 16:33:40 UTC (rev 3820)
@@ -9,71 +9,95 @@
                                   (format-date-time (last-image-upload-timestamp)
                                                     :vms-style t :show-time nil))))))
 
+(defun image-url (image)
+  (format nil "/image-browse/~(~A/~A~)/~A"
+          (quickhoney-image-category image)
+          (quickhoney-image-subcategory image)
+          (bknr.images:store-image-name image)))
+
+(defun navigation (&key previous up next)
+  (html ((:div :class "nav")
+         (when previous
+           (html ((:div :class "previous")
+                  ((:a :href previous) "<<"))))
+         ((:div :class "up")
+          ((:a :href up)
+           "up"))
+         (when next
+           (html ((:div :class "next")
+                  ((:a :href next) ">>")))))))
+
 (define-bknr-tag simple-image-browser ()
   (tbnl:handle-if-modified-since (last-image-upload-timestamp))
   (destructuring-bind (&optional category subcategory image-name) (multiple-value-list (parse-url))
     (cond
       (image-name
-       (let ((image (or (bknr.images:store-image-with-name image-name)
-                        (error #?"image $(image-name) not found"))))
-         (html
-          (:table
-           (:tbody
-            (:tr (:td "name") (:td (:princ image-name)))
-            (let ((next (cadr (member image (bknr.datastore:class-instances 'quickhoney-image)))))
-              (when next
-                (html (:tr (:td "next")
-                           (:td ((:a :href #?"/image-browse/$((bknr.images:store-image-name next))")
-                                 (:princ (bknr.images:store-image-name next))))))))
-            (:tr (:td "width") (:td (:princ (bknr.images:store-image-width image))))
-            (:tr (:td "height") (:td (:princ (bknr.images:store-image-height image))))
-            (when (quickhoney-image-client image)
-              (html (:tr (:td "client") (:td (:princ (quickhoney-image-client image))))))
-            (when (quickhoney-image-spider-keywords image)
-              (html (:tr (:td "description") (:td (:princ (quickhoney-image-spider-keywords image))))))))
-          ((:img :src #?"/image/$(image-name)"
-                 :width (bknr.images:store-image-width image)
-                 :height (bknr.images:store-image-height image)))
-          ((:script :type "text/javascript")
-           (:princ #?"document.location.href = document.location.href.replace(/\\/image-browse.*/, '$((make-image-link image :internal t))');")))))
+       (let* ((image (or (bknr.images:store-image-with-name image-name)
+                        (error #?"image $(image-name) not found")))
+              (images-in-category (images-in-category (list (quickhoney-image-category image)
+                                                            (quickhoney-image-subcategory image))))
+              (previous (loop for rest on images-in-category
+                              when (equal image (cadr rest))
+                              do (return (car rest))))
+              (next (cadr (member image images-in-category))))
+         (navigation :previous (and previous (image-url previous))
+                     :up (format nil "/image-browse/~(~A/~A~)"
+                                 (quickhoney-image-category image)
+                                 (quickhoney-image-subcategory image))
+                     :next (and next (image-url next)))
+         (html 
+               ((:img :src #?"/image/$(image-name)"
+                      :class "image"
+                      :width (bknr.images:store-image-width image)
+                      :height (bknr.images:store-image-height image)))
+               ((:div :class "metadata" :style #?"height: $((bknr.images:store-image-height image))px")
+                (:table
+                 (:tbody
+                  (:tr (:th "name")
+                       (:td (:princ image-name)))
+                  (:tr (:th "artist")
+                       (:td (:princ (bknr.user:user-full-name (or (bknr.user:owned-object-owner image)
+                                                                  (bknr.user:find-user "hans"))))
+                            ", QuickHoney"))
+                  (:tr (:th "date")
+                       (:td (:princ (format-date-time (bknr.datastore:blob-timestamp image) :vms-style t :show-time nil))))
+                  (when (and (quickhoney-image-client image)
+                             (not (equal "" (quickhoney-image-client image))))
+                    (html (:tr (:th "client")
+                               (:td (:princ (quickhoney-image-client image))))))
+                  (when (quickhoney-image-spider-keywords image)
+                    (html (:tr (:th "keywords")
+                               (:td (:princ (quickhoney-image-spider-keywords image))))))))))))
       (subcategory
+       (navigation :up (format nil "/image-browse/~(~A~)" category))
        (html
-        (:h1 (:princ #?"Images with category $(category) and subcategory $(subcategory)"))
+        (:h1 (:princ #?"$(category) / $(subcategory)"))
         (:ul
-         (dolist (image (bknr.images:get-keywords-intersection-store-images
-                         (mapcar #'make-keyword-from-string (list category subcategory))))
+         (dolist (image (sort (copy-list (quickhoney:images-in-category (mapcar #'make-keyword-from-string (list category subcategory))))
+                              #'>
+                              :key #'bknr.datastore:blob-timestamp))
            (html
             (:li ((:a :href #?"/image-browse/$(category)/$(subcategory)/$((bknr.images:store-image-name image))")
                   (:princ (bknr.images:store-image-name image)))))))))
       (category
+       (navigation :up "/image-browse")
        (html
-        (:h1 (:princ #?"Subcategories of $(category)"))
+        (:h1 (:princ category))
         (:ul
-         (dolist (subcategory (mapcar #'car
-                                      (group-on (remove (find-class 'quickhoney::quickhoney-image)
-                                                        (bknr.images:get-keyword-store-images (make-keyword-from-string category))
-                                                        :test (complement #'eq) :key #'class-of)
-                                                :key #'quickhoney::quickhoney-image-subcategory)))
+         (dolist (subcategory (subcategories-of (make-keyword-from-string category)))
            (html
             (:li ((:a :href (format nil "/image-browse/~A/~(~A~)" category subcategory)))
                  (:princ subcategory)))))))
       (t
        (html
-        (:h1 (:princ #?"Categories"))
-        (:ul
-         (dolist (category (mapcar #'car
-                                   (group-on (bknr.datastore:class-instances 'quickhoney::quickhoney-image)
-                                             :key #'quickhoney::quickhoney-image-category)))
-           (when category
-             (html
-              (:li ((:a :href (format nil "/image-browse/~(~A~)" category)))
-                   (:princ category)))))))))))
+        ((:a :href "/image-browse/pixel")
+         (:h1 "Nana Rausch"))
+        ((:a :href "/image-browse/vector")
+         (:h1 "Peter Stemmler")))))
+    (html
+     ((:script :type "text/javascript")
+      (:princ #?"document.location.href = document.location.href.replace(/\\/image-browse\\//, '/index#');")))))
 
-(define-bknr-tag first-image-link ()
-  (html
-   ((:a :href #?"/image-browse/$((bknr.images:store-image-name (first (bknr.datastore:class-instances 'quickhoney-image))))")
-    (emit-tag-children))))
-
 (define-bknr-tag login-status ()
   (cond
     ((bknr.web::admin-p (bknr-session-user))

Modified: trunk/projects/quickhoney/website/templates/frontpage.xml
===================================================================
--- trunk/projects/quickhoney/website/templates/frontpage.xml	2008-09-06 16:31:28 UTC (rev 3819)
+++ trunk/projects/quickhoney/website/templates/frontpage.xml	2008-09-06 16:33:40 UTC (rev 3820)
@@ -30,7 +30,7 @@
   <p>
    This site requires Firefox, Safari or Internet Explorer and Javascript for full viewing pleasure.
   </p>
-  <p>Enter our <quickhoney:first-image-link>Image gallery</quickhoney:first-image-link> for basic view.</p>
+  <p>Enter our <a href="/image-browse">Image gallery</a> for basic view.</p>
   <script type="text/javascript">
    document.location.href = '/index';
   </script>

Modified: trunk/projects/quickhoney/website/templates/image-browse.xml
===================================================================
--- trunk/projects/quickhoney/website/templates/image-browse.xml	2008-09-06 16:31:28 UTC (rev 3819)
+++ trunk/projects/quickhoney/website/templates/image-browse.xml	2008-09-06 16:33:40 UTC (rev 3820)
@@ -1,25 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html
-  xmlns="http://www.w3.org/1999/xhtml"
-  xmlns:bknr="http://bknr.net"
-  xmlns:quickhoney="http://quickhoney.com/"
-  >
- <head>
-  <link rel="stylesheet" href="/static/styles.css" />
-  <script src="/static/javascript.js" type="text/javascript"><!-- x -->   
-  </script> 
-  <title>QuickHoney image</title>
- </head>
- <body id="imagedetail">
-  <div id="logo">
-   <a href="javascript:window.close()">
-    <img src="/image/quickhoney" id="the_logo" name="logo" border="0" />
-   </a>
-  </div>
-  <div id="image">
-   <quickhoney:simple-image-browser />
-  </div>
- </body>
-</html>
\ No newline at end of file
+   xmlns="http://www.w3.org/1999/xhtml"
+   xmlns:bknr="http://bknr.net"
+   xmlns:quickhoney="http://quickhoney.com/"
+   >
+  <head>
+    <link rel="stylesheet" href="/static/yui/reset-fonts/reset-fonts.css" />
+    <link rel="stylesheet" href="/static/quickhoney.css" />
+    <link rel="stylesheet" href="/static/image-browse.css" />
+    <script src="/static/javascript.js" type="text/javascript"><!-- x -->   
+    </script> 
+    <title>QuickHoney image</title>
+  </head>
+  <body id="image-browse">
+    <div id="logo">
+      <img src="/image/quickhoney-black" id="the_logo" name="logo" border="0" />
+    </div>
+    <quickhoney:simple-image-browser />
+    <div id="footer">
+      ©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>
+    </div>
+  </body>
+</html>

Modified: trunk/projects/quickhoney/website/templates/index.xml
===================================================================
--- trunk/projects/quickhoney/website/templates/index.xml	2008-09-06 16:31:28 UTC (rev 3819)
+++ trunk/projects/quickhoney/website/templates/index.xml	2008-09-06 16:33:40 UTC (rev 3820)
@@ -9,7 +9,8 @@
    >
   <head>
     <link rel="stylesheet" href="/static/yui/reset-fonts/reset-fonts.css" />
-    <link rel="stylesheet" href="/static/styles.css" />
+    <link rel="stylesheet" href="/static/quickhoney.css" />
+    <link rel="stylesheet" href="/static/index.css" />
     <link rel="stylesheet" href="/static/ydsf.css" />
     <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="/rss/quickhoney" />
     <script src="/static/detectplugins.js" type="text/javascript"> </script> 




More information about the Bknr-cvs mailing list