coleslaw/src/posts.lisp

39 lines
1.4 KiB
Common Lisp
Raw Normal View History

2011-04-16 15:45:37 -04:00
(in-package :coleslaw)
(defparameter *metadata* (make-hash-table :test #'equal))
2011-04-16 15:45:37 -04:00
(defclass post ()
((slug :initform nil :initarg :slug :accessor post-slug)
(title :initform nil :initarg :title :accessor post-title)
(tags :initform nil :initarg :tags :accessor post-tags)
(date :initform nil :initarg :date :accessor post-date)
(format :initform nil :initarg :format :accessor post-format)
(content :initform nil :initarg :content :accessor post-content)
(aliases :initform nil :initarg :aliases :accessor post-aliases)))
2011-04-16 15:45:37 -04:00
(defun render-posts ()
(do-files (file (repo *config*) "post")
(with-open-file (in file)
(let ((post (read-post in)))
2012-08-20 10:46:24 -04:00
(setf (gethash (post-slug post) *metadata*) post))))
(maphash #'write-post *metadata*))
2011-04-16 15:45:37 -04:00
(defun read-post (stream)
"Make a POST instance based on the data from STREAM."
2011-04-16 15:45:37 -04:00
)
2011-04-16 15:45:37 -04:00
(defun write-post (slug post)
"Write out the HTML for POST in SLUG.html."
(with-open-file (out (format nil "~a.html" slug)
:direction :output
:if-does-not-exist :create)
(let ((content (funcall (theme-fn "POST")
(list :title (post-title post)
:tags (post-tags post)
:date (post-date post)
:content (post-content post)
:prev nil
:next nil))))
(write content out))))