from django.conf.urls.defaults import *
from shiftingbits.settings import MEDIA_ROOT
from django.contrib import admin
from django.views.generic.simple import direct_to_template
from shiftingbits.blog.models import Post
from shiftingbits.blog.views import object_detail, archive_index, archive_month, archive_day, archive_year, object_detail_redirect, archive_day_redirect, archive_month_redirect
from shiftingbits.blog.feeds import LatestPostFeed, LatestPostsByTagFeed
admin.autodiscover()
import mobileadmin
mobileadmin.autoregister()
feeds = {
"latest": LatestPostFeed,
"tags": LatestPostsByTagFeed,
}
date_based_dict = {
"date_field": "pub_date"
}
urlpatterns = patterns("",
### Feeds
url(r"^rss.aspx", "shiftingbits.blog.views.feed_redirect"),
url(r"^feeds/(?P<url>.*)/$", "django.contrib.syndication.views.feed", {"feed_dict": feeds}, name="blog_feeds"),
### Tags
url(r"tags/(?P<tag>[^/]+)/$", "tagging.views.tagged_object_list", { "queryset_or_model": Post, "template_object_name":"post", "template_name": "blog/post_archive.html", "related_tags": True}, name="blog_tag_detail"),
### Handle the way the old links were via redirect
url(r"^(?P<year>\d{4})/(?P<month>[0-9]*)/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$", object_detail_redirect),
url(r"^(?P<year>\d{4})/(?P<month>[0-9]*)/(?P<day>\w{1,2})/$", archive_day_redirect),
url(r"^(?P<year>\d{4})/(?P<month>[0-9]*)/$", archive_month_redirect),
### Date Based Generic Views for Blog Posts
url(r"^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$", object_detail, dict(date_based_dict, **{"template_object_name": "post"}), name="blog_post_detail"),
url(r"^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$", archive_day, dict(date_based_dict, **{"allow_empty": True}), name="blog_archive_daily"),
url(r"^(?P<year>\d{4})/(?P<month>[a-z]{3})/$", archive_month, dict(date_based_dict, **{"allow_empty":True}), name="blog_archive_month"),
url(r"^(?P<year>\d{4})/$", archive_year, dict(date_based_dict, **{"allow_empty":True}), name="blog_archive_year"),
url(r'^$', archive_index, dict(date_based_dict, **{'template_object_name':'post_list'}), name="blog_archive"),
### Comments
(r'^comments/', include('django.contrib.comments.urls')),
### Admin
(r'^admin/(.*)', admin.site.root),
### Projects
(r'^projects/$', direct_to_template, {'template':'projects.html'}),
### Media
(r'^media/(?P<path>.*)$' , 'django.views.static.serve', {'document_root': MEDIA_ROOT, 'show_indexes': True })
)
from shiftingbits.blog.xmlrpc.urls import urlpatterns as xmlrpcpatterns
urlpatterns += xmlrpcpatterns
urlpatterns += patterns('',
(r'^ma/(.*)', mobileadmin.sites.site.root),
)
handler404 = 'mobileadmin.views.page_not_found'
handler500 = 'mobileadmin.views.server_error'