root/urls.py

Revision 1361:cfa16a6965b0, 3.0 kB (checked in by Alexander Solovyov <[email protected]…>, 6 months ago)

update pingback to 0.3, make xmlrpc api-compatible with django-xmlrpc

Line  
1 # Custom patches
2 from os.path import join, dirname
3
4 from django.conf import settings
5 from django.conf.urls.defaults import *
6 from django.contrib import admin
7 from django.contrib.sitemaps import FlatPageSitemap
8 from django.http import HttpResponseServerError
9 from django.template.context import RequestContext
10 from django.template.loader import render_to_string
11
12 from blog.sitemaps import BlogSitemap, IndexSitemap, BlogTagsSitemap
13 import patches
14 from lib import appcheck
15
16 def error500(request, template_name='500.html'):
17     try:
18         output = render_to_string(template_name, {}, RequestContext(request))
19     except:
20         output = "Critical error. Administrator was notified."
21     return HttpResponseServerError(output)
22
23 handler500 = 'urls.error500'
24
25 sitemaps = {
26     'blog': BlogSitemap,
27     'blogtags': BlogTagsSitemap,
28     'flat': FlatPageSitemap,
29     'index': IndexSitemap,
30     }
31
32 try:
33     import urls_local
34     urlpatterns = urls_local.urlpatterns
35 except ImportError:
36     urlpatterns = patterns('',)
37
38 admin.autodiscover()
39
40 urlpatterns += patterns(
41     '',
42     url(r'', include('revcanonical.urls')),
43     url(r'^admin/postimage/', include('postimage.urls')),
44     url(r'^admin/(.*)', admin.site.root, name='admin'),
45     url(r'^accounts/', include('accounts.urls')),
46     url(r'^openid/', include('openidconsumer.urls')),
47     url(r'^openidserver/', include('openidserver.urls')),
48     url(r'^%s' % settings.BLOG_URLCONF_ROOT, include('blog.urls')),
49     url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap',
50         {'sitemaps': sitemaps}),
51     url(r'^xmlrpc/', include('django_xmlrpc.urls')),
52     url(r'^captcha/', include('captcha.urls')),
53     url(r'^robots.txt$', include('robots.urls')),
54     url(r'^feeds/', include('feed.urls')),
55     url(r'^tagging_autocomplete/', include('tagging_autocomplete.urls')),
56     )
57
58 if appcheck.watchlist:
59     urlpatterns += patterns('', url(r'^watchlist/', include('watchlist.urls')),)
60
61 if appcheck.friends:
62     urlpatterns += patterns('', url(r'^friends/', include('friends.urls')),)
63
64 if appcheck.haystack:
65     urlpatterns += patterns('', url(r'^search/', include('search.urls')),)
66
67 if settings.URL_ROOT_HANDLER:
68     urlpatterns += patterns('', url(r'^$', settings.URL_ROOT_HANDLER))
69
70 # static urls will be disabled in production mode,
71 # forcing user to configure httpd
72 if settings.DEBUG:
73     urlpatterns += patterns(
74         '',
75         url(r'^media/(.*)$', 'django.views.static.serve',
76             {'document_root': settings.MEDIA_ROOT}),
77         url(r'^static/(.*)$', 'django.views.static.serve',
78             {'document_root': settings.STATIC_ROOT}),
79         url(r'^admin-media/(.*)$', 'django.views.static.serve',
80             {'document_root': join(dirname(admin.__file__), 'media')}),
81         )
82
83 if appcheck.wpimport:
84     urlpatterns += patterns('', url(r'^wpimport/', include('wpimport.urls')),)
85
86 if appcheck.debug:
87     urlpatterns += patterns('', url('', include('debug.urls')),)
88
89 if appcheck.life:
90     urlpatterns += patterns('', url(r'^life/', include('life.urls')),)
Note: See TracBrowser for help on using the browser.