2011-04-16 15:45:37 -04:00
|
|
|
(in-package :coleslaw)
|
|
|
|
|
2012-08-20 11:06:35 -04:00
|
|
|
(defparameter *posts* (make-hash-table :test #'equal))
|
2011-04-16 15:45:37 -04:00
|
|
|
|
2012-08-20 10:44:46 -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
|
|
|
|
2012-08-20 10:44:46 -04:00
|
|
|
(defun render-posts ()
|
|
|
|
(do-files (file (repo *config*) "post")
|
|
|
|
(with-open-file (in file)
|
|
|
|
(let ((post (read-post in)))
|
2012-08-20 11:06:35 -04:00
|
|
|
(setf (gethash (post-slug post) *posts*) post))))
|
|
|
|
(maphash #'write-post *posts*))
|
2011-04-16 15:45:37 -04:00
|
|
|
|
2012-08-20 10:44:46 -04:00
|
|
|
(defun read-post (stream)
|
|
|
|
"Make a POST instance based on the data from STREAM."
|
2012-08-20 11:06:35 -04:00
|
|
|
(make-instance 'post
|
|
|
|
:slug (make-slug post))
|
2012-08-20 10:44:46 -04:00
|
|
|
)
|
2011-04-16 15:45:37 -04:00
|
|
|
|
2012-08-20 10:44:46 -04:00
|
|
|
(defun write-post (slug post)
|
|
|
|
"Write out the HTML for POST in SLUG.html."
|
2012-08-20 11:06:35 -04:00
|
|
|
(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))))
|