Hey, look! User-defined routes are easy. Slot-value is gross though.

This commit is contained in:
Brit Butler 2014-04-16 11:15:29 -04:00
parent e5a40b67a7
commit f56270430f
3 changed files with 25 additions and 1 deletions

View file

@ -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"

View file

@ -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")

View file

@ -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)))