diff --git a/examples/multi-site.coleslawrc b/examples/multi-site.coleslawrc index 623ec72..b04874f 100644 --- a/examples/multi-site.coleslawrc +++ b/examples/multi-site.coleslawrc @@ -3,6 +3,12 @@ :domain "http://blub.co.za" :feeds ("lisp") :plugins ((mathjax)) + :routing ((:post "posts/~a") + (:tag-index "tag/~a") + (:month-index "date/~a") + (:numeric-index "~d") + (:feed "~a.xml") + (:tag-feed "tag/~a.xml")) :sitenav ((:url "http://twitter.com/ralph_moeritz" :name "Twitter") (:url "http://github.com/ralph-moeritz" :name "Code")) :staging-dir "/tmp/coleslaw" @@ -13,6 +19,12 @@ :domain "http://musings.co.za" :feeds ("opinion") :plugins ((mathjax)) + :routing ((:post "posts/~a") + (:tag-index "tag/~a") + (:month-index "date/~a") + (:numeric-index "~d") + (:feed "~a.xml") + (:tag-feed "tag/~a.xml")) :sitenav ((:url "http://twitter.com/ralph_moeritz" :name "Twitter") (:url "http://github.com/ralph-moeritz" :name "Code")) :staging-dir "/tmp/coleslaw" diff --git a/examples/single-site.coleslawrc b/examples/single-site.coleslawrc index 0760bd0..6bb752f 100644 --- a/examples/single-site.coleslawrc +++ b/examples/single-site.coleslawrc @@ -7,6 +7,12 @@ (disqus :shortname "my-site-name") (analytics :tracking-code "foo")) :repo "/home/git/tmp/improvedmeans/" + :routing ((:post "posts/~a") + (:tag-index "tag/~a") + (:month-index "date/~a") + (:numeric-index "~d") + (:feed "~a.xml") + (:tag-feed "tag/~a.xml")) :sitenav ((:url "http://redlinernotes.com/" :name "Home") (:url "http://twitter.com/redline6561" :name "Twitter") (:url "http://github.com/redline6561" :name "Code") diff --git a/src/documents.lisp b/src/documents.lisp index ae1bc7d..e7fdac9 100644 --- a/src/documents.lisp +++ b/src/documents.lisp @@ -27,7 +27,13 @@ ;; Instance Methods (defgeneric page-url (document) - (:documentation "The url to the DOCUMENT without the domain.")) + (:documentation "The url to the DOCUMENT without the domain.") + (:method (document) + (let* ((class-name (class-name (class-of document))) + (route (assoc class-name (routing *config*)))) + (if route + (format nil (second route) (slot-value document 'slug)) + (error "No routing method found for: ~A" class-name))))) (defmethod page-url :around ((document t)) (let ((result (call-next-method)))