Update plugins for new API.

This commit is contained in:
Brit Butler 2012-09-15 17:30:26 -04:00
parent cc82da57cd
commit 97749261db
3 changed files with 17 additions and 9 deletions

View file

@ -3,9 +3,6 @@
(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\">
@ -24,4 +21,5 @@
<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))
(coleslaw:add-injection (list (format nil *disqus-header* shortname)
(lambda (x) (typep x post))) :head))

View file

@ -53,8 +53,12 @@
(format out "~A~%" (regex-replace-all (string #\Newline) content "<br>"))))
(defun import-posts (filepath &optional since)
(let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
(posts (dom:get-elements-by-tag-name xml "item")))
(load-config)
(when (probe-file filepath)
(ensure-directories-exist (repo *config*))
(loop for post across posts do (import-post post since))))
(let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
(posts (dom:get-elements-by-tag-name xml "item")))
(loop for post across posts do (import-post post since))
(delete-file filepath))))
(defun enable (&key filepath)
(import-posts filepath))

View file

@ -15,4 +15,10 @@ src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLor
</script>")
(defun enable ()
(coleslaw:add-injection *mathjax-header* :head))
(labels ((math-post-p (post)
(member "math" (post-tags post) :test #'string=))
(mathjax-p (content)
(etypecase content
(post (math-post-p content))
(index (some #'math-post-p (index-posts content))))))
(coleslaw:add-injection (list *mathjax-header* #'mathjax-p) :head)))