urls.py

1
""" urls.py - URL configuration handler for Gitar.
2
    Copyright © 2016 Maarten "Vngngdn" Vangeneugden
3
4
    This program is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU Affero General Public License as
6
    published by the Free Software Foundation, either version 3 of the
7
    License, or (at your option) any later version.
8
9
    This program is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Affero General Public License for more details.
13
14
    You should have received a copy of the GNU Affero General Public License
15
    along with this program. If not, see https://www.gnu.org/licenses/agpl.html.
16
"""
17
18
from django.conf.urls import url
19
20
from . import views # Imports the views from the same directory (which is views.py).
21
22
urlpatterns = [
23
        url(r'^$', views.index, name='gitar-index'),
24
        url(r'^(?P<repository_name>\w+)$', views.repositories, name='gitar-repository'),
25
        url(r'^(?P<repository_name>\w+)/(?P<commit>[0-9a-f]{20})$', views.commit, name='gitar-commit'),
26
        url(r'^(?P<repository_name>\w+)/(?P<branch>\w+)$', views.repositories, name='gitar-repository'),
27
        url(r'^(?P<repository_name>\w+)/(?P<branch>\w+)/(?P<path>(.)+)$', views.path_explorer, name='gitar-path-explorer'),
28
29
        ]
30
# XXX: The URL patterns are a bit error-prone, and assume the repository is not
31
# named as if R2-D2 would. For example: a hexadecimal string of 20 characters
32
# is most likely a commit hash, but is a perfectly valid branch name, as well
33
# as a file AND directory name. But the chance of someone naming his/her branch
34
# like that is so unlikely I'd rather have it this way for now.
35