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:
-- Replace cl-markdown with 3bmd down the line?
-- Use cl-inotify or similar for notifications instead of timers?
-- plugins -> lastfm widget, analytics, rss/atom, disqus, akismet, etc.
;; TODO:
;; consider add-to-index/setf-index, create-index, create-post.
;; then ensure the indices API is okay and GET GOING.
;;;; DYNAMIC
TODO:
;;;; STATIC
;;;; implement head-inject/body-inject/navigation!
;;;; implement start-coleslaw, stop-coleslaw!
;;;; non-disqus comment support?
;;; indexes
;;;; implement render-site!!!
;;;; 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
;; identical between the static and dynamic backend?
;; indexes should be id/name, title + posts. rewrite indices to use them.
;;; posts
;; Make find-by-date, post-url not suck.
;; -- re: find-by-date, aside from the subseq+string= grossness, the posts it
;; -- returns are not in reverse chronological order. Fix it!
;; -- re: post-url, escaping is insufficient and there are collisions by title.
;; -- What are alternatives?
;; -- re: post-url, improve escaping.
;;;; PLUGINS
;;;; implement: analytics, crossposting, disqus, mathjax, pygments, recaptcha, s3
;;;; support input or output dirs being git repos + have git hooks?
;;; import
;; add output to HTML files when static-p is true
;; add comment handling ... (when comments ...)
;; 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
;; get run on rendered html before "storage"
;; xposting may be a rendering hook but may necessitate publishing hooks

View file

@ -5,8 +5,14 @@
:maintainer "Brit Butler <redline6561@gmail.com>"
:author "Brit Butler <redline6561@gmail.com>"
:licence "LLGPL"
:depends-on (:coleslaw :zs3 :trivial-timers)
:depends-on (:coleslaw :zs3 :trivial-timers :cl-store)
:components ((:module static
:components ((:file "coleslaw")
(:file "comments"
:depends-on ("coleslaw"))
(:file "posts"
:depends-on ("coleslaw"))
(:file "indices"
:depends-on ("posts"))
(:file "util"
: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 ()
(loop for month in (gethash :months-index *storage*)
collect (cons (index-url :date month) month) into months
finally (return
(pretty-list (mapcar (lambda (consp)
(format nil "<a href=\"~a\">~a</a>"
(car consp) (cdr consp)))
months)))))
collecting (list :url (index-url :date month) :name month)))
(defun taglinks ()
(loop for tag in (gethash :tags-index *storage*)
collect (cons (index-url :tag tag) tag) into tags
finally (return
(pretty-list (mapcar (lambda (consp)
(format nil "<a href=\"~a\">~a</a>"
(car consp) (cdr consp)))
tags)))))
collecting (list :url (index-url :tag tag) :name tag)))
(defun index-title (id &optional page)
(case id

View file

@ -43,14 +43,14 @@
(push post results)))
results))
(defmethod find-by-date (date)
(defmethod find-by-date (year-month)
(let ((results nil)
(year (parse-integer (subseq date 0 4)))
(month (parse-integer (subseq date 5))))
(year (parse-integer (subseq year-month 0 4)))
(month (parse-integer (subseq year-month 5))))
(loop for post being the hash-values in (gethash :posts *storage*)
do (let ((post-date (post-date post)))
(when (and (= year (local-time:timestamp-year post-date))
(= month (local-time:timestamp-month post-date)))
do (let ((date (post-date post)))
(when (and (= year (local-time:timestamp-year date))
(= month (local-time:timestamp-month date)))
(push post results))))
results))
@ -62,4 +62,7 @@
(defmethod post-url (id)
(flet ((escape (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)
(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)
(find-symbol name (theme-package)))

View file

@ -3,12 +3,20 @@
{template index}
{if $taglinks}
<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>
{/if}
{if $monthlinks}
<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>
{/if}
<h1>{$title}</h1>