Sketch of READ-POST.
This commit is contained in:
parent
4b61c1115b
commit
0d0f7b564b
3 changed files with 25 additions and 8 deletions
3
TODO
3
TODO
|
@ -13,8 +13,7 @@ Plugins? Injection support for HEAD and BODY. What about predicate-based injecti
|
||||||
How is it served? Hunchentoot, Lighttpd, S3, whomever!
|
How is it served? Hunchentoot, Lighttpd, S3, whomever!
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
; implement read-post
|
; fix plugins: s3
|
||||||
; fix plugins: s3, wordpress
|
|
||||||
; doc themes and plugins
|
; doc themes and plugins
|
||||||
; implement plugins: atom, markdown, pygment/highlighting
|
; implement plugins: atom, markdown, pygment/highlighting
|
||||||
; actually start using this for redlinernotes.com? Move over May-2007 to present.
|
; actually start using this for redlinernotes.com? Move over May-2007 to present.
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
(format out "title: ~A~%" title)
|
(format out "title: ~A~%" title)
|
||||||
(format out "tags: ~A~%" (format nil "~{~A, ~}" tags))
|
(format out "tags: ~A~%" (format nil "~{~A, ~}" tags))
|
||||||
(format out "date: ~A~%" date)
|
(format out "date: ~A~%" date)
|
||||||
(format out "type: html~%") ; post format: html, md, rst, etc
|
(format out "format: html~%") ; post format: html, md, rst, etc
|
||||||
(format out ";;;;;~%")
|
(format out ";;;;;~%")
|
||||||
(format out "~A~%" (post-content post))))
|
(format out "~A~%" (post-content post))))
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
(tags :initform nil :initarg :tags :accessor post-tags)
|
(tags :initform nil :initarg :tags :accessor post-tags)
|
||||||
(date :initform nil :initarg :date :accessor post-date)
|
(date :initform nil :initarg :date :accessor post-date)
|
||||||
(format :initform nil :initarg :format :accessor post-format)
|
(format :initform nil :initarg :format :accessor post-format)
|
||||||
(content :initform nil :initarg :content :accessor post-content)
|
(content :initform nil :initarg :content :accessor post-content)))
|
||||||
(aliases :initform nil :initarg :aliases :accessor post-aliases)))
|
|
||||||
|
|
||||||
(defun render-posts ()
|
(defun render-posts ()
|
||||||
"Iterate through the files in the repo to render+write the posts out to disk."
|
"Iterate through the files in the repo to render+write the posts out to disk."
|
||||||
|
@ -25,9 +24,28 @@
|
||||||
(:method (text (format (eql :html)))
|
(:method (text (format (eql :html)))
|
||||||
text))
|
text))
|
||||||
|
|
||||||
(defun read-post (stream)
|
(defun read-post (in)
|
||||||
"Make a POST instance based on the data from STREAM."
|
"Make a POST instance based on the data from the stream IN."
|
||||||
)
|
(flet ((check-header ()
|
||||||
|
(unless (string= (read-line in) ";;;;;")
|
||||||
|
(error "The provided file lacks the expected header.")))
|
||||||
|
(parse-field (str)
|
||||||
|
(nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+: (.*)" str)))
|
||||||
|
(slurp-remainder ()
|
||||||
|
(read-sequence (make-string (- (file-length in)
|
||||||
|
(file-position in))
|
||||||
|
:element-type 'character) in)))
|
||||||
|
(check-header)
|
||||||
|
(let ((args (loop for field in '("title" "tags" "date" "format")
|
||||||
|
for line = (read-line in nil)
|
||||||
|
when (not (search field line :test #'string=))
|
||||||
|
do (error "The provided file lacks the expected header.")
|
||||||
|
appending (list (intern (string-upcase field) :keyword)
|
||||||
|
(aref (parse-field (read-line in)) 0)))))
|
||||||
|
(check-header)
|
||||||
|
(apply 'make-instance 'blog
|
||||||
|
(append args (list :content (slurp-remainder)
|
||||||
|
:slug (slugify (getf args :title))))))))
|
||||||
|
|
||||||
(defun write-post (slug post)
|
(defun write-post (slug post)
|
||||||
"Write out the HTML for POST in SLUG.html."
|
"Write out the HTML for POST in SLUG.html."
|
||||||
|
|
Loading…
Add table
Reference in a new issue