diff --git a/plugins/disqus.lisp b/plugins/disqus.lisp index fb7f3d6..ca89f89 100644 --- a/plugins/disqus.lisp +++ b/plugins/disqus.lisp @@ -1,2 +1,27 @@ -(in-package :coleslaw) +(defpackage :coleslaw-disqus + (:use :cl :coleslaw)) +(in-package :coleslaw-disqus) + +;; Should be added to plugins like so: +; :plugins (mathjax (disqus :shortname "mysite-disqus-shortname")) + +(defvar *disqus-header* + "
+ + + comments powered by Disqus") + +(defun enable (&key shortname) + (coleslaw:add-injection (format nil *disqus-header* shortname) :head)) diff --git a/plugins/mathjax.lisp b/plugins/mathjax.lisp index 545e810..360c95d 100644 --- a/plugins/mathjax.lisp +++ b/plugins/mathjax.lisp @@ -14,4 +14,5 @@ src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"> ") -(coleslaw:add-injection *mathjax-header* :head) +(defun enable () + (coleslaw:add-injection *mathjax-header* :head)) diff --git a/src/config.lisp b/src/config.lisp index faa5de6..cfb444d 100644 --- a/src/config.lisp +++ b/src/config.lisp @@ -16,16 +16,24 @@ (defparameter *config* nil "A variable to store the blog configuration and plugin settings.") +(defun enable-plugin (file &rest args) + "Given a path to a plugin, FILE, compile+load it, then call its ENABLE function." + (compile-file file) + (load file) + (let* ((pkgname (format nil "coleslaw-~a" (pathname-name file))) + (plugin-pkg (find-package (string-upcase pkgname)))) + (apply (find-symbol "ENABLE" plugin-pkg) args))) + (defun load-plugins (plugins) - "Resolve the path of each symbol in PLUGINS and call LOAD on the -resulting pathnames. It is expected that the matching *.lisp files + "Compile and load the listed PLUGINS. It is expected that matching *.lisp files are in the plugins folder in coleslaw's source directory." - (let ((files (mapcar (lambda (sym) - (app-path "plugins/~a" (string-downcase (symbol-name sym)))) - plugins))) - (map nil (lambda (file) - (compile-file file) - (load file)) files))) + (flet ((plugin-path (name) + (app-path "plugins/~a" (string-downcase (symbol-name sym))))) + (dolist (plugin plugins) + (etypecase plugin + (list (destructuring-bind (name &rest args) plugin + (apply 'enable-plugin (plugin-path name) args))) + (symbol (enable-plugin (plugin-path plugin))))))) (defun load-config (&optional (dir (user-homedir-pathname))) "Load the coleslaw configuration from DIR/.coleslawrc. DIR is ~ by default."