2014-04-28 13:15:36 -04:00
|
|
|
(defpackage :coleslaw-static-pages
|
|
|
|
(:use :cl)
|
|
|
|
(:export #:enable)
|
2014-04-28 13:42:44 -04:00
|
|
|
(:import-from :coleslaw #:*config*
|
2017-05-21 16:24:44 +02:00
|
|
|
#:assert-field
|
2014-04-28 13:42:44 -04:00
|
|
|
#:content
|
2014-04-28 13:15:36 -04:00
|
|
|
#:find-all
|
|
|
|
#:render
|
2014-04-28 13:42:44 -04:00
|
|
|
#:publish
|
2014-04-30 14:30:42 -04:00
|
|
|
#:theme-fn
|
|
|
|
#:render-text
|
2014-04-28 13:42:44 -04:00
|
|
|
#:write-document))
|
2014-04-28 13:15:36 -04:00
|
|
|
|
|
|
|
(in-package :coleslaw-static-pages)
|
|
|
|
|
|
|
|
(defclass page (content)
|
2016-03-20 23:21:29 +01:00
|
|
|
((title :initarg :title :reader coleslaw::title-of)
|
|
|
|
(format :initarg :format :reader coleslaw::page-format))
|
|
|
|
;; default format is markdown (for backward compatibility)
|
2016-04-21 20:10:21 +02:00
|
|
|
(:default-initargs :format :md))
|
2014-04-29 00:20:46 -04:00
|
|
|
|
|
|
|
(defmethod initialize-instance :after ((object page) &key)
|
2017-05-21 16:24:44 +02:00
|
|
|
(assert-field 'title object)
|
|
|
|
(assert-field 'coleslaw::url object)
|
|
|
|
(with-slots (coleslaw::url coleslaw::text format title) object
|
2014-11-09 20:30:38 -05:00
|
|
|
(setf coleslaw::url (make-pathname :defaults coleslaw::url)
|
2016-03-20 23:21:29 +01:00
|
|
|
format (alexandria:make-keyword (string-upcase format))
|
|
|
|
coleslaw::text (render-text coleslaw::text format))))
|
2014-04-28 13:15:36 -04:00
|
|
|
|
2014-04-28 13:42:44 -04:00
|
|
|
(defmethod render ((object page) &key next prev)
|
2014-04-29 00:20:46 -04:00
|
|
|
;; For the time being, we'll re-use the normal post theme.
|
2014-05-06 15:19:26 -04:00
|
|
|
(declare (ignore next prev))
|
2014-04-28 13:15:36 -04:00
|
|
|
(funcall (theme-fn 'post) (list :config *config*
|
|
|
|
:post object)))
|
|
|
|
|
|
|
|
(defmethod publish ((doc-type (eql (find-class 'page))))
|
|
|
|
(dolist (page (find-all 'page))
|
2014-04-28 13:42:44 -04:00
|
|
|
(write-document page)))
|
2014-04-28 13:15:36 -04:00
|
|
|
|
|
|
|
(defun enable ())
|