gitar

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.urls import path
19
20
from . import views # Imports the views from the same directory (which is views.py).
21
22
urlpatterns = [
23
    path('', views.index, name='gitar-index'),
24
    path('<str:repository_name>', views.repositories, name='gitar-repository'),
25
    path('<str:repository_name>/arbo/<str:branch>',
26
         views.repositories,
27
         name='gitar-repository'),
28
    path('<str:repository_name>/arbo/<str:branch>/<path:path>',
29
         views.path_explorer,
30
         name='gitar-path-explorer'),
31
    path('<str:repository_name>.git',
32
         views.download_git,
33
         name='gitar-download-git'),
34
    path('<str:repository_name>.tar.7z',
35
         views.download_tar,
36
         name='gitar-download-tar'),
37
    #path('<str:repository_name>/validigo/<githex:commit_hash>',
38
    path('<str:repository_name>/validigo/<slug:commit_hash>',
39
         views.commit,
40
         name='gitar-commit'),
41
    #path('<str:repository_name>/validigo/<githex:commit_hash>/<path:path_name>',
42
    path('<str:repository_name>/validigo/<slug:commit_hash>/<path:path_name>',
43
         views.file_commit,
44
         name='gitar-file-commit')
45
    ]
46
    
47
48
49
#PRE-2022 urlpatterns
50
"""
51
urlpatterns = [
52
        url(r'^$', views.index, name='gitar-index'),
53
        url(r'^(?P<repository_name>\w+)$', views.repositories, name='gitar-repository'),
54
        url(r'^(?P<repository_name>\w+)/(?P<commit>[0-9a-f]{20})$', views.commit, name='gitar-commit'),
55
        url(r'^(?P<repository_name>\w+)/(?P<branch>\w+)$', views.repositories, name='gitar-repository'),
56
        url(r'^(?P<repository_name>\w+)/(?P<branch>\w+)/(?P<path>(.)+)$', views.path_explorer, name='gitar-path-explorer'),
57
58
        ]
59
# XXX: The URL patterns are a bit error-prone, and assume the repository is not
60
# named as if R2-D2 would. For example: a hexadecimal string of 20 characters
61
# is most likely a commit hash, but is a perfectly valid branch name, as well
62
# as a file AND directory name. But the chance of someone naming his/her branch
63
# like that is so unlikely I'd rather have it this way for now.
64
"""
65