Source of Nothingness - 2006-02-09

* 2006-02-09

;;; RandomNote投稿
(require "junk/http")

(in-package "junk")

(defvar *rn-url* "http://raido.sakura.ne.jp/southly/rn/index.rb")

(defun rn-post (url str)
  (let (http)
    (multiple-value-bind (proto host file anchor port)
        (junk-http-url-study url)
      (unless (string= proto "http")
        (junk-error "Protocol is not http: ~A" url))
      (unwind-protect
          (multiple-value-prog1
           (setq http (junk-http-request-send host file "POST" :data (format nil "cmd=edit_do&fname=&mes=~A" (si:www-url-encode str nil "0-9A-Za-z"))))
           ; 結果確認するならここ
           (and http (close http)))
        (close http :abort t)))))

(defun user::rn-post-region (beg end)
  (interactive "r")
  (rn-post *rn-url* (buffer-substring beg end)))

ということでできたRandomNote投稿Lisp。
xyzzyからM-x rn-post-regionで投稿します。
編集とか削除はしない方針なので作る予定はありません。

with-open-streamを見てちょっと修正。
一応closeしたほうがいいんだっけ?

update : 2006-02-09 (Thu) 00:00:00