dotim / dotim / urls.py

from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.http import HttpResponse
from django.shortcuts import redirect

from .gallery.feeds import AlbumFeed
from .sitemap import sitemaps

admin.autodiscover()

# Pretty 500 error page
handler500 = 'dotim.blog.views.server_error'


urlpatterns = patterns('',
    (r'^', include('dotim.blog.urls', namespace='blog')),
    (r'^timeline/', include('dotim.activity.urls', namespace='activity')),
    (r'^projects/', include('dotim.projects.urls', namespace='projects')),
    (r'^photos/', include('dotim.gallery.urls', namespace='gallery')),
    (r'^comments/', include('django.contrib.comments.urls')),

    url(r'^atom/albums/$', AlbumFeed(), name='album_feed'),

    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap',
     {'sitemaps': sitemaps}),

    (r'^admin/', include(admin.site.urls)),

    url(r'^robots.txt$', lambda _:
        HttpResponse('User-agent: *\nDisallow:\n', mimetype='text/plain')),

    url(r'^favicon.ico$', lambda _:
        redirect('%sblog/img/favicon.png' % settings.STATIC_URL,
                 permanent=True)),
)


# Redirects -- for short URLs
urlpatterns += patterns('dotim.redirects',
    url(r'^e(?P<id>\d+)$', 'redirect_to_entry', name='short_entry'),
    url(r'^a(?P<id>\d+)$', 'redirect_to_album', name='short_album'),
    url(r'^p(?P<id>\d+)$', 'redirect_to_picture', name='short_picture'),
)


urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.