Source

Mango / urls / defaults.py

Full commit
from django import http
from django.conf import settings
from django.conf.urls.defaults import patterns
from django.core.urlresolvers import reverse

import mango.settings
from mango.feeds import atom
from mango.handlers import flush_cache, moderate, redirect, unsubscribe
from mango.sitemaps import BlogSitemap
from mango.views import (archives, contact, index, message_sent, page, post,
        search, tagged_as, tags, view_source)

urlpatterns = patterns('')

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^static/(?P<path>.*)$', 'django.views.static.serve',
                {'document_root': mango.settings.PATH_TO_STATIC}),
    )

if mango.settings.ARCHIVES:
    urlpatterns += patterns('',
        (r'^archive/$', lambda request: http.HttpResponsePermanentRedirect(reverse(archives))),
        (r'^archives/$', archives),
    )

if mango.settings.CONTACT_FORM:
    urlpatterns += patterns('',
        (r'^contact/$', contact),
        (r'^contact/thanks/$', message_sent),
    )

if mango.settings.PAGING:
    urlpatterns += patterns('',
        (r'^page/(\d+)/$', page),
    )

if mango.settings.SITEMAP:
    urlpatterns += patterns('',
        (r'^sitemap[.]xml$', 'django.contrib.sitemaps.views.sitemap',
                {'sitemaps': {'blog': BlogSitemap}}),
    )

if mango.settings.TAGS_PAGE:
    urlpatterns += patterns('',
        (r'^tags/$', tags),
        (r'^tag/([^/]+)/$', tagged_as),
        (r'^tag/([^/]+)/feed/$', atom),
    )

if mango.settings.SEARCH:
    urlpatterns += patterns('',
        (r'^search$', search),
    )

if mango.settings.SUBSCRIPTIONS:
    urlpatterns += patterns('',
        (r'^(.+?)/unsubscribe/(\d+)/$', unsubscribe),
    )

urlpatterns += patterns('',
    (r'^$', index),
    (r'^feed/$', atom),
    (r'^flushcache/$', flush_cache),
    (r'^moderate/(approve|delete|spam|close)$', moderate),
    (r'^(.+?)/redirect/(.+)?$', redirect),
    (r'^(.+?)/comment/$', post),
    (r'^(.+?)/%s$' % mango.settings.SOURCE_SUFFIX, view_source),
    (r'^(.+?)/$', post),
)