Improve post-url scheme, do taglinks and monthlinks the right way in index template, update coleslaw-static.asd and TODO.

This commit is contained in:
Brit Butler 2011-04-19 16:01:20 -04:00
parent 44acf9d02b
commit b7e8f78465
7 changed files with 49 additions and 32 deletions

24
TODO
View file

@ -3,35 +3,39 @@ Everything.
Ideas: Ideas:
-- Replace cl-markdown with 3bmd down the line? -- Replace cl-markdown with 3bmd down the line?
-- Use cl-inotify or similar for notifications instead of timers? -- Use cl-inotify or similar for notifications instead of timers?
-- plugins -> lastfm widget, analytics, rss/atom, disqus, akismet, etc.
;; TODO: TODO:
;; consider add-to-index/setf-index, create-index, create-post.
;; then ensure the indices API is okay and GET GOING.
;;;; DYNAMIC
;;;; STATIC ;;;; STATIC
;;;; implement head-inject/body-inject/navigation! ;;;; implement head-inject/body-inject/navigation!
;;;; implement start-coleslaw, stop-coleslaw! ;;;; implement start-coleslaw, stop-coleslaw!
;;;; non-disqus comment support? ;;;; implement render-site!!!
;;; indexes ;;;; implement atom feed. RSS too?
;;;; implement non-disqus comment support?
;;;; What do post update semantics look like? i.e. edit file to change tags.
;;; indices
;; what should it really look like, keeping in mind the API should be mostly ;; what should it really look like, keeping in mind the API should be mostly
;; identical between the static and dynamic backend? ;; identical between the static and dynamic backend?
;; indexes should be id/name, title + posts. rewrite indices to use them.
;;; posts ;;; posts
;; Make find-by-date, post-url not suck. ;; Make find-by-date, post-url not suck.
;; -- re: find-by-date, aside from the subseq+string= grossness, the posts it ;; -- re: find-by-date, aside from the subseq+string= grossness, the posts it
;; -- returns are not in reverse chronological order. Fix it! ;; -- returns are not in reverse chronological order. Fix it!
;; -- re: post-url, escaping is insufficient and there are collisions by title. ;; -- re: post-url, improve escaping.
;; -- What are alternatives?
;;;; PLUGINS ;;;; PLUGINS
;;;; implement: analytics, crossposting, disqus, mathjax, pygments, recaptcha, s3 ;;;; implement: analytics, crossposting, disqus, mathjax, pygments, recaptcha, s3
;;;; support input or output dirs being git repos + have git hooks?
;;; import ;;; import
;; add output to HTML files when static-p is true ;; add output to HTML files when static-p is true
;; add comment handling ... (when comments ...) ;; add comment handling ... (when comments ...)
;; support old URLs via use of post-aliases? ;; support old URLs via use of post-aliases?
;;;; DYNAMIC
;;;; implement the whole damn backend!
;;;; make sure it has an admin interface!
;;;; -- spend two years trying to make it secure without HTTPS+SSL. fail.
;;;; rendering hooks (pygmentize, xposting) via :around/:before/:after methods ;;;; rendering hooks (pygmentize, xposting) via :around/:before/:after methods
;; get run on rendered html before "storage" ;; get run on rendered html before "storage"
;; xposting may be a rendering hook but may necessitate publishing hooks ;; xposting may be a rendering hook but may necessitate publishing hooks

View file

@ -5,8 +5,14 @@
:maintainer "Brit Butler <redline6561@gmail.com>" :maintainer "Brit Butler <redline6561@gmail.com>"
:author "Brit Butler <redline6561@gmail.com>" :author "Brit Butler <redline6561@gmail.com>"
:licence "LLGPL" :licence "LLGPL"
:depends-on (:coleslaw :zs3 :trivial-timers) :depends-on (:coleslaw :zs3 :trivial-timers :cl-store)
:components ((:module static :components ((:module static
:components ((:file "coleslaw") :components ((:file "coleslaw")
(:file "comments"
:depends-on ("coleslaw"))
(:file "posts" (:file "posts"
:depends-on ("coleslaw"))
(:file "indices"
:depends-on ("posts"))
(:file "util"
:depends-on ("coleslaw")))))) :depends-on ("coleslaw"))))))

