summaryrefslogtreecommitdiff
path: root/journal-content.lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-06-30 21:40:27 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-06-30 21:40:27 +0200
commitf262befd1591052f273055a3b1e80aa0d62e3814 (patch)
treed2c1e3ac3594ffa74538dc23bca6dc3f50108626 /journal-content.lisp
parentc74c449d11281c942965ca85d84c59b9107e4521 (diff)
Cache FORMAT-DATE results for faster page generation.
darcs-hash:2efe2fb7b5c7637c31d56be210624a48f61755ec
Diffstat (limited to 'journal-content.lisp')
-rw-r--r--journal-content.lisp55
1 files changed, 50 insertions, 5 deletions
diff --git a/journal-content.lisp b/journal-content.lisp
index c914269..12ff5a3 100644
--- a/journal-content.lisp
+++ b/journal-content.lisp
@@ -143,11 +143,56 @@
(apply #'make-instance 'journal-entry :file filename data)))))
+(defun find-journal-entry-files ()
+ (let ((journal-entry-files (list)))
+ (when (file-exists-p *entry-dir*)
+ (walk-directory *entry-dir*
+ #'(lambda (x)
+ (push x journal-entry-files))
+ :test (complement #'directory-pathname-p)))
+ journal-entry-files))
+
+
+(defun read-journal-entries ()
+ (let ((journal-entry-files (find-journal-entry-files)))
+ (sort (mapcar #'read-journal-entry journal-entry-files)
+ #'>=
+ :key #'id-of)))
+
+
(defun compute-journal-last-modified-date ()
#-clisp (get-universal-time)
#+clisp
- (loop for file in (list* *script-filename* ;; journal.cgi
- (merge-pathnames (make-pathname :type "lisp")
- *script-filename*) ;; journal.lisp
- (find-journal-entry-files))
- maximize (posix:file-stat-mtime (posix:file-stat file))))
+ (max (compute-script-last-modified-date)
+ (loop for file in (find-journal-entry-files)
+ maximize (posix:file-stat-mtime (posix:file-stat file)))))
+
+
+(defun write-out-entry (entry)
+ (assert (file-of entry))
+ (with-open-file (out (file-of entry) :direction :output
+ :if-exists :supersede
+ :external-format #+clisp charset:utf-8
+ #+sbcl :utf-8)
+ (with-slots (id uuid date last-modification body title categories comments)
+ entry
+ (write `(:id ,id
+ :uuid ,uuid
+ :date ,date
+ :last-modification ,last-modification
+ :title ,title
+ :categories ,categories
+ :body ,body
+ :comments ,(loop for comment in comments
+ collect
+ (with-slots (id uuid date author body email
+ website)
+ comment
+ `(:id ,id
+ :uuid ,uuid
+ :date ,date
+ :author ,author
+ :email ,email
+ :website ,website
+ :body ,body))))
+ :stream out))))