From f262befd1591052f273055a3b1e80aa0d62e3814 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sat, 30 Jun 2007 21:40:27 +0200 Subject: Cache FORMAT-DATE results for faster page generation. darcs-hash:2efe2fb7b5c7637c31d56be210624a48f61755ec --- journal-content.lisp | 55 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'journal-content.lisp') 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)))) -- cgit v1.2.3