From 72e631e8a490c8670d4a1107b382a3d15ea78c6e Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Tue, 21 Aug 2012 16:37:18 -0400 Subject: [PATCH] Only read a line in once, make posts, not blogs. --- src/posts.lisp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/posts.lisp b/src/posts.lisp index d272bf0..93b995f 100644 --- a/src/posts.lisp +++ b/src/posts.lisp @@ -38,21 +38,17 @@ (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))) + (nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+: (.*)" str)))) (check-header) (let ((args (loop for field in '("title" "tags" "date" "format") for line = (read-line in nil) appending (list (make-keyword field) - (aref (parse-field (read-line in)) 0))))) + (aref (parse-field line) 0))))) (check-header) (setf (getf args :tags) (cl-ppcre:split ", " (getf args :tags)) (getf args :format) (make-keyword (getf args :format))) - (apply 'make-instance 'blog - (append args (list :content (slurp-remainder) + (apply 'make-instance 'post + (append args (list :content (read-line in nil) :slug (slugify (getf args :title)))))))) (defun write-post (slug post)