2009-11-23 03:58:30 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
|
|
|
""" Url handler """
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python Modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-11-10 18:34:14 +05:30
|
|
|
import os
|
|
|
|
|
2009-11-23 03:58:30 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Django and Gramps Modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-11-10 18:34:14 +05:30
|
|
|
import const
|
|
|
|
from django.conf.urls.defaults import *
|
2009-11-10 10:58:35 +05:30
|
|
|
from django.contrib import admin
|
|
|
|
admin.autodiscover()
|
|
|
|
|
2011-10-16 02:00:34 +05:30
|
|
|
from webapp.grampsdb.views import (main_page, user_page, logout_page,
|
|
|
|
process_action, view, view_detail,
|
2011-10-16 22:30:32 +05:30
|
|
|
view_name_detail, browse_page)
|
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',
|
2010-08-18 08:06:26 +05:30
|
|
|
{'document_root':
|
|
|
|
os.path.join(const.ROOT_DIR, "plugins", "webstuff"),
|
2009-11-10 18:34:14 +05:30
|
|
|
'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),
|
2011-10-16 22:30:32 +05:30
|
|
|
(r'^user/$', user_page),
|
2009-11-10 10:58:35 +05:30
|
|
|
(r'^user/(\w+)/$', user_page),
|
2011-10-16 22:30:32 +05:30
|
|
|
(r'^browse/$', browse_page),
|
2009-11-10 10:58:35 +05:30
|
|
|
(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-12-27 23:53:59 +05:30
|
|
|
url(r'^person/(?P<handle>(\w+))/(?P<action>(\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-12-17 05:34:22 +05:30
|
|
|
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))$', view_name_detail),
|
|
|
|
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/(?P<action>(\w+))$', view_name_detail),
|
2011-10-12 21:58:26 +05:30
|
|
|
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/(?P<action>(\w+))$', process_action),
|
2011-10-13 03:18:34 +05:30
|
|
|
(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/styles/images/favicon.ico'}),
|
2009-11-10 10:58:35 +05:30
|
|
|
)
|
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]))
|