2009/09/05

teepeedee2

teepeedee2 をちょこっと動かしてみた。

(eval-when (:compile-toplevel :load-toplevel :execute)
(require :teepeedee2))

(defpackage :try-teepeedee2
(:use :cl :tpd2 :tpd2.ml.html))

(in-package :try-teepeedee2)

(defpage
"/hello" ; URL
((name "Friend")) ; リクエストパラメータ
(values ; ボディとヘッダの多値を返す
(<html ; タグはマクロ
(<body
(<h1 "こんにちは " name)
(<div "まみむめも♪")))
(byte-vector-cat ; ヘッダはバイトベクタで返す
tpd2.webapp::+http-header-html-content-type+ ; "Content-Type: text/html;charset=utf-8"
"Xxx: Aaa" tpd2.io:+newline+))) ; 他のヘッダも付けるときはこんなふう

(defun start ()
"Visit http://localhost:8080/hello"
(http-start-server 8080)
(sb-thread:make-thread #'event-loop :name "tpd2"))
;;(start)

私の環境は clbulid で用意しているため、いくつかのライブラリてバージョンがあってなかった模様。以下のように適当にソースをいじった。


diff --git a/src/lib/utils.lisp b/src/lib/utils.lisp
index f937fe0..6e5f718 100644
--- a/src/lib/utils.lisp
+++
b/src/lib/utils.lisp
@@ -49,5 +49,6 @@
(with-input-from-string (*standard-input* (force-string string)) (read-safely)))

(defun backtrace-description (err)
- (format nil "ERROR ~A:~&~A" (with-output-to-string (*standard-output*) (describe err))
- (trivial-backtrace:backtrace-string)))
+ (format nil "ERROR ~A:~&~A" (with-output-to-string (*standard-output*) (describe err))
+ (with-output-to-string (out)
+ (trivial-backtrace:print-backtrace-to-stream out))))
diff --git a/src/webapp/default-site.lisp b/src/webapp/default-site.lisp
index 2d8fc33..ac3a660 100644
--- a/src/webapp/default-site.lisp
+++
b/src/webapp/default-site.lisp
@@ -3,3 +3,4 @@
(defsite *default-site*)
(setf *current-site* *default-site*)

+
\ No newline at end of file
diff --git a/src/webapp/js-library.lisp b/src/webapp/js-library.lisp
index 9a1899f..05aa768 100644
--- a/src/webapp/js-library.lisp
+++
b/src/webapp/js-library.lisp
@@ -50,7 +50,7 @@

(defun channels-get-param ()
(let ((lines (make-array)))
- (ps:doeach (channel *channels*)
+ (ps:dolist (channel *channels*)
(lines.push (+ (encode-U-R-I-component channel) "|" (aref *channels* channel))))
(return (+ ".channels.=" (lines.join ";")))))

0 件のコメント: