Commits

Anonymous committed d560e7a

Standardized declaration of templates and servers, in preparation for more dynamic reloading

Comments (0)

Files changed (3)

 	       (:file "services")
 	       (:file "urls")
 	       (:file "cache")
+	       (:file "server")
 	       )
   :depends-on (
 	       ; external packages

taglibraries.lisp

   '*tag-library*
   '*tag-library-provider-registry*
   'create-folder-tag-library-provider
-
+  'create-asdf-system-tag-library-provider
 
   'in-tag-library
   'use-tag-library
   (make-instance 'folder-tag-library-provider :folder folder)
   )
 
+(defun create-asdf-system-tag-library-provider (system)
+  (make-instance 'folder-tag-library-provider 
+		 :folder (asdf:system-relative-pathname 
+					(asdf:find-system system) 
+					(make-pathname :directory `(:relative "taglibraries") )
+					)
+		 )
+  )
+
+
 ; -- Implementation of base tag-library-provider functions
 
 (defmethod provider-tag-library-expiredp (library (provider folder-tag-library-provider) )
 
   'template
   'deftemplate
+  'deftemplates
   '*template*
   '*template-provider-registry*
   'create-folder-template-provider
   (:method ( (tmpl template) )
     (when (template-stalep tmpl)
       (or (template-tags-expiredp tmpl)
+	  (not (slot-boundp tmpl 'provider) )
 	  (provider-template-expiredp tmpl (template-provider tmpl) )
 	  )
       )
 )
 
 (defmethod template-provider-base-directory ( (provider asdf-system-provider) )
-  (asdf:system-relative-pathname (system-of provider) "templates/")
+  (asdf:system-relative-pathname (system-of provider) (make-pathname :directory `(:relative "templates")) )
   )
 
 (defun create-asdf-system-template-provider (system)
      )
   )
 
+(defun local-template-provider-registry-symbol () 
+  "Returns a symbol in the current package for storing the template provider registry expected by the package"
+  (intern "*PACKAGE-TEMPLATE-PROVIDER-REGISTRY*" *package*) 
+  )
+
+(defun local-tag-library-provider-registry-symbol () 
+  "Returns a symbol in the current package for storing the tag library provider registry expected by the package"
+  (intern "*PACKAGE-TAG-LIBRARY-PROVIDER-REGISTRY*" *package*) 
+  )
+
+(defmacro deftemplates (
+			&key
+			((:tag-library-packages tag-library-packages) nil)
+			((:template-packages template-packages) nil)
+			((:templates templates) nil)
+			)
+  (let (
+	(template-provider-registry (local-template-provider-registry-symbol) )
+	(tag-library-provider-registry (local-tag-library-provider-registry-symbol) )
+	)
+    `(progn
+       (defparameter ,template-provider-registry
+	 (list ,@(append (mapcar (lambda (template-package)
+				   `(create-asdf-system-template-provider (quote ,template-package))
+				   )
+				 template-packages
+				 )
+			 (list `(create-asdf-system-template-provider 'hh-web ) ) ;; always here by default
+			 )
+	       )
+	 )
+
+       (defparameter ,tag-library-provider-registry
+	 (list ,@(append (mapcar (lambda (tag-library-package)
+				   `(create-asdf-system-tag-library-provider (quote ,tag-library-package) )
+				   )
+			       tag-library-packages
+			       )
+		       (list `(create-asdf-system-tag-library-provider 'hh-web ) ) ;; always here by default
+		       ) 
+	     )
+       )
+
+       (let (
+	     (*tag-library-provider-registry* ,tag-library-provider-registry)
+	     (*template-provider-registry* ,template-provider-registry)
+	     )
+	 ,@(mapcar (lambda (template)
+		     `(deftemplate ,@template)
+		     )
+		   templates
+		   )
+	 )
+     )
+  )
+  )
+
 ;;;------------------------------------------------------------------------------------
 ;;;  Tag library use in templates
 ;;;