2
plugins/akismet.lisp Normal file
View file

@ -0,0 +1,2 @@
(in-package :coleslaw)

View file

@ -2,21 +2,11 @@
(defun monthlinks () (defun monthlinks ()
(loop for month in (gethash :months-index *storage*) (loop for month in (gethash :months-index *storage*)
collect (cons (index-url :date month) month) into months collecting (list :url (index-url :date month) :name month)))
finally (return
(pretty-list (mapcar (lambda (consp)
(format nil "<a href=\"~a\">~a</a>"
(car consp) (cdr consp)))
months)))))
(defun taglinks () (defun taglinks ()
(loop for tag in (gethash :tags-index *storage*) (loop for tag in (gethash :tags-index *storage*)
collect (cons (index-url :tag tag) tag) into tags collecting (list :url (index-url :tag tag) :name tag)))
finally (return
(pretty-list (mapcar (lambda (consp)
(format nil "<a href=\"~a\">~a</a>"
(car consp) (cdr consp)))
tags)))))
(defun index-title (id &optional page) (defun index-title (id &optional page)
(case id (case id

View file

@ -43,14 +43,14 @@
(push post results))) (push post results)))
results)) results))
(defmethod find-by-date (date) (defmethod find-by-date (year-month)
(let ((results nil) (let ((results nil)
(year (parse-integer (subseq date 0 4))) (year (parse-integer (subseq year-month 0 4)))
(month (parse-integer (subseq date 5)))) (month (parse-integer (subseq year-month 5))))
(loop for post being the hash-values in (gethash :posts *storage*) (loop for post being the hash-values in (gethash :posts *storage*)
do (let ((post-date (post-date post))) do (let ((date (post-date post)))
(when (and (= year (local-time:timestamp-year post-date)) (when (and (= year (local-time:timestamp-year date))
(= month (local-time:timestamp-month post-date))) (= month (local-time:timestamp-month date)))
(push post results)))) (push post results))))
results)) results))
@ -62,4 +62,7 @@
(defmethod post-url (id) (defmethod post-url (id)
(flet ((escape (str) (flet ((escape (str)
(substitute #\- #\Space str))) (substitute #\- #\Space str)))
(concatenate 'string *site-root* "/" (escape (post-title (find-post id)))))) (let ((post (find-post id)))
(concatenate 'string *site-root* "/"
(year-month (post-date post)) "/"
(escape (post-title post))))))

View file

@ -6,5 +6,9 @@
(defun pretty-list (list) (defun pretty-list (list)
(format nil "~{~A~^, ~}" list)) (format nil "~{~A~^, ~}" list))
(defun year-month (date)
(format nil "~4d-~2,'0d" (local-time:timestamp-year date)
(local-time:timestamp-month date)))
(defun theme-fn (name) (defun theme-fn (name)
(find-symbol name (theme-package))) (find-symbol name (theme-package)))

View file

@ -3,12 +3,20 @@
{template index} {template index}
{if $taglinks} {if $taglinks}
<div id="tagsoup"> <div id="tagsoup">
<p>This blog covers {$taglinks |noAutoescape} <p>This blog covers
{foreach $taglink in $taglinks}
<a href="{$taglink.url |noAutoescape}">{$taglink.name}</a>
{if not isLast($taglink)}, {/if}
{/foreach}
</div> </div>
{/if} {/if}
{if $monthlinks} {if $monthlinks}
<div id="monthsoup"> <div id="monthsoup">
<p>View posts from {$monthlinks |noAutoescape} <p>View posts from
{foreach $monthlink in $monthlinks}
<a href="{$monthlink.url |noAutoescape}">{$monthlink.name}</a>
{if not isLast($monthlink)}, {/if}
{/foreach}
</div> </div>
{/if} {/if}
<h1>{$title}</h1> <h1>{$title}</h1>