coleslaw/src/posts.lisp

37 lines
1.3 KiB
Common Lisp
Raw Normal View History

2011-04-16 15:45:37 -04:00
(in-package :coleslaw)
(defparameter *posts* (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)))
(setf (gethash (post-slug post) *posts*) post))))
(maphash #'write-post *posts*))
2011-04-16 15:45:37 -04:00
(defun read-post (stream)
"Make a POST instance based on the data from STREAM."
(make-instance 'post
:slug (make-slug post))
)
2011-04-16 15:45:37 -04:00
(defun write-post (slug post)
"Write out the HTML for POST in SLUG.html."
(render-page (format nil "~a.html" slug)
(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))))