addons-server/urls.py

137 строки
3.9 KiB
Python
Исходник Обычный вид История

2009-10-21 06:20:38 +04:00
from django.conf import settings
2009-10-23 03:43:38 +04:00
from django.conf.urls.defaults import patterns, url, include
2010-01-02 00:32:21 +03:00
from django.contrib import admin
from django.shortcuts import redirect
2010-05-05 22:51:20 +04:00
from django.views.i18n import javascript_catalog
from django.views.decorators.cache import cache_page
2010-01-02 00:32:21 +03:00
admin.autodiscover()
2009-10-23 03:43:38 +04:00
2010-02-05 04:51:14 +03:00
handler404 = 'amo.views.handler404'
handler500 = 'amo.views.handler500'
2009-10-21 03:29:27 +04:00
urlpatterns = patterns('',
2010-04-21 07:08:27 +04:00
# Discovery pane is first for undetectable efficiency wins.
('^discovery/', include('discovery.urls')),
2010-01-27 23:15:17 +03:00
# Add-ons.
('', include('addons.urls')),
2010-02-06 01:06:16 +03:00
# Browse pages.
('', include('browse.urls')),
2010-07-27 03:37:06 +04:00
# Tags.
('', include('tags.urls')),
# Collections.
('', include('bandwagon.urls')),
# Users
('', include('users.urls')),
2009-10-21 06:20:38 +04:00
2010-07-27 03:35:00 +04:00
# Tags
('', include('tags.urls')),
# Developer Hub.
('developers/', include('devhub.urls')),
2009-12-31 01:26:56 +03:00
# AMO admin (not django admin).
('^admin/', include('zadmin.urls')),
2010-02-04 05:19:47 +03:00
# Nick's special pages.
('^nickspages/', include('nick.urls')),
# Localizable pages.
('', include('pages.urls')),
2010-08-17 21:55:49 +04:00
# App versions.
('pages/appversions/', include('applications.urls')),
# Services
2010-05-13 07:56:50 +04:00
('', include('amo.urls')),
2010-02-05 08:39:55 +03:00
# Search
('^search/', include('search.urls')),
2010-02-27 04:04:59 +03:00
# Global stats dashboard.
url('^statistics/', lambda r: redirect('/'), name='statistics.dashboard'),
# Javascript translations.
2010-05-05 22:51:20 +04:00
url('^jsi18n/.*$', cache_page(60 * 60 * 24 * 365)(javascript_catalog),
{'domain': 'z-javascript', 'packages': ['zamboni']}, name='jsi18n'),
2010-02-10 22:35:25 +03:00
# SAMO/API
('^api/', include('api.urls')),
2010-08-27 08:54:01 +04:00
# Review spam.
url('^reviews/spam/$', 'reviews.views.spam', name='reviews.spam'),
2010-02-05 08:39:55 +03:00
# Redirect patterns.
('^bookmarks/?$',
lambda r: redirect('browse.extensions', 'bookmarks', permanent=True)),
2010-02-05 08:39:55 +03:00
('^reviews/display/(\d+)',
lambda r, id: redirect('reviews.list', id, permanent=True)),
2010-08-27 05:11:07 +04:00
('^reviews/add/(\d+)',
lambda r, id: redirect('reviews.add', id, permanent=True)),
('^users/info/(\d+)',
lambda r, id: redirect('users.profile', id, permanent=True)),
('^pages/about$',
lambda r: redirect('pages.about', permanent=True)),
('^pages/faq$',
lambda r: redirect('pages.faq', permanent=True)),
# Redirect persona/xxx
('^persona/(\d+)',
lambda r, id: redirect('addons.detail', id, permanent=True)),
# Redirect top-tags to tags/top
2010-07-27 03:37:06 +04:00
('^top-tags/?',
lambda r: redirect('tags.top_cloud', permanent=True)),
('^personas/film and tv/?$',
lambda r: redirect('browse.personas', 'film-and-tv', permanent=True)),
2010-06-17 21:14:30 +04:00
('^addons/versions/(\d+)/?$',
lambda r, id: redirect('addons.versions', id, permanent=True)),
('^addons/versions/(\d+)/format:rss$',
lambda r, id: redirect('addons.versions.rss', id, permanent=True)),
('^addons/reviews/(\d+)/format:rss$',
lambda r, id: redirect('reviews.list.rss', id, permanent=True)),
2010-06-19 03:11:12 +04:00
('^search-engines.*$',
lambda r: redirect('browse.search-tools', permanent=True)),
('^addons/contribute/(\d+)/?$',
lambda r, id: redirect('addons.contribute', id, permanent=True)),
2010-07-27 22:35:26 +04:00
('^recommended$',
lambda r: redirect('browse.featured', permanent=True)),
('^recommended/format:rss$',
lambda r: redirect('browse.featured.rss', permanent=True)),
)
2009-10-23 03:43:38 +04:00
2010-08-27 21:07:16 +04:00
urlpatterns += patterns('piston.authentication',
url(r'^oauth/request_token/$', 'oauth_request_token',
name='oauth.request_token'),
url(r'^oauth/authorize/$', 'oauth_user_auth', name='oauth.authorize'),
url(r'^oauth/access_token/$', 'oauth_access_token',
name='oauth.access_token'),
)
2009-10-21 06:20:38 +04:00
if settings.DEBUG:
# Remove leading and trailing slashes so the regex matches.
media_url = settings.MEDIA_URL.lstrip('/').rstrip('/')
urlpatterns += patterns('',
(r'^%s/(?P<path>.*)$' % media_url, 'django.views.static.serve',
2009-10-22 01:56:43 +04:00
{'document_root': settings.MEDIA_ROOT}),
2009-10-21 06:20:38 +04:00
)