Bugfixes to sitemaps, mathjax, and posts.

This commit is contained in:
Brit Butler 2014-05-16 09:52:04 -04:00
parent 414b221e6b
commit f58c265fb7
3 changed files with 23 additions and 16 deletions

View file

@ -14,15 +14,16 @@
</script>~]
<script type=\"text/javascript\" src=\"~A~@[?config=~A~]\"></script>")
(defgeneric mathjax-p (document)
(:documentation "Test if DOCUMENT requires contains any math-tagged content.")
(:method ((content content))
(tag-p "math" content))
(:method ((index index))
(and (slot-boundp index 'content)
(some #'mathjax-p (index-content index)))))
(defun enable (&key force config (preset "TeX-AMS-MML_HTMLorMML")
(location "http://cdn.mathjax.org/mathjax/latest/MathJax.js"))
(labels ((math-post-p (obj)
;; Would it be better to test against latex than math, here?
(tag-p "math" obj))
(mathjax-p (obj)
(or force
(etypecase obj
(content (math-post-p obj))
(index (some #'math-post-p (index-content obj)))))))
(flet ((plugin-p (x) (or force (mathjax-p x))))
(let ((mathjax-header (format nil *mathjax-header* config location preset)))
(add-injection (list mathjax-header #'mathjax-p) :head))))
(add-injection (list mathjax-header #'plugin-p) :head))))

View file

@ -2,9 +2,12 @@
(:use :cl)
(:import-from :coleslaw #:*config*
#:index
#:deploy
#:page-url
#:find-all
#:discover
#:publish
#:theme-fn
#:add-document
#:write-document)
(:import-from :alexandria #:hash-table-values)
(:export #:enable))
@ -16,11 +19,13 @@
(defmethod page-url ((object sitemap)) "sitemap.xml")
(defmethod deploy :before (staging)
"Render sitemap.xml under document root."
(declare (ignore staging))
(let* ((urls (mapcar #'page-url (hash-table-values coleslaw::*site*)))
(sitemap (make-instance 'sitemap :urls (append '("" "sitemap.xml") urls))))
(defmethod discover ((doc-type (eql (find-class 'sitemap))))
(let ((base-urls '("" "sitemap.xml"))
(urls (mapcar #'page-url (hash-table-values coleslaw::*site*))))
(add-document (make-instance 'sitemap :urls (append base-urls urls)))))
(defmethod publish ((doc-type (eql (find-class 'sitemap))))
(dolist (sitemap (find-all 'sitemap))
(write-document sitemap (theme-fn 'sitemap "sitemap"))))
(defun enable ())

View file

@ -3,7 +3,8 @@
(defclass post (content)
((title :initarg :title :reader title-of)
(author :initarg :author :accessor author-of)
(format :initarg :format :accessor post-format)))
(format :initarg :format :accessor post-format))
(:default-initargs :author nil))
(defmethod initialize-instance :after ((object post) &key)
(with-accessors ((title title-of)