Sfoglia il codice sorgente

Cleanup plugin loading.

Brit Butler 11 anni fa
parent
commit
1ea73feab7
1 ha cambiato i file con 13 aggiunte e 12 eliminazioni
  1. 13 12
      src/config.lisp

+ 13 - 12
src/config.lisp

@@ -19,23 +19,24 @@
19 19
 (defparameter *config* nil
20 20
   "A variable to store the blog configuration and plugin settings.")
21 21
 
22
-(defun enable-plugin (file &rest args)
23
-  "Given a path to a plugin, FILE, compile+load it, then call its ENABLE function."
24
-  (compile-file file)
25
-  (load file)
26
-  (let* ((pkgname (format nil "coleslaw-~a" (pathname-name file)))
27
-         (plugin-pkg (find-package (string-upcase pkgname))))
28
-    (apply (find-symbol "ENABLE" plugin-pkg) args)))
22
+(defun enable-plugin (name args)
23
+  "Given a plugin, NAME, compile+load it and call its ENABLE function with ARGS."
24
+  (flet ((plugin-path (sym)
25
+           (app-path "plugins/~(~A~)" sym))
26
+         (plugin-package (sym)
27
+           (format nil "~:@(coleslaw-~A~)" sym)))
28
+    (let ((file (plugin-path name)))
29
+      (load (compile-file file :verbose nil :print nil) :verbose t))
30
+    (let ((package (find-package (plugin-package name))))
31
+      (apply (find-symbol "ENABLE" package) args))))
29 32
 
30 33
 (defun load-plugins (plugins)
31 34
   "Compile and load the listed PLUGINS. It is expected that matching *.lisp files
32 35
 are in the plugins folder in coleslaw's source directory."
33 36
   (setf *injections* nil)
34
-  (flet ((plugin-path (sym)
35
-           (app-path "plugins/~a" (string-downcase (symbol-name sym)))))
36
-    (dolist (plugin plugins)
37
-      (destructuring-bind (name &rest args) plugin
38
-        (apply 'enable-plugin (plugin-path name) args)))))
37
+  (dolist (plugin plugins)
38
+    (destructuring-bind (name &rest args) plugin
39
+      (enable-plugin name args))))
39 40
 
40 41
 (defun discover-config-path (repo-path)
41 42
   "Check the supplied REPO-PATH for a .coleslawrc and if one