Skip to content
Browse files

.

  • Loading branch information...
1 parent 2eb266c commit 59c265dd8c80244e462d851edca15888d522cbeb asdr the admin committed
Showing with 26 additions and 78 deletions.
  1. +21 −65 easyweb.lisp
  2. +1 −10 html.lisp
  3. +4 −3 prototype-app1/_settings.lisp
View
86 easyweb.lisp
@@ -7,67 +7,23 @@
(in-package :easyweb)
-;;static file dispatcher?
-;;regex dispatcher?
-;;prefix dispatcher?
-;;folder dispatcher?
-;;
-;;GET and POST parameter pass??????
-#|(defmacro map-urls (prefix &body mappings)
- (format t "~%~%URL Mapping")
- (and (every #'listp (mapcar #'identity mappings))
- (not (setf *dispatch-table* nil))
- (mapc #'(lambda(m)
- (destructuring-bind (pattern . view) m
- (format t "~%~S..::..~S" pattern view)
- (push (create-regex-dispatcher (format nil "~A~A" prefix pattern)
- view)
- *dispatch-table*)))
- mappings)))
-
-(defun mapping (prefix &rest mappings)
- (labels ((destruct-mapping (lst)
- ;(format t "~A" lst)))
- (destructuring-bind ((pattern pattern-type) (view params)) lst
- (case pattern-type
- (:file
- (format t "file")
- )
- (:folder
- (format t "folder")
- )
- (:prefix
- (format t "prefix")
- (push (create-prefix-dispatcher (format nil "~A~A" prefix pattern)
- view)
- *dispatch-table*))
- (:regex
- (format t "~%~S..::..~S" pattern view)
- (push (create-regex-dispatcher (format nil "~A~A" prefix pattern)
- view)
- *dispatch-table*)))
- )))
- (setf *dispatch-table* nil)
- (mapc #'destruct-mapping mappings)))|#
-
(defun get-lambda-list (fn)
;;may be platform dependent code
;;but i still need it
;;return the parameter list of given function
-(let ((ns (easyweb.html::empty-string))
- (lambda-list nil))
- (with-output-to-string (stream ns)
- (let ((*standard-output* stream))
- (describe fn)))
- (with-input-from-string (str ns)
- (do ((line (read-line str nil 'eof) (read-line str nil 'eof)))
- ((eq line 'eof) lambda-list)
- (let ((start (search "Lambda-list: " line :test #'string=)))
- (when start
- (setf lambda-list (subseq line (+ start
- (length "Lambda-list: "))))))))
- lambda-list))
-
+ (let ((ns (dsgner::empty-string))
+ (lambda-list nil))
+ (with-output-to-string (stream ns)
+ (let ((*standard-output* stream))
+ (describe fn)))
+ (with-input-from-string (str ns)
+ (do ((line (read-line str nil 'eof) (read-line str nil 'eof)))
+ ((eq line 'eof) lambda-list)
+ (let ((start (search "Lambda-list: " line :test #'string=)))
+ (when start
+ (setf lambda-list (subseq line (+ start
+ (length "Lambda-list: "))))))))
+ lambda-list))
(defmacro map-urls (prefix &body body)
`(progn
@@ -76,19 +32,19 @@
(type (car uri-part))
(uri nil))
(case type
- ((:regex :prefix :file :folder)
- (let* ((handler (cadr mapping))
- (args (get-lambda-list handler))
+ (:regex "regular exp.")
+ (:prefix "prefix")
+ (:file "file-")
+ (:folder "folder")
+ (otherwise
+ (let* ((handler (cadr mapping))
+ (args nil #|(get-lambda-list handler)|#)
(uri (format nil "~A~A" prefix (cadr uri-part))))
`(define-easy-handler (,(gensym) :uri ,uri)
,args
(,handler ,@(mapcan #'(lambda (arg)
`(,(hunchentoot::convert-parameter (string-downcase arg) 'keyword) ,arg))
- args)))))
- (:prefix "prefix")
- (:file "file-")
- (:folder "folder")
- (otherwise "other"))))
+ args))))))))
body)))
(defun start-server (&key (port 8000))
View
11 html.lisp
@@ -2,16 +2,7 @@
(in-package :common-lisp-user)
(defpackage :easyweb.html
- (:use #:cl #:dsgner)
- (:export #|#:a #:abbr #:acronym #:address #:applet #:b #:base #:basefont
- #:bdo #:big #:blockquote #:body #:br #:button #:caption #:center #:cite
- #:code #:col #:colgroup #:dd #:del #:dfn #:dir #:div #:dl #:dt #:em #:fieldset
- #:font #:form #:frame #:frameset #:h1 #:h2 #:h3 #:h4 #:h5 #:h6 #:head #:hr
- #:html #:i #:iframe #:img #:input #:ins #:isindex #:kbd #:label #:legend #:li
- #:link #:map #:menu #:meta #:noframes #:noscript #:object #:ol #:optgroup
- #:option #:p #:param #:pre #:q #:s #:samp #:script #:select #:small #:span
- #:strike #:strong #:style #:sub #:sup #:table #:tbody #:td #:textarea #:tfoot
- #:th #:thead #:title #:tr #:tt #:u #:ul #::var #:xmp #:doctype #:<!--|#))
+ (:use #:cl #:dsgner))
(in-package :easyweb.html)
View
7 prototype-app1/_settings.lisp
@@ -10,8 +10,9 @@
;;url dispatching should occur here
(map-urls "/"
- ((:regex "asdr") open-link)
- ((:prefix "serdar") mervecigim)
- ((:prefix "merve") mervecigim)
+ ((:std "") index-page)
+ ((:std "asdr") open-link)
+ ((:std "serdar") mervecigim)
+ ((:std "merve") mervecigim)
((:file "tmp/fileX" "/home/admin-o/pjs/easyweb/tmp/filex.x" "text/plain"))
((:folder "tmp/" "/home/asdr/admin-o/pjs/easyweb/" "text/plain")))

0 comments on commit 59c265d

Please sign in to comment.
Something went wrong with that request. Please try again.