Add Disqus plugin and modify plugins to allow argument passing.
This commit is contained in:
parent
2b0c0e3925
commit
395897e758
3 changed files with 44 additions and 10 deletions
|
@ -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*
|
||||
"<div id=\"disqus_thread\"></div>
|
||||
<script type=\"text/javascript\">
|
||||
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
||||
var disqus_shortname = '~a';
|
||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||
(function() {
|
||||
var dsq = document.createElement('script');
|
||||
dsq.type = 'text/javascript';
|
||||
dsq.async = true;
|
||||
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
})();
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href=\"http://disqus.com/?ref_noscript\">comments powered by Disqus.</a></noscript>
|
||||
<a href=\"http://disqus.com\" class=\"dsq-brlink\">comments powered by <span class=\"logo-disqus\">Disqus</span></a>")
|
||||
|
||||
(defun enable (&key shortname)
|
||||
(coleslaw:add-injection (format nil *disqus-header* shortname) :head))
|
||||
|
|
|
@ -14,4 +14,5 @@
|
|||
src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">
|
||||
</script>")
|
||||
|
||||
(coleslaw:add-injection *mathjax-header* :head)
|
||||
(defun enable ()
|
||||
(coleslaw:add-injection *mathjax-header* :head))
|
||||
|
|
|
@ -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."
|
||||
|
|
Loading…
Add table
Reference in a new issue