gitar

Add URL paths in new style

Author
Maarten Vangeneugden
Date
Feb. 24, 2022, 3:45 p.m.
Hash
48b03ca424109f1fdc29843392583dd74af06a68
Parent
00ed8701811f6a77081cb03122397b131ca6fcb3
Modified file
urls.py

urls.py

26 additions and 1 deletion.

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