urls.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from django.conf import settings
  2. from django.conf.urls.defaults import *
  3. from newsroom.models import *
  4. from newsroom import views as nr_views
  5. from newsroom.feeds import LatestNewsFeed
  6. # custom views stories
  7. urlpatterns = patterns('newsroom.views',
  8. url(r'^feed.xml', LatestNewsFeed(), name="nr-news-feed"),
  9. url(r'^authors/$', view=nr_views.author_list, name="nr-author-list"),
  10. url(r'^authors/(?P<type_slug>[\-\d\w]+)/(?P<slug>[\-\d\w]+)/$', view=nr_views.author_detail, name="nr-author-detail"),
  11. url(r'^archives/$', view=nr_views.archive_index, name='nr-archive-index'),
  12. url(r'^archives/(?P<year>\d{4})/$', view=nr_views.archive_year, name='nr-archive-year'),
  13. url(r'^archives/(?P<year>\d{4})/(?P<slug>[\-\d\w]+)/$', view=nr_views.archive_detail, name='nr-archive-section-detail'),
  14. url(r'^$', view=nr_views.paper_index, name="nr-index"),
  15. # We use a custom view so we can increment the view_count
  16. url(r'^editorials/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$', view=nr_views.editorial_detail, name='nr-editorial-detail'),
  17. url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$', view=nr_views.story_detail, name='nr-story-detail'),
  18. url(r'^tags/$', view=nr_views.tag_index, name='nr-tag-index'),
  19. url(r'^tags/(?P<name>[\-\d\w]+)/$', view=nr_views.tag_detail, name='nr-tag-detail'),
  20. )
  21. # editorials
  22. editorial_args = {'date_field': 'published_on', 'queryset': Editorial.objects.published()}
  23. urlpatterns += patterns('django.views.generic.date_based',
  24. url(r'^editorials/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', editorial_args, name='nr-editorial-archive-day'),
  25. url(r'^editorials/(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', editorial_args, name='nr-editorial-archive-month'),
  26. url(r'^editorials/(?P<year>\d{4})/$', 'archive_year', editorial_args, name='nr-editorial-archive-year'),
  27. )
  28. # stories
  29. story_args = {'date_field': 'published_on', 'queryset': Story.objects.published()}
  30. urlpatterns += patterns('django.views.generic.date_based',
  31. #url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$', 'object_detail', story_args, name='nr-story-detail'),
  32. url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', story_args, name='nr-story-archive-day'),
  33. url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', story_args, name='nr-story-archive-month'),
  34. url(r'(?P<year>\d{4})/$', 'archive_year', story_args, name='nr-story-archive-year'),
  35. )
  36. urlpatterns += patterns('django.views.generic.list_detail',
  37. url(r'page/(?P<page>[0-9]+)/$', 'object_list', {'queryset': Story.objects.published(), 'allow_empty': True, 'paginate_by': 5}, name='nr-story-list'),
  38. )