From cd86bea65ef609c49748e6de2c4477a74b9a4c87 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Tue, 29 May 2007 12:28:25 +0200 Subject: Implement the :VIEW action. darcs-hash:9d67894b5470b637903527559910e6ffdf456872 --- journal.lisp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'journal.lisp') diff --git a/journal.lisp b/journal.lisp index 89a5fd6..95cfe61 100755 --- a/journal.lisp +++ b/journal.lisp @@ -103,6 +103,10 @@ (call-next-method)) +(defun find-entry (number) + (find number *journal-entries* :key #'id-of)) + + (defun fixup-markdown-output (markup) ;; No, cl-markdown is certainly not perfect. ;; @@ -250,24 +254,36 @@ after another in any arbitrary order." (http-send-headers)) +(defun show-journal-entry (journal-entry) + (<:div :class :journal-entry + (<:h2 (<:as-html (title-of journal-entry))) + (<:div :class :journal-entry-date + (<:as-html + (format-date nil "%@day-of-week, den %day.%mon.%yr, %hr:%min." + (date-of journal-entry)))) + (<:as-is (journal-markup->html (body-of journal-entry))))) + + (defun show-web-journal () (http-add-header "Content-type" "text/html; charset=UTF-8") (http-send-headers) (<:html + (<:head + (<:title + (<:as-html + (if (member *action* '(:view :edit :preview)) + (format nil "~A -- Kompottkins Weisheiten" + (title-of (find-entry *post-number*))) + "Kompottkins Weisheiten")))) (<:body (<:h1 :id :main-title "Kompottkins Weisheiten") (<:div :id :contents - (if (or (null *action*) - (eq *action* :index)) - (dolist (journal-entry *journal-entries*) - (<:div :class :journal-entry - (<:h2 (<:as-html (title-of journal-entry))) - (<:div :class :journal-entry-date - (<:as-html - (format-date nil "%@day-of-week, den %day.%mon.%yr, %hr:%min." - (date-of journal-entry)))) - (<:as-is (journal-markup->html (body-of journal-entry))))))) + (case *action* + ((:index nil) + (mapc #'show-journal-entry *journal-entries*)) + ((:view) + (show-journal-entry (find-entry *post-number*)))))) (<:div :id :navigation) #+debug @@ -280,7 +296,7 @@ after another in any arbitrary order." (<:hr) (<:h2 (<:as-html x)) (<:p "Type " (<:em (<:as-html (type-of y))) ".") - (<:pre (<:as-html (prin1-to-string y)))))))) + (<:pre (<:as-html (prin1-to-string y))))))) (defun main () -- cgit v1.2.3