Permalink
Browse files

reg

  • Loading branch information...
asdr committed Mar 21, 2011
1 parent 562d0ed commit b259358a5f5e146b233b38d5e5df5b85a5a479cd
Showing with 48 additions and 27 deletions.
  1. +27 −0 #misc.lisp#
  2. +1 −1 application-util.lisp
  3. +6 −14 initialize.lisp
  4. +6 −2 misc.lisp
  5. +8 −10 settings.lisp
View
@@ -0,0 +1,27 @@
+(in-package :easyweb)
+
+(defmacro defview (name &key url-pattern (request-type :get) (defun '(() (format nil "default view"))) &allow-other-keys)
+ (if (and (listp url-pattern)
+ (listp (car defun))) ;; the first element of body must include list of arguments
+
+ `(progn
+ ;;define dispatcher function
+ (defun ,name (,@(let ((ret (mapcar #'(lambda(arg)
+ (if (atom arg)
+ arg
+ `(,(car arg) (or (and (boundp 'hunchentoot:*request*)
+ (hunchentoot::compute-parameter (hunchentoot::compute-real-name ',(car arg))
+ 'string
+ ,request-type))
+ ,(cadr arg)))))
+ (car defun))))
+ (when ret
+ (push '&key ret))))
+ ,@(cdr defun))
+
+ ;;export dispatcher function
+ (cl:export ',name)
+
+ ;;map url-pattern to dispatcher function
+ (define-url-patterns ""
+ (,url-pattern ,name ,request-type)))))
View
@@ -55,7 +55,7 @@
name
"."
type)
- easyweb.settings:+default-application-dir+))
+ *template-application-dir*))
(of-path (progn
(when (string= type "asd")
(setf name application-name))
View
@@ -3,21 +3,13 @@
;;ensure ~/*configuration-dir* exists
;;if doesnt exist create and load default setting into it
-(let ((configuration-file-path (probe-file (merge-pathnames "easyweb.conf" easyweb.settings:+configuration-dir+))))
- (unless (cl-fad:directory-exists-p easyweb.settings:+default-application-dir+)
- (when (ensure-directories-exist easyweb.settings:+default-application-dir+)
- (let* ((installation-path (asdf:component-pathname (asdf:find-system :easyweb)))
- (default-application-source (merge-pathnames "template-app/"
- installation-path)))
- (cl-fad:walk-directory default-application-source #'(lambda(file)
- (cl-fad:copy-file file
- (merge-pathnames (concatenate 'string
- (pathname-name file)
- "."
- (pathname-type file))
- easyweb.settings:+default-application-dir+))))))))
+(when (ensure-directories-exist easyweb.settings:*configuration-dir*)
+ (let ((configuration-file-path (probe-file (merge-pathnames "easyweb.conf" easyweb.settings:*configuration-dir*))))
+ (let ((installation-path (asdf:component-pathname (asdf:find-system :easyweb))))
+ (defvar *template-application-dir* (merge-pathnames "template-app/"
+ installation-path)))))
+
-
(setf hunchentoot:*show-lisp-errors-p* t
hunchentoot:*show-lisp-backtraces-p* t)
View
@@ -1,6 +1,10 @@
(in-package :easyweb)
-(defmacro defview (name &key url-pattern (request-type :get) (defun '(() (format nil "default view"))) &allow-other-keys)
+(defmacro defview (name
+ &key url-pattern
+ (request-type :get)
+ (defun '(() (format nil "default view")))
+ &allow-other-keys)
(if (and (listp url-pattern)
(listp (car defun))) ;; the first element of body must include list of arguments
@@ -21,7 +25,7 @@
;;export dispatcher function
(cl:export ',name)
-
+
;;map url-pattern to dispatcher function
(define-url-patterns ""
(,url-pattern ,name ,request-type)))))
View
@@ -2,20 +2,18 @@
(defpackage :easyweb.settings
(:use #:cl)
- (:export #:+configuration-dir+
- #:+default-application-dir+
- #:+template-start-tag+
- #:+template-end-tag+))
+ (:export #:*configuration-dir*
+ #:*template-start-tag*
+ #:*template-end-tag*))
(in-package :easyweb.settings)
-(defconstant +configuration-dir+ (merge-pathnames ".easyweb.d/" (user-homedir-pathname)))
-(defconstant +default-application-dir+ (merge-pathnames "default-application/" +configuration-dir+))
-(defconstant +template-start-tag+ "(%")
-(defconstant +template-end-tag+ "%)")
+(defvar *configuration-dir* (merge-pathnames ".easyweb.d/" (user-homedir-pathname)))
+(defparameter *template-start-tag* "(%")
+(defparameter *template-end-tag* "%)")
;;html-template settings
-(setf html-template:*template-start-marker* +template-start-tag+
- html-template:*template-end-marker* +template-end-tag+)
+(setf html-template:*template-start-marker* *template-start-tag*
+ html-template:*template-end-marker* *template-end-tag*)

0 comments on commit b259358

Please sign in to comment.