summaryrefslogtreecommitdiff
path: root/urls.py
blob: c35baedfab13e80afa2fa26313ecc64395ac86ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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.decorators.cache import cache_page
from django.views.generic import TemplateView, RedirectView

from feeds import PackageFeed, NewsFeed, ReleaseFeed
import sitemaps

our_sitemaps = {
    'base':           sitemaps.BaseSitemap,
    'news':           sitemaps.NewsSitemap,
    'packages':       sitemaps.PackagesSitemap,
    'package-files':  sitemaps.PackageFilesSitemap,
    'package-groups': sitemaps.PackageGroupsSitemap,
    'split-packages': sitemaps.SplitPackagesSitemap,
    'releases':       sitemaps.ReleasesSitemap,
}

news_sitemaps = { 'news': sitemaps.RecentNewsSitemap }

urlpatterns = []

# Public pages
urlpatterns += patterns('public.views',
    (r'^$', 'index', {}, 'index'),
    (r'^about/$', TemplateView.as_view(template_name='public/about.html'),
        {}, 'page-about'),
    (r'^art/$',   TemplateView.as_view(template_name='public/art.html'),
        {}, 'page-art'),
    (r'^svn/$',   TemplateView.as_view(template_name='public/svn.html'),
        {}, 'page-svn'),
    (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'),
    (r'^people/(?P<slug>[-\w]+)/$', 'people', {}, 'people'),
)

# Feeds patterns, used below
feeds_patterns = patterns('',
    (r'^$',          'public.views.feeds', {}, 'feeds-list'),
    (r'^news/$',     cache_page(311)(NewsFeed())),
    (r'^packages/$', cache_page(313)(PackageFeed())),
    (r'^packages/(?P<arch>[A-z0-9]+)/$',
        cache_page(313)(PackageFeed())),
    (r'^packages/all/(?P<repo>[A-z0-9\-]+)/$',
        cache_page(313)(PackageFeed())),
    (r'^packages/(?P<arch>[A-z0-9]+)/(?P<repo>[A-z0-9\-]+)/$',
        cache_page(313)(PackageFeed())),
    (r'^releases/$', cache_page(317)(ReleaseFeed())),
)

# Includes and other remaining stuff
urlpatterns += patterns('',
    (r'^admin/',     include(admin.site.urls)),
    (r'^devel/',     include('devel.urls')),
    (r'^feeds/',     include(feeds_patterns)),
    (r'^groups/',    include('packages.urls_groups')),
    (r'^mirrorlist/',include('mirrors.urls_mirrorlist')),
    (r'^mirrors/',   include('mirrors.urls')),
    (r'^news/',      include('news.urls')),
    (r'^packages/',  include('packages.urls')),
    (r'^releng/',    include('releng.urls')),
    (r'^todo/',      include('todolists.urls')),
    (r'^visualize/', include('visualize.urls')),
    (r'^opensearch/packages/$', 'packages.views.opensearch',
        {}, 'opensearch-packages'),
    (r'^opensearch/packages/suggest$', 'packages.views.opensearch_suggest',
        {}, 'opensearch-packages-suggest'),
)

# Retro home page views
urlpatterns += patterns('retro.views',
    (r'^retro/(?P<year>[0-9]{4})/$', 'retro_homepage', {}, 'retro-homepage'),
)

# Sitemaps
urlpatterns += patterns('',
    (r'^sitemap.xml$',
        cache_page(1831)(sitemap_views.index),
        {'sitemaps': our_sitemaps, 'sitemap_url_name': 'sitemaps'}),
    (r'^sitemap-(?P<section>.+)\.xml$',
        cache_page(1831)(sitemap_views.sitemap),
        {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml.jinja'},
        'sitemaps'),
    (r'^news-sitemap\.xml$',
        cache_page(1831)(sitemap_views.sitemap),
        {'sitemaps': news_sitemaps, 'template_name': 'sitemaps/news_sitemap.xml.jinja'},
        'news-sitemap'),
)

# 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',      '/people/developers/'),
    ('^donations.php', '/donate/'),
    ('^download.php',  '/download/'),
    ('^index.php',     '/'),
    ('^logos.php',     '/art/'),
    ('^news.php',      '/news/'),
    ('^packages.php',  '/packages/'),
    ('^people.php',    '/people/developers/'),
    ('^todolists/$',   '/todo/'),
    ('^developers/$',  '/people/developers/'),
    ('^fellows/$',     '/people/developer-fellows/'),
    ('^trustedusers/$', '/people/trusted-users/'),

    ('^docs/en/guide/install/arch-install-guide.html',
        'https://wiki.archlinux.org/index.php/Installation_guide'),
    ('^docs/en/',
        'https://wiki.archlinux.org/'),
    ('^docs/',
        'https://wiki.archlinux.org/'),
)

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: