Commit 250594c5 authored by Erik Huelsmann's avatar Erik Huelsmann

Retain the original filename for LHTML pages

Note that the LHTML preprocessor is now converted to an 'around method'-like
concept which passes content and context from one around processor to another.

Around processors may elect to pre- or post-process.
parent 246f5da9
......@@ -7,10 +7,6 @@
(format t "Generating site in ~A.~%" *output-dir*)
(process-static *static-dir* *output-dir*)
(process-static (merge-pathnames #P"static/" *layout-dir*) *output-dir*)
(let ((pages (populate-pages)))
(format t "Preprocessing LHTML pages..~%")
(dolist (page pages)
(preprocess-lisp-page page)))
(dolist (page (populate-pages))
......@@ -27,7 +23,8 @@
using (hash-value v)
collect (cons k v))))))
(preprocess-md-page (format nil "~{~A~%~}" content) page-context
(list (lambda (page context next-processors)
(list #'preprocess-lisp-page
(lambda (page context next-processors)
(process-page page context))))))))))
......@@ -69,21 +69,24 @@
(cl-markdown:markdown content :stream out))))
(funcall (pop next-processors) md-content context next-processors)))))
(defun preprocess-lisp-page (page)
(let* ((lisp-file (page-content page)))
(when (string-equal (pathname-type lisp-file) "lisp")
(let ((html-file (make-pathname :defaults lisp-file :type "html")))
(format t "Loading ~a and creating fresh ~a...~%"
(file-namestring lisp-file) html-file)
(let (*computed-page-content*)
(load (merge-pathnames lisp-file *pages-dir*))
(with-open-file (out (merge-pathnames html-file *pages-dir*) :if-exists :supersede
:if-does-not-exist :create :direction :output)
(let ((headers (getf *computed-page-content* :headers)))
(mapc #'(lambda(key value) (format out "~a: ~a~%" key value))
(plist-keys headers)(plist-values headers)))
(format out "---~%")
(write-string (getf *computed-page-content* :html-string) out)))))))
(defun preprocess-lisp-page (content context next-processors)
(let* ((lisp-file (make-path *pages-dir* context t)))
(unless (string= (pathname-type lisp-file) "lisp")
(return-from preprocess-lisp-page (funcall (pop next-processors) content context next-processors)))
(let ((html-file (make-pathname :defaults lisp-file :type "html"))
(format t "Loading ~a and creating fresh ~a...~%"
(file-namestring lisp-file) html-file)
;;;###TODO not happy about loading the lisp file; it defeats the preprocessor/postprocessor purpose
(load (merge-pathnames lisp-file *pages-dir*))
(let ((headers (getf *computed-page-content* :headers)))
(funcall (pop next-processors) (getf *computed-page-content* :html-string)
(append (mapcan #'(lambda (key value)
(acons key value nil))
(plist-keys headers)
(plist-values headers))
(defun process-page (content context)
(let ((template-path (pathname (merge-pathnames *templates-dir* *DEFAULT-PAGE-TEMPLATE*))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment