Browse Source

plugin: static-pages: allow specifying format

`format' in class `page' defaults to markdown to ensure backward
compatibility.
Daniel Kochmański 9 years ago
parent
commit
1c585326ab
1 changed files with 7 additions and 4 deletions
  1. 7 4
      plugins/static-pages.lisp

+ 7 - 4
plugins/static-pages.lisp

13
 (in-package :coleslaw-static-pages)
13
 (in-package :coleslaw-static-pages)
14
 
14
 
15
 (defclass page (content)
15
 (defclass page (content)
16
-  ((title :initarg :title :reader coleslaw::title-of)))
16
+  ((title :initarg :title :reader coleslaw::title-of)
17
+   (format :initarg :format :reader coleslaw::page-format))
18
+  ;; default format is markdown (for backward compatibility)
19
+  (:default-initargs :format "md"))
17
 
20
 
18
 (defmethod initialize-instance :after ((object page) &key)
21
 (defmethod initialize-instance :after ((object page) &key)
19
-  ;; Expect all static-pages to be written in Markdown for now.
20
-  (with-slots (coleslaw::url coleslaw::text) object
22
+  (with-slots (coleslaw::url coleslaw::text format) object
21
     (setf coleslaw::url (make-pathname :defaults coleslaw::url)
23
     (setf coleslaw::url (make-pathname :defaults coleslaw::url)
22
-          coleslaw::text (render-text coleslaw::text :md))))
24
+          format (alexandria:make-keyword (string-upcase format))
25
+          coleslaw::text (render-text coleslaw::text format))))
23
 
26
 
24
 (defmethod render ((object page) &key next prev)
27
 (defmethod render ((object page) &key next prev)
25
   ;; For the time being, we'll re-use the normal post theme.
28
   ;; For the time being, we'll re-use the normal post theme.