diff --git a/scribeengine/config/routing.py b/scribeengine/config/routing.py index 6a91213..db23202 100644 --- a/scribeengine/config/routing.py +++ b/scribeengine/config/routing.py @@ -43,9 +43,9 @@ def make_map(): # CUSTOM ROUTES HERE - map.connect('/archive/{year}', controller='blog', action='archive') - map.connect('/archive/{year}/{month}', controller='blog', action='archive') - map.connect('/archive/{year}/{month}/{day}', controller='blog', action='archive') + map.connect('/archive/{year}', controller='blog', action='archive',month=None,day=None,url=None) + map.connect('/archive/{year}/{month}', controller='blog', action='archive',day=None,url=None) + map.connect('/archive/{year}/{month}/{day}', controller='blog', action='archive',url=None) map.connect('/archive/{year}/{month}/{day}/{url}', controller='blog', action='view') map.connect('/{controller}/{action}') diff --git a/scribeengine/controllers/blog.py b/scribeengine/controllers/blog.py index 12b34e8..349270d 100644 --- a/scribeengine/controllers/blog.py +++ b/scribeengine/controllers/blog.py @@ -88,5 +88,5 @@ class BlogController(BaseController): Session.add(post) Session.commit() h.flash.set_message(u'Successfully submitted your comment.', u'success') - h.redirect_to(h.full_url(post)) + h.redirect_to(h.url_for_post(post)) diff --git a/scribeengine/lib/helpers.py b/scribeengine/lib/helpers.py index 17f1403..613be40 100644 --- a/scribeengine/lib/helpers.py +++ b/scribeengine/lib/helpers.py @@ -78,10 +78,15 @@ def teaser(text, url): text = text[:position] return text -def full_url(post): - return '/archive/%s/%s/%s/%s' % (str(post.created.strftime('%Y')), \ - str(post.created.strftime('%m')), \ - str(post.created.strftime('%d')), \ - str(post.url)) +def url_for_post(post): + #TODO: this is hard coded. + return url_for( + controller='blog', + action='view', + year=post.created.strftime('%Y'), + month=post.created.strftime('%m'), + day=post.created.strftime('%d'), + url=post.url + ) flash = Flash() diff --git a/scribeengine/templates/admin/login.mako b/scribeengine/templates/admin/login.mako index 44fb607..ba5841d 100644 --- a/scribeengine/templates/admin/login.mako +++ b/scribeengine/templates/admin/login.mako @@ -3,7 +3,7 @@