Browse files

update

  • Loading branch information...
1 parent 4becb70 commit 09bce2b74755c10314d1f40f928fc5193b5d0e55 @archimag committed Jul 14, 2009
Showing with 88 additions and 7 deletions.
  1. +63 −0 example/example-1.lisp
  2. +12 −0 example/example-2.lisp
  3. +12 −6 src/overlay.lisp
  4. +1 −1 src/plugins.lisp
View
63 example/example-1.lisp
@@ -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)
+
+
+
View
12 example/example-2.lisp
@@ -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)
View
18 src/overlay.lisp
@@ -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
View
2 src/plugins.lisp
@@ -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))

0 comments on commit 09bce2b

Please sign in to comment.