2009-11-10 18:34:14 +05:30
|
|
|
import os
|
|
|
|
|
|
|
|
import const
|
2009-11-10 10:58:35 +05:30
|
|
|
|
2009-11-10 18:34:14 +05:30
|
|
|
from django.conf.urls.defaults import *
|
2009-11-10 10:58:35 +05:30
|
|
|
from django.contrib import admin
|
|
|
|
admin.autodiscover()
|
|
|
|
|
2009-11-10 19:53:19 +05:30
|
|
|
from web.grampsdb.views import (main_page, user_page, logout_page,
|
|
|
|
view, view_detail)
|
2009-11-10 10:58:35 +05:30
|
|
|
|
|
|
|
urlpatterns = patterns('',
|
|
|
|
# Specific matches first:
|
|
|
|
(r'^admin/(.*)', admin.site.root),
|
|
|
|
)
|
|
|
|
|
|
|
|
urlpatterns += patterns('',
|
|
|
|
# Static serves! DANGEROUS in production:
|
|
|
|
(r'^styles/(?P<path>.*)$', 'django.views.static.serve',
|
2009-11-10 18:34:14 +05:30
|
|
|
{'document_root': const.DATA_DIR,
|
|
|
|
'show_indexes': True},
|
2009-11-10 10:58:35 +05:30
|
|
|
),
|
|
|
|
(r'^images/(?P<path>.*)$', 'django.views.static.serve',
|
2009-11-10 18:34:14 +05:30
|
|
|
{'document_root': const.IMAGE_DIR,
|
|
|
|
'show_indexes': True},
|
2009-11-10 10:58:35 +05:30
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
# The rest will match views:
|
|
|
|
urlpatterns += patterns('',
|
|
|
|
(r'^$', main_page),
|
|
|
|
(r'^user/(\w+)/$', user_page),
|
|
|
|
(r'^login/$', 'django.contrib.auth.views.login'),
|
|
|
|
(r'^logout/$', logout_page),
|
|
|
|
(r'^(?P<view>(\w+))/$', view),
|
2009-11-19 08:11:37 +05:30
|
|
|
url(r'^person/(?P<handle>(\w+))/$', view_detail,
|
|
|
|
{"view": "person"}, name="view-person-detail"),
|
2009-11-10 10:58:35 +05:30
|
|
|
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/$', view_detail),
|
|
|
|
)
|
2009-11-19 08:11:37 +05:30
|
|
|
|
|
|
|
# In urls:
|
|
|
|
# urlpatterns = patterns('',
|
|
|
|
# url(r'^archive/(\d{4})/$', archive, name="full-archive"),
|
|
|
|
# url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
|
|
|
|
# )
|
|
|
|
|
|
|
|
# In template:
|
|
|
|
# {% url arch-summary 1945 %}
|
|
|
|
# {% url full-archive 2007 %}
|
|
|
|
#{% url path.to.view as the_url %}
|
|
|
|
#{% if the_url %}
|
|
|
|
# <a href="{{ the_url }}">Link to optional stuff</a>
|
|
|
|
#{% endif %}
|
|
|
|
|
|
|
|
# In code:
|
|
|
|
#from django.core.urlresolvers import reverse
|
|
|
|
#
|
|
|
|
#def myview(request):
|
|
|
|
# return HttpResponseRedirect(reverse('arch-summary', args=[1945]))
|