Navigation Menu

Skip to content

Commit

Permalink
made a change to "caveman.project:build" (backward incompatible!).
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Mar 25, 2012
1 parent 2bc01c8 commit 4183bad
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 42 deletions.
3 changes: 2 additions & 1 deletion skeleton/skeleton.asd
Expand Up @@ -24,7 +24,8 @@
:depends-on (:clack :depends-on (:clack
:caveman :caveman
:cl-syntax :cl-syntax
:cl-syntax-annot) :cl-syntax-annot
:cl-ppcre)
:components ((:module "lib" :components ((:module "lib"
:components :components
((:module "view" ((:module "view"
Expand Down
23 changes: 17 additions & 6 deletions skeleton/src/skeleton.lisp
Expand Up @@ -5,7 +5,10 @@


(clack.util:namespace <% @var name %> (clack.util:namespace <% @var name %>
(:use :cl (:use :cl
:clack) :clack
:clack.builder
:clack.middleware.static
:clack.middleware.session)
(:shadow :stop) (:shadow :stop)
(:import-from :caveman (:import-from :caveman
:config) :config)
Expand All @@ -17,7 +20,10 @@
(:import-from :clack.builder (:import-from :clack.builder
:*builder-lazy-p*) :*builder-lazy-p*)
(:import-from :<% @var name %>.app (:import-from :<% @var name %>.app
:*app*)) :*app*)
(:import-from :cl-ppcre
:scan
:regex-replace))


(cl-syntax:use-syntax :annot) (cl-syntax:use-syntax :annot)


Expand All @@ -27,10 +33,15 @@
@export @export
(defvar *project* nil) (defvar *project* nil)


(defmethod build ((this <<% @var name %>>) &optional app) (defmethod build ((this <<% @var name %>>))
@ignore app (builder
(call-next-method (<clack-middleware-static>
this :path (lambda (path)
(when (ppcre:scan "^(?:/static/|/images/|/css/|/js/|/robot\\.txt$|/favicon.ico$)" path)
(ppcre:regex-replace "^/static" path "")))
:root (merge-pathnames (config :static-path)
(config :application-root)))
<clack-middleware-session>
<% @var name %>.app:*app*)) <% @var name %>.app:*app*))


@export @export
Expand Down
14 changes: 11 additions & 3 deletions src/core/app.lisp
Expand Up @@ -8,7 +8,8 @@


(clack.util:namespace caveman.app (clack.util:namespace caveman.app
(:use :cl (:use :cl
:clack) :clack
:caveman.middleware.context)
(:import-from :clack.util.route (:import-from :clack.util.route
:match) :match)
(:import-from :caveman.context (:import-from :caveman.context
Expand All @@ -27,9 +28,16 @@
:accessor routing-rules)) :accessor routing-rules))
(:documentation "Base class for Caveman Application. All Caveman Application must inherit this class.")) (:documentation "Base class for Caveman Application. All Caveman Application must inherit this class."))


(defmethod call ((this <app>) req) (defmethod call :around ((this <app>) env)
(call (wrap
(make-instance '<caveman-middleware-context>)
(lambda (env)
(call-next-method this env)))
env))

(defmethod call ((this <app>) env)
"Overriding method. This method will be called for each request." "Overriding method. This method will be called for each request."
@ignore req @ignore env
(let* ((req *request*) (let* ((req *request*)
(path-info (path-info req)) (path-info (path-info req))
(method (request-method req))) (method (request-method req)))
Expand Down
35 changes: 3 additions & 32 deletions src/core/project.lisp
Expand Up @@ -10,17 +10,8 @@
(:use :cl (:use :cl
:anaphora :anaphora
:clack :clack
:clack.builder :clack.builder)
:clack.middleware.static
:clack.middleware.session
:caveman.middleware.context)
(:shadow :stop) (:shadow :stop)
(:import-from :local-time
:format-timestring
:now)
(:import-from :cl-ppcre
:scan
:scan-to-strings)
(:import-from :cl-fad (:import-from :cl-fad
:file-exists-p) :file-exists-p)
(:import-from :caveman.context (:import-from :caveman.context
Expand All @@ -45,28 +36,8 @@
:accessor project-mode))) :accessor project-mode)))


@export @export
(defmethod build ((this <project>) &optional app) (defgeneric build (project)
(builder (:documentation "Build up an application for this project and return it. This method must be implemented in subclasses."))
(clack.middleware.logger:<clack-middleware-logger>
:logger (make-instance 'clack.logger.file:<clack-logger-file>
:output-file
(merge-pathnames
(local-time:format-timestring nil
(local-time:now)
:format
'("log-" (:year 4) (:month 2) (:day 2)))
(merge-pathnames
(getf (config this) :log-path)
(getf (config this) :application-root)))))
(<clack-middleware-static>
:path (lambda (path)
(when (ppcre:scan "^(?:/static/|/images/|/css/|/js/|/robot\\.txt$|/favicon.ico$)" path)
(ppcre:regex-replace "^/static" path "")))
:root (merge-pathnames (getf (config this) :static-path)
(getf (config this) :application-root)))
<clack-middleware-session>
<caveman-middleware-context>
app))


(defun slurp-file (path) (defun slurp-file (path)
"Read a specified file and return the content as a sequence." "Read a specified file and return the content as a sequence."
Expand Down

0 comments on commit 4183bad

Please sign in to comment.