From ebe80cd8bf292063d25f489048e1da20e1b402e5 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Wed, 12 Sep 2012 17:25:36 -0400 Subject: [PATCH] Fix glaring bugs. --- coleslaw.asd | 6 +++--- src/coleslaw.lisp | 6 +++--- src/indices.lisp | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/coleslaw.asd b/coleslaw.asd index 7260461..8a6ed80 100644 --- a/coleslaw.asd +++ b/coleslaw.asd @@ -12,10 +12,10 @@ (:file "util") (:file "config") (:file "themes") - (:file "coleslaw") - (:file "feeds") (:file "posts") - (:file "indices")) + (:file "indices") + (:file "feeds") + (:file "coleslaw")) :in-order-to ((test-op (load-op coleslaw-tests))) :perform (test-op :after (op c) (funcall (intern "RUN!" :coleslaw-tests) diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index cadd7b7..ce8b1f6 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -7,8 +7,8 @@ "Render the given CONTENT to disk using THEME-FN if supplied. Additional args to render CONTENT can be passed via RENDER-ARGS." (let* ((path (etypecase content - (post (format nil "posts/~a.html" (post-slug post))) - (index (index-path index)))) + (post (format nil "posts/~a.html" (post-slug content))) + (index (index-path content)))) (filepath (merge-pathnames path (staging *config*))) (page (funcall (theme-fn (or theme-fn 'base)) (list :config *config* @@ -21,7 +21,7 @@ Additional args to render CONTENT can be passed via RENDER-ARGS." (with-open-file (out filepath :direction :output :if-does-not-exist :create) - (write page :stream out)))) + (write-line page out)))) (defun compile-blog (staging) "Compile the blog to a STAGING directory as specified in .coleslawrc." diff --git a/src/indices.lisp b/src/indices.lisp index 66741d2..292db58 100644 --- a/src/indices.lisp +++ b/src/indices.lisp @@ -37,34 +37,34 @@ (let ((content (remove-if-not (lambda (post) (member tag (post-tags post) :test #'string=)) posts))) (make-instance 'index :path (format nil "tag/~a.html" tag) - :posts (by-date content) - :title "Posts tagged ~a" tag))) + :posts content + :title (format nil "Posts tagged ~a" tag)))) (defun index-by-month (month posts) "Return an index of all POSTS matching the given MONTH." (let ((content (remove-if-not (lambda (post) (search month (post-date post))) posts))) (make-instance 'index :path (format nil "date/~a.html" month) - :posts (by-date content) + :posts content :title (format nil "Posts from ~a" month)))) (defun index-by-n (i posts &optional (step 10)) "Return the index for the Ith page of POSTS in reverse chronological order." - (make-instance 'index :path (format nil "~d.html" i) - :posts (let ((index (* step (1- i)))) + (make-instance 'index :path (format nil "~d.html" (1+ i)) + :posts (let ((index (* step i))) (subseq posts index (min (length posts) (+ index step)))) :title "Recent Posts")) (defun render-indices () "Render the indices to view posts in groups of size N, by month, and by tag." - (let ((posts (hash-table-values *posts*))) + (let ((posts (by-date (hash-table-values *posts*)))) (dolist (tag (all-tags)) (render-page (index-by-tag tag posts))) (dolist (month (all-months)) (render-page (index-by-month month posts))) - (dolist (i (ceiling (length posts) 10)) - (render-page (index-by-n i (by-date posts)) nil - :prev (and (plusp (1- i)) (1- i)) - :next (and (< (* i 10) (length posts)) (1+ i))))) + (dotimes (i (ceiling (length posts) 10)) + (render-page (index-by-n i posts) nil + :prev (and (plusp i) i) + :next (and (< (* i 10) (length posts)) (+ 2 i))))) (update-symlink "index.html" "1.html"))