Changeset 3701
- Timestamp:
- 07/30/08 23:06:43 (4 months ago)
- Files:
-
- trunk/projects/quickhoney/src/handlers.lisp (modified) (2 diffs)
- trunk/projects/quickhoney/src/image.lisp (modified) (3 diffs)
- trunk/projects/quickhoney/src/news.lisp (added)
- trunk/projects/quickhoney/src/quickhoney.asd (modified) (1 diff)
- trunk/projects/quickhoney/src/webserver.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/quickhoney/src/handlers.lisp
r3529 r3701 314 314 "function done() { window.opener.do_query(); window.close(); }")) 315 315 (:body 316 (:p "Image " (:princ-safe (store-image-name image)) " with " (:princ-safe (hash-table-count color-table)) " colors uploaded") 316 (:p "Image " (:princ-safe (store-image-name image)) " with " 317 (:princ-safe (hash-table-count color-table)) " colors uploaded") 317 318 (:p ((:img :src (format nil "/image/~D" (store-object-id image)) 318 319 :width (round (* ratio width)) :height (round (* ratio height))))) … … 425 426 (:p (:princ-safe (apply #'format nil (simple-condition-format-control e) (simple-condition-format-arguments e)))) 426 427 (:p ((:a :href "javascript:window.close()") "ok")))))))))))) 428 429 (defclass news-json-handler (object-handler) 430 () 431 (:default-initargs :object-class 'rss-channel :query-function #'find-rss-channel)) 432 433 (defvar *json-output*) 434 435 (defmacro with-json-output ((stream) &body body) 436 `(let ((*json-output* ,stream)) 437 ,@body)) 438 439 (defmacro with-json-output-to-string (() &body body) 440 `(with-output-to-string (*json-output*) 441 ,@body)) 442 443 (defmacro with-json-array (() &body body) 444 (with-gensyms (need-comma) 445 `(let (,need-comma) 446 (princ #\[ *json-output*) 447 (prog1 448 (labels ((encode-array-element (value) 449 (if ,need-comma 450 (princ #\, *json-output*) 451 (setf ,need-comma t)) 452 (json:encode-json value *json-output*))) 453 ,@body) 454 (princ #\] *json-output*))))) 455 456 (defmacro with-json-object (() &body body) 457 (with-gensyms (need-comma) 458 `(let (,need-comma) 459 (princ #\{ *json-output*) 460 (prog1 461 (labels ((encode-object-member (key value) 462 (when value 463 (if ,need-comma 464 (princ #\, *json-output*) 465 (setf ,need-comma t)) 466 (json:encode-json key *json-output*) 467 (princ #\, *json-output*) 468 (json:encode-json value *json-output*)))) 469 ,@body) 470 (princ #\} *json-output*))))) 471 472 (defmethod handle-object ((handler news-json-handler) (channel rss-channel)) 473 (with-http-response (:content-type "application/json") 474 (with-json-output-to-string () 475 (with-json-array () 476 (dolist (item (rss-channel-items channel)) 477 (with-json-object () 478 (encode-object-member "pubDate" (format-date-time (rss-item-pub-date item) :vms-style t)) 479 (encode-object-member "title" (rss-item-title item)) 480 (encode-object-member "description" (rss-item-description item)))))))) trunk/projects/quickhoney/src/image.lisp
r3683 r3701 8 8 (spider-keywords :update :initform nil) 9 9 (products :update :initform nil))) 10 11 (defmethod rss-item-pub-date ((item quickhoney-image))12 (blob-timestamp item))13 14 (defmethod quickhoney-image-explicit ((image quickhoney-image))15 (member :explicit (store-image-keywords image)))16 17 (defmethod rss-item-encoded-content ((image quickhoney-image))18 (let* ((category (first (intersection (store-image-keywords image) '(:vector :pixel))))19 (is-vector (eq category :vector)))20 (with-output-to-string (s)21 (html-stream22 s23 ((:div :class (format nil "newsentry news_~(~A~)" category))24 ((:img :src (format nil "http://~A/image/~A/cutout-button,,~A,98,4"25 (website-host)26 (store-object-id image)27 (if is-vector "00ccff" "ff00ff")))28 (:div29 (:h1 (:princ (store-image-name image)))30 (:princ (format nil "~A by ~A | "31 (format-date-time (blob-timestamp image))32 (if is-vector "Peter" "Nana")))33 ((:a :href (make-image-link image)) "permalink")))))34 (when (quickhoney-image-client image)35 (html-stream s :br "Client: " (:princ (quickhoney-image-client image)))))))36 10 37 11 (defvar *last-image-upload-timestamp* 0) … … 48 22 (store-object-remove-keywords image 'bknr.web::keywords '(:import))) 49 23 (get-keywords-intersection-store-images '(:import)))) 50 51 (defmethod rss-item-channel ((item quickhoney-image))52 "quickhoney")53 54 (defmethod rss-item-title ((image quickhoney-image))55 (store-image-name image))56 57 (defmethod rss-item-description ((image quickhoney-image))58 (format nil "~A~@[ (Client: ~A)~]" (store-image-name image) (quickhoney-image-client image)))59 60 (defmethod rss-item-link ((image quickhoney-image))61 (make-image-link image))62 63 (defmethod rss-item-guid ((image quickhoney-image))64 (make-image-link image))65 24 66 25 (defmethod quickhoney-image-category ((image quickhoney-image)) … … 82 41 (delete-object (quickhoney-animation-image-animation image))) 83 42 84 (define-persistent-class quickhoney-news-item (quickhoney-image)85 ((title :update)86 (text :update)))87 88 (defmethod quickhoney-image-spider-keywords ((item quickhoney-news-item))89 (quickhoney-news-item-title item))90 91 (defmethod rss-item-title ((item quickhoney-news-item))92 (quickhoney-news-item-title item))93 94 (defmethod rss-item-encoded-content ((item quickhoney-news-item))95 (concatenate 'string96 (call-next-method)97 (quickhoney-news-item-text item)))98 99 (defclass quickhoney-rss-channel (rss-channel)100 ()101 (:metaclass persistent-class))102 103 (defmethod rss-channel-items ((channel quickhoney-rss-channel) &key)104 (remove-if (lambda (item)105 (and (typep item 'quickhoney-image)106 (quickhoney-image-explicit item)))107 (call-next-method)))trunk/projects/quickhoney/src/quickhoney.asd
r3648 r3701 30 30 (:file "config" :depends-on ("packages")) 31 31 (:file "image" :depends-on ("config")) 32 (:file "news" :depends-on ("image")) 32 33 (:file "layout" :depends-on ("config")) 33 34 (:file "imageproc" :depends-on ("config")) trunk/projects/quickhoney/src/webserver.lisp
r2832 r3701 34 34 ("/upload-news" upload-news-handler) 35 35 ("/digg-image" digg-image-handler) 36 ("/news-json" news-json-handler) 36 37 ("/" template-handler 37 38 :default-template "frontpage"
