Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
archimag committed Jul 14, 2009
1 parent 4becb70 commit 09bce2b
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 7 deletions.
63 changes: 63 additions & 0 deletions example/example-1.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
;;; example.lisp

(asdf:operate 'asdf:load-op :restas)
(asdf:operate 'asdf:load-op :xfactory)

(restas:define-plugin :restas.example-1
(:use :cl))

(in-package :restas.example-1)

(defun in-pool (obj)
(gp:object-register obj *request-pool*))

(defparameter *master* "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head >
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />
<title>Welcome</title>
</head>
<body>
<h1>Welcome!</h1>
<div id=\"content\" />
</body>
</html> ")


(define-simple-route main ("" :method :get :overlay-master *master*)
(in-pool
(xfactory:with-document-factory ((html))
(html "overlay"
(html :div
(xfactory:attributes :id "content")
(html :form
(xfactory:attributes :method "post")
(html :div "Input test message:")
(html :input
(xfactory:attributes :name "message"))
(html :input
(xfactory:attributes :value "Send"
:type "submit"))))))))

(define-simple-route main/post ("" :method :post :overlay-master *master*)
(in-pool
(xfactory:with-document-factory ((html))
(html "overlay"
(html :div
(xfactory:attributes :id "content")
(html :div
(html :b "test message: ")
(xfactory:text (hunchentoot:post-parameter "message")))
(html :a
(xfactory:attributes :href "")
"Try again"))))))


(restas:reconnect-all-plugins)
(restas:start-web-server 8080)



12 changes: 12 additions & 0 deletions example/example-2.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;;; example.lisp

(asdf:operate 'asdf:load-op :restas)
(asdf:operate 'asdf:load-op :cl-who)

(restas:define-plugin :restas.example-2
(:use :cl))

(in-package :restas.example-2)

(restas:reconnect-all-plugins)
(restas:start-web-server 8080)
18 changes: 12 additions & 6 deletions src/overlay.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@
(xtree:append-document-property origin :xml-doc-html))
origin)

(defmethod apply-overlay ((origin pathname) overlay bindings)
(apply-overlay (gp:object-register (xtree:parse origin)
*request-pool*)
overlay
bindings))
;; (defmethod apply-overlay ((origin pathname) overlay bindings)
;; (apply-overlay (gp:object-register (xtree:parse origin)
;; *request-pool*)
;; overlay
;; bindings))

;; (defmethod apply-overlay ((origin puri:uri) overlay bindings)
;; (apply-overlay (gp:object-register (xtree:parse origin)
;; *request-pool*)
;; overlay
;; bindings))

(defmethod apply-overlay ((origin puri:uri) overlay bindings)
(defmethod apply-overlay (origin overlay bindings)
(apply-overlay (gp:object-register (xtree:parse origin)
*request-pool*)
overlay
Expand Down
2 changes: 1 addition & 1 deletion src/plugins.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
(set-package-var "*BASEPATH*" ,(cadr (assoc :basepath options)))
(set-package-var "*BASEURL*")
(set-package-var "*DEFAULT-CONTENT-TYPE*" ,(cadr (assoc :default-content-type options)))
(eval `(if (functionp ',(intern "COMPUTE-USER-LOGIN-NAME" package))
(eval `(unless (functionp ',(intern "COMPUTE-USER-LOGIN-NAME" package))
(defun ,(intern "COMPUTE-USER-LOGIN-NAME" package) () nil)))
(setf (gethash ,name *plugins*)
(find-package package))
Expand Down

0 comments on commit 09bce2b

Please sign in to comment.