summaryrefslogtreecommitdiff
path: root/urls.py
diff options
context:
space:
mode:
Diffstat (limited to 'urls.py')
-rw-r--r--urls.py107
1 files changed, 63 insertions, 44 deletions
diff --git a/urls.py b/urls.py
index 2ac8271e..2014f0aa 100644
--- a/urls.py
+++ b/urls.py
@@ -1,15 +1,11 @@
-import os.path
-
-# Stupid Django. Don't remove these "unused" handler imports
-from django.conf.urls import handler500, handler404, include, patterns
-from django.conf import settings
+from django.conf.urls import include, patterns, url
from django.contrib import admin
+from django.contrib.sitemaps import views as sitemap_views
-from django.views.generic import TemplateView
from django.views.decorators.cache import cache_page
-from django.views.i18n import null_javascript_catalog
+from django.views.generic import TemplateView, RedirectView
-from feeds import PackageFeed, NewsFeed
+from feeds import PackageFeed, NewsFeed, ReleaseFeed
import sitemaps
our_sitemaps = {
@@ -19,40 +15,12 @@ our_sitemaps = {
'package-files': sitemaps.PackageFilesSitemap,
'package-groups': sitemaps.PackageGroupsSitemap,
'split-packages': sitemaps.SplitPackagesSitemap,
+ 'releases': sitemaps.ReleasesSitemap,
}
admin.autodiscover()
urlpatterns = []
-# Feeds patterns, used later
-feeds_patterns = patterns('',
- (r'^$', 'public.views.feeds', {}, 'feeds-list'),
- (r'^news/$', cache_page(300)(NewsFeed())),
- (r'^packages/$', cache_page(300)(PackageFeed())),
- (r'^packages/(?P<arch>[A-z0-9]+)/$',
- cache_page(300)(PackageFeed())),
- (r'^packages/(?P<arch>[A-z0-9]+)/(?P<repo>[A-z0-9~\-]+)/$',
- cache_page(300)(PackageFeed())),
-)
-
-# Sitemaps
-urlpatterns += patterns('django.contrib.sitemaps.views',
- # Thanks Django, we can't cache these longer because of
- # https://code.djangoproject.com/ticket/2713
- (r'^sitemap.xml$', 'index',
- {'sitemaps': our_sitemaps}),
- (r'^sitemap-(?P<section>.+)\.xml$', 'sitemap',
- {'sitemaps': our_sitemaps}),
-)
-
-# Authentication / Admin
-urlpatterns += patterns('django.contrib.auth.views',
- (r'^login/$', 'login', {
- 'template_name': 'registration/login.html'}),
- (r'^logout/$', 'logout', {
- 'template_name': 'registration/logout.html'}),
-)
-
# Public pages
urlpatterns += patterns('public.views',
(r'^$', 'index', {}, 'index'),
@@ -67,16 +35,26 @@ urlpatterns += patterns('public.views',
(r'^donate/$', 'donate', {}, 'page-donate'),
(r'^download/$', 'download', {}, 'page-download'),
(r'^master-keys/$', 'keys', {}, 'page-keys'),
+ (r'^master-keys/json/$', 'keys_json', {}, 'pgp-keys-json'),
)
-urlpatterns += patterns('retro.views',
- (r'^retro/(?P<year>[0-9]{4})/$', 'retro_homepage', {}, 'retro-homepage'),
+# Feeds patterns, used below
+feeds_patterns = patterns('',
+ (r'^$', 'public.views.feeds', {}, 'feeds-list'),
+ (r'^news/$', cache_page(300)(NewsFeed())),
+ (r'^packages/$', cache_page(300)(PackageFeed())),
+ (r'^packages/(?P<arch>[A-z0-9]+)/$',
+ cache_page(300)(PackageFeed())),
+ (r'^packages/all/(?P<repo>[A-z0-9\-]+)/$',
+ cache_page(300)(PackageFeed())),
+ (r'^packages/(?P<arch>[A-z0-9]+)/(?P<repo>[A-z0-9\-]+)/$',
+ cache_page(300)(PackageFeed())),
+ (r'^releases/$', cache_page(300)(ReleaseFeed())),
)
# Includes and other remaining stuff
urlpatterns += patterns('',
# cache this static JS resource for 1 week rather than default 5 minutes
- (r'^jsi18n/$', cache_page(604800)(null_javascript_catalog)),
(r'^admin/', include(admin.site.urls)),
(r'^devel/', include('devel.urls')),
(r'^feeds/', include(feeds_patterns)),
@@ -90,20 +68,61 @@ urlpatterns += patterns('',
(r'^visualize/', include('visualize.urls')),
(r'^opensearch/packages/$', 'packages.views.opensearch',
{}, 'opensearch-packages'),
- (r'^todolists/$','todolists.views.public_list'),
+ (r'^opensearch/packages/suggest$', 'packages.views.opensearch_suggest',
+ {}, 'opensearch-packages-suggest'),
+)
+
+# Sitemaps
+urlpatterns += patterns('',
+ (r'^sitemap.xml$',
+ cache_page(1800)(sitemap_views.index),
+ {'sitemaps': our_sitemaps, 'sitemap_url_name': 'sitemaps'}),
+ (r'^sitemap-(?P<section>.+)\.xml$',
+ cache_page(1800)(sitemap_views.sitemap),
+ {'sitemaps': our_sitemaps}, 'sitemaps'),
+)
+
+# Authentication / Admin
+urlpatterns += patterns('django.contrib.auth.views',
+ (r'^login/$', 'login', {
+ 'template_name': 'registration/login.html'}),
+ (r'^logout/$', 'logout', {
+ 'template_name': 'registration/logout.html'}),
)
+# Redirects for older known pages we see in the logs
legacy_urls = (
('^about.php', '/about/'),
('^changelog.php', '/packages/?sort=-last_update'),
+ ('^devs.php', '/developers/'),
+ ('^donations.php', '/donate/'),
('^download.php', '/download/'),
('^index.php', '/'),
('^logos.php', '/art/'),
('^news.php', '/news/'),
+ ('^packages.php', '/packages/'),
+ ('^people.php', '/developers/'),
+ ('^todolists/$', '/todo/'),
+
+ ('^docs/en/guide/install/arch-install-guide.html',
+ 'https://wiki.parabolagnulinux.org/Installation_Guide'),
+ ('^docs/en/',
+ 'https://wiki.parabolagnulinux.org/'),
+ ('^docs/',
+ 'https://wiki.parabolagnulinux.org/'),
+
+ ('^developers/$', '/hackers/'),
+ ('^trustedusers/$', '/hackers/'),
)
-for old_url, new_url in legacy_urls:
- urlpatterns += patterns('django.views.generic.simple',
- (old_url, 'redirect_to', {'url': new_url}))
+urlpatterns += [url(old_url, RedirectView.as_view(url=new_url))
+ for old_url, new_url in legacy_urls]
+
+
+def show_urls(urllist=urlpatterns, depth=0):
+ for entry in urllist:
+ print " " * depth, entry.regex.pattern
+ if hasattr(entry, 'url_patterns'):
+ show_urls(entry.url_patterns, depth + 1)
# vim: set ts=4 sw=4 et: