Drop local-time dependency, finish indices.

This commit is contained in:
Brit Butler 2012-08-20 16:55:47 -04:00
parent e1d4751a22
commit a2c6be20bf
2 changed files with 17 additions and 15 deletions

View file

@ -5,7 +5,7 @@
:license "BSD" :license "BSD"
:author "Brit Butler <redline6561@gmail.com>" :author "Brit Butler <redline6561@gmail.com>"
:pathname "src/" :pathname "src/"
:depends-on (:closure-template :iolib.os :local-time :alexandria) :depends-on (:closure-template :iolib.os :alexandria)
:serial t :serial t
:components ((:file "packages") :components ((:file "packages")
(:file "config") (:file "config")

View file

@ -12,7 +12,7 @@
collect (list :url (format nil "~a/month/~a.html" (domain *config*) month) collect (list :url (format nil "~a/month/~a.html" (domain *config*) month)
:name month)))) :name month))))
(defun write-index (posts filename) (defun write-index (posts filename title)
(let ((content (loop for post in posts (let ((content (loop for post in posts
collect (list :url (format nil "~a/posts/~a.html" collect (list :url (format nil "~a/posts/~a.html"
(domain *config*) (post-slug post)) (domain *config*) (post-slug post))
@ -23,6 +23,7 @@
(funcall (theme-fn "INDEX") (funcall (theme-fn "INDEX")
(list :taglinks (taglinks) (list :taglinks (taglinks)
:monthlinks (monthlinks) :monthlinks (monthlinks)
:title title
:posts content :posts content
; TODO: Populate prev and next with links. ; TODO: Populate prev and next with links.
:prev nil :prev nil
@ -35,26 +36,27 @@
(let ((posts (sort *posts* #'string> :key #'post-date))) (let ((posts (sort *posts* #'string> :key #'post-date)))
(loop for i from 1 then (1+ i) (loop for i from 1 then (1+ i)
until (> (* (1- i) 20) (length posts)) until (> (* (1- i) 20) (length posts))
do (write-index (by-20 posts i) (format nil "~d.html" i)))))) do (write-index (by-20 posts i) (format nil "~d.html" i) "Recent Posts")))))
(defun render-by-tag () (defun render-by-tag ()
(let ((tags (remove-duplicates (mapcan #'post-tags *posts*) :test #'string=))) (let ((tags (remove-duplicates (mapcan #'post-tags *posts*) :test #'string=)))
(loop for tag in tags (loop for tag in tags
do (let ((posts (remove-if-not (lambda (x) do (flet ((match-tag (post)
(member tag x :test #'string= (member tag post :test #'string= :key #'post-tags)))
:key #'post-tags)) (let ((posts (remove-if-not #'match-tag posts)))
posts))) (write-index posts (format nil "tag/~a.html" tag)
(write-index posts (format nil "tag/~a.html" tag)))))) (format nil "Posts tagged ~a" tag)))))))
(defun render-by-month () (defun render-by-month ()
;; TODO: Make this actually work. Add to render-indices. (let ((months (remove-duplicates (mapcar (lambda (x) (subseq (post-date x) 0 7))
(let ((months (remove-duplicates (mapcar #'post-date *posts*) :test #'string=))) *posts*) :test #'string=)))
(loop for month in months (loop for month in months
do (let ((posts (remove-if-not (lambda (x) do (let ((posts (remove-if-not (lambda (x) (search month (post-date x))
(from-month month x) *posts*))))
posts)))) (write-index posts (format nil "date/~a.html" (subseq month 0 7))
(render-index posts))))) (format nil "Posts from ~a" (subseq month 0 7)))))))
(defun render-indices () (defun render-indices ()
(render-by-20) (render-by-20)
(render-by-tag)) (render-by-tag)
(render-by-month))