Changeset 3912
- Timestamp:
- 09/17/08 13:47:43 (2 months ago)
- Files:
-
- trunk/projects/quickhoney/src/handlers.lisp (modified) (3 diffs)
- trunk/projects/quickhoney/src/packages.lisp (modified) (1 diff)
- trunk/projects/quickhoney/src/quickhoney.asd (modified) (1 diff)
- trunk/projects/quickhoney/src/twitter.lisp (modified) (1 diff)
- trunk/projects/quickhoney/upgrade-stuff (deleted)
- trunk/projects/quickhoney/website/static/javascript.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/quickhoney/src/handlers.lisp
r3905 r3912 294 294 (let* ((width (cl-gd:image-width)) 295 295 (height (cl-gd:image-height)) 296 (ratio (/ 1 (max (/ width 300) (/ height 200))))) 296 (ratio (/ 1 (max (/ width 300) (/ height 200)))) 297 (image-name (pathname-name (upload-original-filename uploaded-file)))) 297 298 (maybe-convert-to-palette) 298 (let* ((image (make-store-image :name (pathname-name (upload-original-filename uploaded-file))299 (let* ((image (make-store-image :name image-name 299 300 :class-name 'quickhoney-image 300 301 :keywords (cons :upload (image-keywords-from-request-parameters)) … … 305 306 (with-http-response () 306 307 (with-http-body () 308 (twitter:update-status (bknr-session-user) 309 (format nil "Uploaded new image ~A: http://quickhoney.com~A/~A" 310 image-name (handler-path handler) image-name)) 307 311 (html (:html 308 312 (:head … … 356 360 (cl-gd:destroy-image uploaded-image) 357 361 (setf uploaded-image scaled-image))) 358 (let ((item (make-store-image :name (normalize-news-title title) 359 :image uploaded-image 360 :type (if (cl-gd:true-color-p uploaded-image) :jpg :png) 361 :class-name 'quickhoney-news-item 362 :keywords (list :upload) 363 :initargs (list :cat-sub (list :news) 364 :title title 365 :text text 366 :owner (bknr-session-user))))) 362 (let* ((title (normalize-news-title title)) 363 (item (make-store-image :name title 364 :image uploaded-image 365 :type (if (cl-gd:true-color-p uploaded-image) :jpg :png) 366 :class-name 'quickhoney-news-item 367 :keywords (list :upload) 368 :initargs (list :cat-sub (list :news) 369 :title title 370 :text text 371 :owner (bknr-session-user))))) 367 372 (declare (ignore item)) ; for now 373 (twitter:update-status (bknr-session-user) 374 (format nil "Posted news item: http://quickhoney.com/news/~A" title)) 368 375 (with-http-response () 369 376 (with-http-body () trunk/projects/quickhoney/src/packages.lisp
r3822 r3912 78 78 79 79 (defpackage :twitter 80 (:use :cl )80 (:use :cl :bknr.datastore) 81 81 (:export #:update-status)) trunk/projects/quickhoney/src/quickhoney.asd
r3823 r3912 34 34 (:file "imageproc" :depends-on ("config")) 35 35 (:file "json" :depends-on ("packages")) 36 (:file "twitter" :depends-on ("packages")) 36 37 (:file "handlers" :depends-on ("json" "layout" "config" "image" "news")) 37 38 (:file "tags" :depends-on ("image")) trunk/projects/quickhoney/src/twitter.lisp
r3683 r3912 1 1 (in-package :twitter) 2 2 3 (defparameter *authorization* '("QuickHoneyTest" "autotwitter") 4 "Authorization (USER PASSWORD) to use to identify to twitter") 3 (define-persistent-class account () 4 ((user :read 5 :type bknr.user:user 6 :documentation "USER that this Twitter account belongs to") 7 (authorization :update 8 :documentation "List of username and password for this account"))) 5 9 6 (defun update-status (status-string) 7 (babel:octets-to-string 8 (drakma:http-request "http://twitter.com/statuses/update.xml" 9 :method :post 10 :content (format nil "status=~A" status-string) 11 :content-type "application/x-www-form-urlencoded" 12 :basic-authorization *authorization*))) 10 (define-condition cannot-update-status (error) 11 ((result :initarg :result :reader result))) 12 13 (define-condition no-account-for-user (error) 14 ((user :initarg :user :reader user))) 15 16 (defgeneric update-status (who status-string &key) 17 18 (:method ((account account) status-string &key) 19 (let ((result (babel:octets-to-string 20 (drakma:http-request "http://twitter.com/statuses/update.xml" 21 :method :post 22 :content (format nil "status=~A" status-string) 23 :content-type "application/x-www-form-urlencoded" 24 :basic-authorization (account-authorization account))))) 25 (when (cl-ppcre:scan "<error>" result) 26 (error 'cannot-update-status :result result)))) 27 28 (:method ((user bknr.user:user) status-string &key errorp) 29 (let ((account (find user (class-instances 'account) :key #'account-user))) 30 (if account 31 (update-status account status-string) 32 (when errorp 33 (error 'no-account-for-user :user user)))))) trunk/projects/quickhoney/website/static/javascript.js
r3911 r3912 1 // -*- Java -*- 1 // This may look like -*- Java -*-, but it really is JavaScript 2 3 // Copyright 2005-2008 Hans Huebner, hans.huebner@gmail.com 4 // All rights reserved. 2 5 3 6 /* configuration */
