gitar

In the middle of an update: Adding commit support

While not completely ready, I've added the first steps of adding commits in Gitar, which is a pretty important part of a web project geared at Git repositories. But I also want to work on it on the go, so I added it to the tracker in this state already. Now I can also add the new message files as well.

Author
Maarten Vangeneugden
Date
March 6, 2022, 10 a.m.
Hash
b652e5f165894a130dddc4a420b25ce231cd48c0
Parent
48b03ca424109f1fdc29843392583dd74af06a68
Modified files
.gitignore
Commits.py
GitActions/CommitInfo.py
GitActions/FileInfo.py
GitActions/RepoInfo.py
GitActions/__init__.py
locale/af/LC_MESSAGES/django.po
locale/de/LC_MESSAGES/django.po
locale/eo/LC_MESSAGES/django.po
locale/es/LC_MESSAGES/django.po
locale/fr/LC_MESSAGES/django.po
locale/nl/LC_MESSAGES/django.po
templates/gitar/commit.djhtml
templates/gitar/directory.djhtml
templates/gitar/locale/af/LC_MESSAGES/django.po
templates/gitar/locale/de/LC_MESSAGES/django.po
templates/gitar/locale/eo/LC_MESSAGES/django.po
templates/gitar/locale/es/LC_MESSAGES/django.po
templates/gitar/locale/fr/LC_MESSAGES/django.po
templates/gitar/locale/nl/LC_MESSAGES/django.po
urls.py
views.py

.gitignore

2 additions and 0 deletions.

View changes Hide changes
1
1
migrations/
2
2
__pycache__/
3
3
# Init file for Python modules. Nope.
4
4
__init__.py  # 
5
5
# Ignore compiled message files
+
6
*.mo
+
7
*.mo

Commits.py

20 additions and 0 deletions.

View changes Hide changes
+
1
    Copyright © 2017 Maarten "Vngngdn" Vangeneugden
+
2
+
3
    This program is free software: you can redistribute it and/or modify
+
4
    it under the terms of the GNU Affero General Public License as
+
5
    published by the Free Software Foundation, either version 3 of the
+
6
    License, or (at your option) any later version.
+
7
+
8
    This program is distributed in the hope that it will be useful,
+
9
    but WITHOUT ANY WARRANTY; without even the implied warranty of
+
10
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+
11
    GNU Affero General Public License for more details.
+
12
+
13
    You should have received a copy of the GNU Affero General Public License
+
14
    along with this program. If not, see https://www.gnu.org/licenses/agpl.html.
+
15
"""
+
16
+
17
def changed_files(repo, commit):
+
18
    """ Returns a list of all the files that were changed in the given
+
19
    commit. """
+
20

GitActions/CommitInfo.py

8 additions and 0 deletions.

View changes Hide changes
+
1
# formatted file in a commit. 
+
2
+
3
# The function returns a list 
+
4
+
5
# If one line is removed, and one line is added, and both have the same line
+
6
# number, then that should be regarded as a changed line, not a removed+added line.
+
7
# This holds for each non-broken list of removed+added lines.
+
8

GitActions/FileInfo.py

19 additions and 17 deletions.

View changes Hide changes
1
1
2
2
from ..models import Repository
3
3
from . import RepoInfo
4
4
import git
5
5
+
6
6
7
7
8
def get_changing_commits(repository, file):
8
9
    """ Returns a list of all commits in which the file was changed.
9
10
    """
10
11
    presented_commits = get_presented_commits(repository, file)
11
12
12
13
13
14
def get_presented_commits(repository, file):
14
15
    """ Returns a dict with all branches where the given file is present.
15
16
    """
16
17
     branches = RepoInfo.get_commits(repository)
17
-
     present_branches = dict()
18
-
     for commits in branches:
19
-
         if
20
-
+
18
    present_branches = dict()
+
19
    for commits in branches:
+
20
        pass
+
21
21
22
def last_commit(repository, file):
22
-
    """ Returns the last commit in which this file occured.
+
23
    """ Returns the last commit in which this file occured.
23
24
    """
24
25
25
-
26
-
27
-
28
-
def file_in_commit(file, commit):
29
-
    """ Checks whether the given file blob is present in the commit object. """
30
-
    if (commit.tree.join(file)
31
-
    def file_in_tree(file, tree):
32
-
        """ Checks if the given file object exists in the tree object. """
33
-
        if file in tree.blobs:
34
-
            return True
35
-
        elif tree.trees
36
-
+
26
    #print(repository.directory_path)
+
27
    repo = pydriller.Repository(repository.directory_path, only_in_branch=branch)
+
28
    # Because traverse_commits() is a generator, I can't reverse the order, and
+
29
    # since it goes from oldest to latest, I have to traverse all commits and
+
30
    # store the last one that mentions that particular file.
+
31
    latest_commit = None
+
32
    for commit in repo.traverse_commits():
+
33
        for modified_file in commit.modified_files:
+
34
            #print("Comparing {} with {}".format(modified_file.new_path, file))
+
35
            if modified_file.new_path == file:
+
36
                latest_commit = commit
+
37
    return latest_commit
+
38

GitActions/RepoInfo.py

4 additions and 0 deletions.

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 ..models import Repository
18
18
import git
19
19
20
20
def get_description(repository):
21
21
    """ Returns the Git repo description of the given repository.
22
22
    """
23
23
    if isinstance(repository, Repository):
24
24
        repository = git.Repo(repository.directory_path)
25
25
26
26
    return repository.description
27
27
28
28
def log_message(repository, commit, simple=True):
29
29
    """ Returns the log message that was attached to the given commit.
30
30
31
31
    Keyword arguments:
32
32
    repository -- the repository in which to search
33
33
    commit     -- the specific commit hash
34
34
    simple     -- whether to return a oneliner, or the entire message (default True)
35
35
    """
36
36
    pass
37
37
38
38
39
39
def get_repository_object(repository_name):
+
40
    repository = Repository.objects.get(directory_path__endswith=repository_name+".git")
+
41
    return repository
+
42
    
+
43
def get_repository_object(repository_name):
40
44
    """ Checks the database for a repository with the same name, and returns a
41
45
    GitPython Repo object.
42
46
43
47
    Given the name of the repository, this function will search the database for
44
48
    a repository whoms name corresponds with the given name. When it found one, 
45
49
46
50
    Keyword arguments:
47
51
    repository_name -- The name of the repository
48
52
    """
49
53
    # Next line raises a Repository.DoesNotExist exception if not found, so it's
50
54
    # not necessary to check whether it was found or not.
51
55
    repository = Repository.objects.get(directory_path__endswith=repository_name+".git")
52
56
53
57
    return git.Repo(repository.directory_path)
54
58
55
59
def get_repository_model_object(repository_name):
56
60
    """ Functions identical to the get_repository_object, except that this
57
61
    function returns the Django model representation.
58
62
59
63
    Keyword arguments:
60
64
    repository_name -- The name of the repository
61
65
    """
62
66
    return Repository.objects.get(directory_path__endswith=repository_name+".git")
63
67
64
68
def read_file(file_blob):
65
69
    """ Reads the contents of the given file, and returns it in a list of
66
70
    strings.
67
71
68
72
    Reading the contents of a file using GitPython is a bit cumbersome. This
69
73
    function takes care of the hassle, and returns a list of unicode strings,
70
74
    allowing easy operations on the file's contents.
71
75
    """
72
76
73
77
    file_data_stream = file_blob.data_stream
74
78
    file_content = file_data_stream.read().decode("utf-8")
75
79
    file_formatted_content = []
76
80
    line = ""
77
81
    for character in file_content:
78
82
        if character != "\n":
79
83
            line = line + character
80
84
        else:
81
85
            file_formatted_content.append(line)
82
86
            line = ""
83
87
    return file_formatted_content
84
88
85
89
def get_branches(repository):
86
90
    """ Returns all branch objects of the repository.
87
91
    """
88
92
    return repository.heads
89
93
90
94
def get_branch_by_name(repository, name):
91
95
    """ Returns the branch of the repository with the given name.
92
96
    """
93
97
    heads = repository.heads
94
98
    for head in heads:
95
99
        if head.name == name:
96
100
            return head
97
101
98
102
def get_commits_of_all_branches(repository):
99
103
    """ Returns a dict with the keys being the branch names, and the values
100
104
    being their commits.
101
105
    """
102
106
    heads = repository.heads
103
107
    branches = dict()
104
108
    for head in heads:
105
109
        branches[head.name] = get_commits(repository, head.name)
106
110
    return branches
107
111
def get_commits(repository, branch="master"):
108
112
    """ Returns all commits of the given repository.
109
113
    If branch is unspecified, the commits of the master branch are returned.
110
114
    """
111
115
    return repository.iter_commits(branch)
112
116

GitActions/__init__.py

0 additions and 0 deletions.

View changes Hide changes

locale/af/LC_MESSAGES/django.po

29 additions and 0 deletions.

View changes Hide changes
+
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+
2
# This file is distributed under the same license as the PACKAGE package.
+
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+
4
#
+
5
#, fuzzy
+
6
msgid ""
+
7
msgstr ""
+
8
"Project-Id-Version: PACKAGE VERSION\n"
+
9
"Report-Msgid-Bugs-To: \n"
+
10
"POT-Creation-Date: 2022-03-06 07:38+0000\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+
13
"Language-Team: LANGUAGE <LL@li.org>\n"
+
14
"Language: \n"
+
15
"MIME-Version: 1.0\n"
+
16
"Content-Type: text/plain; charset=UTF-8\n"
+
17
"Content-Transfer-Encoding: 8bit\n"
+
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
19
+
20
#: gitar/views.py:38
+
21
msgid ""
+
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
+
23
"combination with the Django framework."
+
24
msgstr ""
+
25
+
26
#: gitar/views.py:42
+
27
msgid "Home page"
+
28
msgstr ""
+
29

locale/de/LC_MESSAGES/django.po

3 additions and 7 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2020-06-14 17:28+0200\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
19
20
20
#: gitar/views.py:34
21
-
msgid ""
+
21
msgid ""
22
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
23
23
"combination with the Django framework."
24
24
msgstr ""
25
25
26
26
#: gitar/views.py:39
27
-
msgid "Home page"
+
27
msgid "Home page"
28
28
msgstr ""
29
29
30
-
#: gitar/views.py:40
31
-
msgid "Source code"
32
-
msgstr ""
33
-

locale/eo/LC_MESSAGES/django.po

29 additions and 0 deletions.

View changes Hide changes
+
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+
2
# This file is distributed under the same license as the PACKAGE package.
+
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+
4
#
+
5
#, fuzzy
+
6
msgid ""
+
7
msgstr ""
+
8
"Project-Id-Version: PACKAGE VERSION\n"
+
9
"Report-Msgid-Bugs-To: \n"
+
10
"POT-Creation-Date: 2022-03-06 07:38+0000\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+
13
"Language-Team: LANGUAGE <LL@li.org>\n"
+
14
"Language: \n"
+
15
"MIME-Version: 1.0\n"
+
16
"Content-Type: text/plain; charset=UTF-8\n"
+
17
"Content-Transfer-Encoding: 8bit\n"
+
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
19
+
20
#: gitar/views.py:38
+
21
msgid ""
+
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
+
23
"combination with the Django framework."
+
24
msgstr ""
+
25
+
26
#: gitar/views.py:42
+
27
msgid "Home page"
+
28
msgstr ""
+
29

locale/es/LC_MESSAGES/django.po

3 additions and 7 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2020-06-14 17:28+0200\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
19
20
20
#: gitar/views.py:34
21
-
msgid ""
+
21
msgid ""
22
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
23
23
"combination with the Django framework."
24
24
msgstr ""
25
25
26
26
#: gitar/views.py:39
27
-
msgid "Home page"
+
27
msgid "Home page"
28
28
msgstr ""
29
29
30
-
#: gitar/views.py:40
31
-
msgid "Source code"
32
-
msgstr ""
33
-

locale/fr/LC_MESSAGES/django.po

5 additions and 6 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2020-06-14 17:28+0200\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
19
19
20
20
#: gitar/views.py:34
21
-
msgid ""
+
21
msgid ""
22
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
23
23
"combination with the Django framework."
24
24
msgstr ""
25
25
"Gitar est un application qui permet à ses utilisateurs de partager "
26
26
"facilement des repos Git, grace á le cadriciel Django."
27
27
28
28
#: gitar/views.py:39
29
-
msgid "Home page"
+
29
msgid "Home page"
30
30
msgstr "Page d'acceuil"
31
31
32
32
#: gitar/views.py:40
33
-
msgid "Source code"
34
-
msgstr "Code source"
35
-
+
33
#~ msgstr "Code source"
+
34

locale/nl/LC_MESSAGES/django.po

5 additions and 6 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2020-06-14 17:28+0200\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
19
20
20
#: gitar/views.py:34
21
-
msgid ""
+
21
msgid ""
22
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
23
23
"combination with the Django framework."
24
24
msgstr ""
25
25
"Gitar is een simpele web app dat gebruikers toelaat gemakkelijk Git-repo's "
26
26
"met elkaar te delen, in combinatie met Django."
27
27
28
28
#: gitar/views.py:39
29
-
msgid "Home page"
+
29
msgid "Home page"
30
30
msgstr "Homepage"
31
31
32
32
#: gitar/views.py:40
33
-
msgid "Source code"
34
-
msgstr "Broncode"
35
-
+
33
#~ msgstr "Broncode"
+
34

templates/gitar/commit.djhtml

95 additions and 0 deletions.

View changes Hide changes
+
1
{% load i18n %}
+
2
{% load humanize %}
+
3
{% load static %}
+
4
+
5
{% block title %}{{ repository_name }} | Gitar{% endblock title %}
+
6
+
7
{% block stylesheets %}
+
8
    {{ block.super }}
+
9
     <link href="{% static "website/gitar.css" %}" rel="stylesheet" media="screen, projection" />
+
10
{% endblock stylesheets %}
+
11
+
12
{% block description %}
+
13
{{ repository_name }} {{ commit.hash|truncatechars:10 }}: {{ commit.msg }}
+
14
{% endblock description %}
+
15
+
16
{% block header %}
+
17
<header>
+
18
    <h1>{{ repository_name }}</h1>  
+
19
    <label for="nav-drawer-toggle"></label>
+
20
</header>
+
21
{% endblock header %}
+
22
+
23
{% block main %}
+
24
<aside>
+
25
<dl>
+
26
    <dt>{% translate "Author" %}:</dt>
+
27
    <dd>{{ commit.author }}</dd>
+
28
</dl>
+
29
</aside>
+
30
+
31
<section class="emphasis">
+
32
    <h4>{{ commit.msg }}</h4>
+
33
    <p>{% translate "Commited by" %} {{ commit.author }} </p>
+
34
</section>
+
35
+
36
{% for mod_file in commit.modified_files %}
+
37
    <section style="font-family: 'Fira Code', monospace;">
+
38
        <h3>{{ mod_file.filename }}</h3>
+
39
        <table class="highlight">
+
40
            {% for line in file_html_code. %}
+
41
            <tr>
+
42
                <td id="{{ forloop.counter }}" class="line-number" style=":hover { background-color: #00E676;}">
+
43
                    <a style=":hover { background-color: #00e676;}" href="#{{ forloop.counter }}">
+
44
                    <pre>{{ forloop.counter }}</pre></a></td>
+
45
                <td><pre>{{ line|safe }}</pre></td>
+
46
            </tr>
+
47
            {% endfor %}
+
48
        </table>
+
49
    </section>
+
50
    <section>
+
51
    {# Determining whether we're dealing with an addition, modification or deletion #}
+
52
    {# {% if mod_file.change_type == "Added" %} #}
+
53
+
54
    <p>
+
55
    Voor {{ mod_file.filename }}
+
56
    {{ mod_file.source_code_before }}
+
57
    Na: 
+
58
    {{ mod_file.source_code }}
+
59
    </p>
+
60
+
61
    {% for row in rows %}
+
62
    {% if row.type == "deletion" %}
+
63
    <tr class="deletion">
+
64
    {% elif row.type == "addition" %}
+
65
    <tr class="addition">
+
66
    {% else %}
+
67
    <tr class="nochange">
+
68
    {% endif %}
+
69
        {% if row.type == "deletion" %}
+
70
        <td id="{{ row.old_num }}">{{ row.old_num }}</td>
+
71
        <td></td>
+
72
        {% elif row.type == "addition" %}
+
73
        <td></td>
+
74
        <td id="{{ row.new_num }}">{{ row.new_num }}</td>
+
75
        {% else %}
+
76
        <td id="{{ row.old_num }}">{{ row.old_num }}</td>
+
77
        <td id="{{ row.new_num }}">{{ row.new_num }}</td>
+
78
        {% endif %}
+
79
+
80
        }}">{{ row.old_num }}</td>
+
81
        {% else %} {# Not a change #}
+
82
        <td id="">
+
83
        </td>
+
84
+
85
    
+
86
    </tr>
+
87
    {% endfor %}
+
88
    
+
89
+
90
+
91
    </section>
+
92
{% endfor %}
+
93
+
94
{% endblock main %}
+
95

templates/gitar/directory.djhtml

35 additions and 1 deletion.

View changes Hide changes
1
1
{% load i18n %}
2
2
{% load static %}
+
3
{% load static %}
3
4
4
5
{% block title %}{{ repository_name }} | Gitar{% endblock title %}
5
6
6
7
{% block stylesheets %}
7
8
    {{ block.super }}
8
9
     <link href="{% static "website/gitar.css" %}" rel="stylesheet" media="screen, projection" />
9
10
{% endblock stylesheets %}
10
11
11
12
{% block description %}
12
13
{{repository_description}}
13
14
{% endblock description %}
14
15
15
16
{% block header %}
16
17
<header>                                                                                                                                                                                         
17
-
    <h1>{{ repository_name }}</h1>  
+
18
    <h1>{{ repository_name }}</h1>  
18
19
    <label for="nav-drawer-toggle"></label>
19
20
</header>
20
21
{% endblock header %}
21
22
22
23
{% block main %}
23
24
<section>
24
25
    <div class="row">
+
26
    <!--Tree contents-->
+
27
    <table>
+
28
        <thead>
+
29
            <tr>
+
30
                <th scope="col">{% translate "Name" %}</th>
+
31
                <th scope="col">{% translate "Latest commit" %}</th>
+
32
                <th scope="col">{% translate "Latest update" %}</th>
+
33
            </tr>
+
34
        </thead>
+
35
        <tbody>
+
36
            {% if subdirectories %}
+
37
            {% for subdirectory in subdirectories %}
+
38
            {% endfor %}
+
39
            {% endif %}
+
40
+
41
            {% for file in files %}
+
42
            <tr>
+
43
                <td><a href="{% url 'gitar-path-explorer' repository_name branch file.path %}">
+
44
                    {{ file.name }}</a></td>
+
45
                <td><a href="{% url 'gitar-commit' repository_name file.commit.hash %}">
+
46
                    {{ file.commit.msg }}</a></td>
+
47
                <td>{% if file.older_than_one_month %}
+
48
                    {{ file.commit.committer_date|date }}
+
49
                    {% else %}
+
50
                    {{ file.commit.committer_date|naturaltime }}
+
51
                    {% endif %}
+
52
                    </td>
+
53
            </tr>
+
54
            {% endfor %}
+
55
        </tbody>
+
56
    </table>
+
57
+
58
    <div class="row">
25
59
        <div class="col hide-on-med-and-down l4">
26
60
            <!-- Add tertiary information such as branches and licensing here.  -->
27
61
            <h3 class="{{mdc}}-text">{{repository_name}}</h3>
28
62
            <h5 class="{{mdc}}-text">{% trans "Description" %}</h5>
29
63
            {{repository_description}}
30
64
            <h5 class="{{mdc}}-text">{% trans "Branches" %}</h5>
31
65
            {% for bbranch in branches %}
32
66
            <a class="{{mdac}}-text text-accent-3" href="{% url 'gitar-repository' repository_name bbranch %}">
33
67
                {{bbranch}}
34
68
            </a><br />
35
69
            {% endfor %}
36
70
            <h5 class="{{mdc}}-text">{% trans "Extra information" %}</h5>
37
71
            <div class="chip">
38
72
                {{repository_language}}
39
73
                <i class="material-icons {{mdac}}-text text-accent-3">code</i>
40
74
            </div><br />
41
75
            <div class="chip">
42
76
                {{repository_license}}
43
77
                <i class="material-icons {{mdac}}-text text-accent-3">copyright</i>
44
78
            </div><br />
45
79
        </div>
46
80
        <div class="col s12 m8 l5">
47
81
            <!-- Main area with links to files and subdirectories -->
48
82
            <h3 class="{{mdc}}-text">{% trans "Files" %}</h3>
49
83
            <table class="highlight">
50
84
                {% if subdirectories %}
51
85
                <thead>
52
86
                    {% for subdirectory in subdirectories %}
53
87
                    <tr>
54
88
                        <th>
55
89
                        <a class="{{mdac}}-text text-accent-4" href="{% url 'gitar-path-explorer' repository_name branch subdirectory.path %}">
56
90
                            {{subdirectory.name}}
57
91
                        </a>
58
92
                        </th>
59
93
                    </tr>
60
94
                    {% endfor %}
61
95
                </thead>
62
96
                {% endif %}
63
97
                <tbody>
64
98
                    {% for file in files %}
65
99
                    <tr>
66
100
                        <td>
67
101
                        <a class="{{mdac}}-text text-accent-3" href="{% url 'gitar-path-explorer' repository_name branch file.path %}">
68
102
                            {{file.name}}
69
103
                        </a>
70
104
                        </td>
71
105
                            <td>{{file.commit|truncatechars:6}}</td>
72
106
                    </tr>
73
107
                    {% endfor %}
74
108
                </tbody>
75
109
            </table>
76
110
        </div>
77
111
        <div class="col hide-on-small-only m4 l3">
78
112
            <!-- List of commits on the current branch, chronologically. -->
79
113
            <h3 class="{{mdc}}-text">{% trans "Commits" %}</h3>
80
114
            {% for commit in commits %}
81
115
            <hr />
82
116
            <a
83
117
                class="{{mdac}}-text text-accent-3 tooltipped"
84
118
                {# href="{% url 'gitar-commit' repository_name commit.hash %}" #}
85
119
                data-position="left"
86
120
                data-delay="50"
87
121
                data-tooltip="Viewing commits is not implemented yet!">
88
122
                {{commit.hash|truncatechars:15}}
89
123
            </a>
90
124
            <span class="{{mdc}}-text text-lighten-2">
91
125
                {% trans "by" %} {{commit.author}}
92
126
            </span><br />
93
127
            {{commit.description|lower|capfirst}}{% if commit.description|last != "." %}.{% endif %}
94
128
            {% endfor %}
95
129
        </div>
96
130
    </div>
97
131
</section>
98
132
{% endblock main %}
99
133

templates/gitar/locale/af/LC_MESSAGES/django.po

118 additions and 0 deletions.

View changes Hide changes
+
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+
2
# This file is distributed under the same license as the PACKAGE package.
+
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+
4
#
+
5
#, fuzzy
+
6
msgid ""
+
7
msgstr ""
+
8
"Project-Id-Version: PACKAGE VERSION\n"
+
9
"Report-Msgid-Bugs-To: \n"
+
10
"POT-Creation-Date: 2022-03-06 07:38+0000\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+
13
"Language-Team: LANGUAGE <LL@li.org>\n"
+
14
"Language: \n"
+
15
"MIME-Version: 1.0\n"
+
16
"Content-Type: text/plain; charset=UTF-8\n"
+
17
"Content-Transfer-Encoding: 8bit\n"
+
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
19
+
20
#: gitar/templates/gitar/commit.djhtml:27
+
21
msgid "Author"
+
22
msgstr ""
+
23
+
24
#: gitar/templates/gitar/commit.djhtml:34
+
25
msgid "Commited by"
+
26
msgstr ""
+
27
+
28
#: gitar/templates/gitar/directory.djhtml:31
+
29
msgid "Name"
+
30
msgstr ""
+
31
+
32
#: gitar/templates/gitar/directory.djhtml:32
+
33
msgid "Latest commit"
+
34
msgstr ""
+
35
+
36
#: gitar/templates/gitar/directory.djhtml:33
+
37
msgid "Latest update"
+
38
msgstr ""
+
39
+
40
#: gitar/templates/gitar/directory.djhtml:63
+
41
msgid "Description"
+
42
msgstr ""
+
43
+
44
#: gitar/templates/gitar/directory.djhtml:65
+
45
msgid "Branches"
+
46
msgstr ""
+
47
+
48
#: gitar/templates/gitar/directory.djhtml:71
+
49
msgid "Extra information"
+
50
msgstr ""
+
51
+
52
#: gitar/templates/gitar/directory.djhtml:83
+
53
msgid "Files"
+
54
msgstr ""
+
55
+
56
#: gitar/templates/gitar/directory.djhtml:114
+
57
msgid "Commits"
+
58
msgstr ""
+
59
+
60
#: gitar/templates/gitar/directory.djhtml:126
+
61
msgid "by"
+
62
msgstr ""
+
63
+
64
#: gitar/templates/gitar/index.djhtml:5
+
65
msgid "Gitar | Index page"
+
66
msgstr ""
+
67
+
68
#: gitar/templates/gitar/index.djhtml:8
+
69
msgid "My personal answer to GitHub."
+
70
msgstr ""
+
71
+
72
#: gitar/templates/gitar/index.djhtml:29
+
73
msgid "Front page"
+
74
msgstr ""
+
75
+
76
#: gitar/templates/gitar/index.djhtml:39
+
77
msgid "About Gitar"
+
78
msgstr ""
+
79
+
80
#: gitar/templates/gitar/index.djhtml:41
+
81
msgid ""
+
82
"\n"
+
83
"\t\tGitar is a simple web app to easily host Git repositories using the "
+
84
"Django framework.\n"
+
85
"        It's a hobby project of me, to make it easy for\n"
+
86
"        people to scroll through the code I publish, in a read-only fashion. "
+
87
"It\n"
+
88
"        makes use of\n"
+
89
"        <a href=\"https://pygments.org/\" target=\"_blank\">Pygments</a>\n"
+
90
"        to read the source files, and apply the appropriate syntax "
+
91
"coloring.\n"
+
92
"        "
+
93
msgstr ""
+
94
+
95
#: gitar/templates/gitar/index.djhtml:51
+
96
msgid ""
+
97
"All repositories are automatically updated when changes\n"
+
98
"        have been pushed to the server, without any manual intervention from "
+
99
"me.\n"
+
100
"        Special attention goes to clean URL design, adhering to web "
+
101
"standards,\n"
+
102
"        and responsive design across all screen types."
+
103
msgstr ""
+
104
+
105
#: gitar/templates/gitar/index.djhtml:57
+
106
msgid ""
+
107
"Gitar <b>is a project under development!</b>\n"
+
108
"        While it's certainly presentable, there's still a lot of room for "
+
109
"improvement.<br />\n"
+
110
"        Also, if you happen to walk in while I'm working, it's possible "
+
111
"you'll\n"
+
112
"        fall through the floor, so be warned =D"
+
113
msgstr ""
+
114
+
115
#: gitar/templates/gitar/index.djhtml:64
+
116
msgid "Public repositories"
+
117
msgstr ""
+
118

templates/gitar/locale/de/LC_MESSAGES/django.po

41 additions and 22 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2018-04-09 20:09+0000\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
19
20
20
#: gitar/templates/gitar/directory.html:16
21
-
msgid "Description"
+
21
msgid "Author"
+
22
msgstr ""
+
23
+
24
#: gitar/templates/gitar/commit.djhtml:34
+
25
msgid "Commited by"
+
26
msgstr ""
+
27
+
28
#: gitar/templates/gitar/directory.djhtml:31
+
29
msgid "Name"
+
30
msgstr ""
+
31
+
32
#: gitar/templates/gitar/directory.djhtml:32
+
33
msgid "Latest commit"
+
34
msgstr ""
+
35
+
36
#: gitar/templates/gitar/directory.djhtml:33
+
37
msgid "Latest update"
+
38
msgstr ""
+
39
+
40
#: gitar/templates/gitar/directory.djhtml:63
+
41
msgid "Description"
22
42
msgstr ""
23
43
24
44
#: gitar/templates/gitar/directory.html:18
25
-
msgid "Branches"
+
45
msgid "Branches"
26
46
msgstr ""
27
47
28
48
#: gitar/templates/gitar/directory.html:24
29
-
msgid "Extra information"
+
49
msgid "Extra information"
30
50
msgstr ""
31
51
32
52
#: gitar/templates/gitar/directory.html:36
33
-
msgid "Files"
+
53
msgid "Files"
34
54
msgstr ""
35
55
36
56
#: gitar/templates/gitar/directory.html:67
37
-
msgid "Commits"
+
57
msgid "Commits"
38
58
msgstr ""
39
59
40
60
#: gitar/templates/gitar/directory.html:79
41
-
msgid "by"
+
61
msgid "by"
42
62
msgstr ""
43
63
44
64
#: gitar/templates/gitar/index.html:4
45
-
msgid "Gitar | Index page"
+
65
msgid "Gitar | Index page"
46
66
msgstr ""
47
67
48
68
#: gitar/templates/gitar/index.html:6
49
-
msgid "My personal answer to GitHub."
+
69
msgid "My personal answer to GitHub."
50
70
msgstr ""
51
71
52
72
#: gitar/templates/gitar/index.html:13
53
-
msgid ""
54
-
"Gitar is a simple web app to easily host Git repositories using the Django "
55
-
"framework."
56
-
msgstr ""
+
73
msgid "Front page"
+
74
msgstr ""
57
75
58
76
#: gitar/templates/gitar/index.html:17
59
-
msgid "About Gitar"
+
77
msgid "About Gitar"
60
78
msgstr ""
61
79
62
80
#: gitar/templates/gitar/index.html:19
63
-
#, python-format
64
-
msgid ""
+
81
msgid ""
65
82
"Gitar is a hobby project of me, to make it easy for\n"
66
-
"        people to scroll through the code I publish, in a read-only fashion. "
+
83
"\t\tGitar is a simple web app to easily host Git repositories using the "
+
84
"Django framework.\n"
+
85
"        It's a hobby project of me, to make it easy for\n"
+
86
"        people to scroll through the code I publish, in a read-only fashion. "
67
87
"It\n"
68
88
"        makes use of\n"
69
89
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
70
-
"\">Pygments</a>\n"
71
-
"        to read the source files, and apply the appropriate syntax "
+
90
"        to read the source files, and apply the appropriate syntax "
72
91
"coloring.\n"
73
92
"        "
74
93
msgstr ""
75
94
76
95
#: gitar/templates/gitar/index.html:27
77
-
msgid ""
+
96
msgid ""
78
97
"All repositories are automatically updated when changes\n"
79
98
"        have been pushed to the server, without any manual intervention from "
80
99
"me.\n"
81
100
"        Special attention goes to clean URL design, adhering to web "
82
101
"standards,\n"
83
102
"        and responsive design across all screen types."
84
103
msgstr ""
85
104
86
105
#: gitar/templates/gitar/index.html:32
87
-
msgid ""
+
106
msgid ""
88
107
"Gitar <b>is a project under development!</b>\n"
89
108
"        While it's certainly presentable, there's still a lot of room for "
90
109
"improvement.<br />\n"
91
110
"        Also, if you happen to walk in while I'm working, it's possible "
92
111
"you'll\n"
93
112
"        fall through the floor, so be warned =D"
94
113
msgstr ""
95
114
96
115
#: gitar/templates/gitar/index.html:39
97
-
msgid "Public repositories"
+
116
msgid "Public repositories"
98
117
msgstr ""
99
118

templates/gitar/locale/eo/LC_MESSAGES/django.po

118 additions and 0 deletions.

View changes Hide changes
+
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+
2
# This file is distributed under the same license as the PACKAGE package.
+
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+
4
#
+
5
#, fuzzy
+
6
msgid ""
+
7
msgstr ""
+
8
"Project-Id-Version: PACKAGE VERSION\n"
+
9
"Report-Msgid-Bugs-To: \n"
+
10
"POT-Creation-Date: 2022-03-06 07:38+0000\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+
13
"Language-Team: LANGUAGE <LL@li.org>\n"
+
14
"Language: \n"
+
15
"MIME-Version: 1.0\n"
+
16
"Content-Type: text/plain; charset=UTF-8\n"
+
17
"Content-Transfer-Encoding: 8bit\n"
+
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
19
+
20
#: gitar/templates/gitar/commit.djhtml:27
+
21
msgid "Author"
+
22
msgstr ""
+
23
+
24
#: gitar/templates/gitar/commit.djhtml:34
+
25
msgid "Commited by"
+
26
msgstr ""
+
27
+
28
#: gitar/templates/gitar/directory.djhtml:31
+
29
msgid "Name"
+
30
msgstr ""
+
31
+
32
#: gitar/templates/gitar/directory.djhtml:32
+
33
msgid "Latest commit"
+
34
msgstr ""
+
35
+
36
#: gitar/templates/gitar/directory.djhtml:33
+
37
msgid "Latest update"
+
38
msgstr ""
+
39
+
40
#: gitar/templates/gitar/directory.djhtml:63
+
41
msgid "Description"
+
42
msgstr ""
+
43
+
44
#: gitar/templates/gitar/directory.djhtml:65
+
45
msgid "Branches"
+
46
msgstr ""
+
47
+
48
#: gitar/templates/gitar/directory.djhtml:71
+
49
msgid "Extra information"
+
50
msgstr ""
+
51
+
52
#: gitar/templates/gitar/directory.djhtml:83
+
53
msgid "Files"
+
54
msgstr ""
+
55
+
56
#: gitar/templates/gitar/directory.djhtml:114
+
57
msgid "Commits"
+
58
msgstr ""
+
59
+
60
#: gitar/templates/gitar/directory.djhtml:126
+
61
msgid "by"
+
62
msgstr ""
+
63
+
64
#: gitar/templates/gitar/index.djhtml:5
+
65
msgid "Gitar | Index page"
+
66
msgstr ""
+
67
+
68
#: gitar/templates/gitar/index.djhtml:8
+
69
msgid "My personal answer to GitHub."
+
70
msgstr ""
+
71
+
72
#: gitar/templates/gitar/index.djhtml:29
+
73
msgid "Front page"
+
74
msgstr ""
+
75
+
76
#: gitar/templates/gitar/index.djhtml:39
+
77
msgid "About Gitar"
+
78
msgstr ""
+
79
+
80
#: gitar/templates/gitar/index.djhtml:41
+
81
msgid ""
+
82
"\n"
+
83
"\t\tGitar is a simple web app to easily host Git repositories using the "
+
84
"Django framework.\n"
+
85
"        It's a hobby project of me, to make it easy for\n"
+
86
"        people to scroll through the code I publish, in a read-only fashion. "
+
87
"It\n"
+
88
"        makes use of\n"
+
89
"        <a href=\"https://pygments.org/\" target=\"_blank\">Pygments</a>\n"
+
90
"        to read the source files, and apply the appropriate syntax "
+
91
"coloring.\n"
+
92
"        "
+
93
msgstr ""
+
94
+
95
#: gitar/templates/gitar/index.djhtml:51
+
96
msgid ""
+
97
"All repositories are automatically updated when changes\n"
+
98
"        have been pushed to the server, without any manual intervention from "
+
99
"me.\n"
+
100
"        Special attention goes to clean URL design, adhering to web "
+
101
"standards,\n"
+
102
"        and responsive design across all screen types."
+
103
msgstr ""
+
104
+
105
#: gitar/templates/gitar/index.djhtml:57
+
106
msgid ""
+
107
"Gitar <b>is a project under development!</b>\n"
+
108
"        While it's certainly presentable, there's still a lot of room for "
+
109
"improvement.<br />\n"
+
110
"        Also, if you happen to walk in while I'm working, it's possible "
+
111
"you'll\n"
+
112
"        fall through the floor, so be warned =D"
+
113
msgstr ""
+
114
+
115
#: gitar/templates/gitar/index.djhtml:64
+
116
msgid "Public repositories"
+
117
msgstr ""
+
118

templates/gitar/locale/es/LC_MESSAGES/django.po

41 additions and 22 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2018-04-09 20:09+0000\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
19
20
20
#: gitar/templates/gitar/directory.html:16
21
-
msgid "Description"
+
21
msgid "Author"
+
22
msgstr ""
+
23
+
24
#: gitar/templates/gitar/commit.djhtml:34
+
25
msgid "Commited by"
+
26
msgstr ""
+
27
+
28
#: gitar/templates/gitar/directory.djhtml:31
+
29
msgid "Name"
+
30
msgstr ""
+
31
+
32
#: gitar/templates/gitar/directory.djhtml:32
+
33
msgid "Latest commit"
+
34
msgstr ""
+
35
+
36
#: gitar/templates/gitar/directory.djhtml:33
+
37
msgid "Latest update"
+
38
msgstr ""
+
39
+
40
#: gitar/templates/gitar/directory.djhtml:63
+
41
msgid "Description"
22
42
msgstr ""
23
43
24
44
#: gitar/templates/gitar/directory.html:18
25
-
msgid "Branches"
+
45
msgid "Branches"
26
46
msgstr ""
27
47
28
48
#: gitar/templates/gitar/directory.html:24
29
-
msgid "Extra information"
+
49
msgid "Extra information"
30
50
msgstr ""
31
51
32
52
#: gitar/templates/gitar/directory.html:36
33
-
msgid "Files"
+
53
msgid "Files"
34
54
msgstr ""
35
55
36
56
#: gitar/templates/gitar/directory.html:67
37
-
msgid "Commits"
+
57
msgid "Commits"
38
58
msgstr ""
39
59
40
60
#: gitar/templates/gitar/directory.html:79
41
-
msgid "by"
+
61
msgid "by"
42
62
msgstr ""
43
63
44
64
#: gitar/templates/gitar/index.html:4
45
-
msgid "Gitar | Index page"
+
65
msgid "Gitar | Index page"
46
66
msgstr ""
47
67
48
68
#: gitar/templates/gitar/index.html:6
49
-
msgid "My personal answer to GitHub."
+
69
msgid "My personal answer to GitHub."
50
70
msgstr ""
51
71
52
72
#: gitar/templates/gitar/index.html:13
53
-
msgid ""
54
-
"Gitar is a simple web app to easily host Git repositories using the Django "
55
-
"framework."
56
-
msgstr ""
+
73
msgid "Front page"
+
74
msgstr ""
57
75
58
76
#: gitar/templates/gitar/index.html:17
59
-
msgid "About Gitar"
+
77
msgid "About Gitar"
60
78
msgstr ""
61
79
62
80
#: gitar/templates/gitar/index.html:19
63
-
#, python-format
64
-
msgid ""
+
81
msgid ""
65
82
"Gitar is a hobby project of me, to make it easy for\n"
66
-
"        people to scroll through the code I publish, in a read-only fashion. "
+
83
"\t\tGitar is a simple web app to easily host Git repositories using the "
+
84
"Django framework.\n"
+
85
"        It's a hobby project of me, to make it easy for\n"
+
86
"        people to scroll through the code I publish, in a read-only fashion. "
67
87
"It\n"
68
88
"        makes use of\n"
69
89
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
70
-
"\">Pygments</a>\n"
71
-
"        to read the source files, and apply the appropriate syntax "
+
90
"        to read the source files, and apply the appropriate syntax "
72
91
"coloring.\n"
73
92
"        "
74
93
msgstr ""
75
94
76
95
#: gitar/templates/gitar/index.html:27
77
-
msgid ""
+
96
msgid ""
78
97
"All repositories are automatically updated when changes\n"
79
98
"        have been pushed to the server, without any manual intervention from "
80
99
"me.\n"
81
100
"        Special attention goes to clean URL design, adhering to web "
82
101
"standards,\n"
83
102
"        and responsive design across all screen types."
84
103
msgstr ""
85
104
86
105
#: gitar/templates/gitar/index.html:32
87
-
msgid ""
+
106
msgid ""
88
107
"Gitar <b>is a project under development!</b>\n"
89
108
"        While it's certainly presentable, there's still a lot of room for "
90
109
"improvement.<br />\n"
91
110
"        Also, if you happen to walk in while I'm working, it's possible "
92
111
"you'll\n"
93
112
"        fall through the floor, so be warned =D"
94
113
msgstr ""
95
114
96
115
#: gitar/templates/gitar/index.html:39
97
-
msgid "Public repositories"
+
116
msgid "Public repositories"
98
117
msgstr ""
99
118

templates/gitar/locale/fr/LC_MESSAGES/django.po

63 additions and 26 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
msgid ""
6
6
msgstr ""
7
7
"Project-Id-Version: \n"
8
8
"Report-Msgid-Bugs-To: \n"
9
9
"POT-Creation-Date: 2018-04-09 20:09+0000\n"
10
-
"PO-Revision-Date: 2021-10-30 16:05+0200\n"
+
10
"PO-Revision-Date: 2021-10-30 16:05+0200\n"
11
11
"Language: fr\n"
+
12
"Language-Team: \n"
+
13
"Language: fr\n"
12
14
"MIME-Version: 1.0\n"
13
15
"Content-Type: text/plain; charset=UTF-8\n"
14
16
"Content-Transfer-Encoding: 8bit\n"
15
17
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
16
18
"Last-Translator: \n"
17
-
"Language-Team: \n"
18
-
"X-Generator: Poedit 3.0\n"
19
19
20
20
#: gitar/templates/gitar/directory.html:16
21
-
msgid "Description"
+
21
msgid "Author"
+
22
msgstr ""
+
23
+
24
#: gitar/templates/gitar/commit.djhtml:34
+
25
#, fuzzy
+
26
#| msgid "Commits"
+
27
msgid "Commited by"
+
28
msgstr "Commits"
+
29
+
30
#: gitar/templates/gitar/directory.djhtml:31
+
31
msgid "Name"
+
32
msgstr ""
+
33
+
34
#: gitar/templates/gitar/directory.djhtml:32
+
35
msgid "Latest commit"
+
36
msgstr ""
+
37
+
38
#: gitar/templates/gitar/directory.djhtml:33
+
39
msgid "Latest update"
+
40
msgstr ""
+
41
+
42
#: gitar/templates/gitar/directory.djhtml:63
+
43
msgid "Description"
22
44
msgstr "Description"
23
45
24
46
#: gitar/templates/gitar/directory.html:18
25
-
msgid "Branches"
+
47
msgid "Branches"
26
48
msgstr "Branches"
27
49
28
50
#: gitar/templates/gitar/directory.html:24
29
-
msgid "Extra information"
+
51
msgid "Extra information"
30
52
msgstr "Information additionel"
31
53
32
54
#: gitar/templates/gitar/directory.html:36
33
-
msgid "Files"
+
55
msgid "Files"
34
56
msgstr "Fichiers"
35
57
36
58
#: gitar/templates/gitar/directory.html:67
37
-
msgid "Commits"
+
59
msgid "Commits"
38
60
msgstr "Commits"
39
61
40
62
#: gitar/templates/gitar/directory.html:79
41
-
msgid "by"
+
63
msgid "by"
42
64
msgstr "par"
43
65
44
66
#: gitar/templates/gitar/index.html:4
45
-
msgid "Gitar | Index page"
+
67
msgid "Gitar | Index page"
46
68
msgstr "Gitar | Page d'acceuil"
47
69
48
70
#: gitar/templates/gitar/index.html:6
49
-
msgid "My personal answer to GitHub."
+
71
msgid "My personal answer to GitHub."
50
72
msgstr "Mon réponse personnel á GitHub."
51
73
52
74
#: gitar/templates/gitar/index.html:13
53
-
msgid ""
54
-
"Gitar is a simple web app to easily host Git repositories using the Django "
55
-
"framework."
56
-
msgstr ""
+
75
msgid "Front page"
+
76
msgstr ""
57
77
"Gitar est une simple application web pour héberger facilement les dépôts Git "
58
-
"en utilisant le cadre logiciel Django."
59
-
60
78
#: gitar/templates/gitar/index.html:17
61
-
msgid "About Gitar"
+
79
msgid "About Gitar"
62
80
msgstr "À propos de Gitar"
63
81
64
82
#: gitar/templates/gitar/index.html:19
65
-
#, python-format
66
-
msgid ""
+
83
#, fuzzy
+
84
#| msgid ""
+
85
#| "Gitar is a hobby project of me, to make it easy for\n"
+
86
#| "        people to scroll through the code I publish, in a read-only "
+
87
#| "fashion. It\n"
+
88
#| "        makes use of\n"
+
89
#| "        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments."
+
90
#| "org/\">Pygments</a>\n"
+
91
#| "        to read the source files, and apply the appropriate syntax "
+
92
#| "coloring.\n"
+
93
#| "        "
+
94
msgid ""
67
95
"Gitar is a hobby project of me, to make it easy for\n"
68
-
"        people to scroll through the code I publish, in a read-only fashion. "
+
96
"\t\tGitar is a simple web app to easily host Git repositories using the "
+
97
"Django framework.\n"
+
98
"        It's a hobby project of me, to make it easy for\n"
+
99
"        people to scroll through the code I publish, in a read-only fashion. "
69
100
"It\n"
70
101
"        makes use of\n"
71
102
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
72
-
"\">Pygments</a>\n"
73
-
"        to read the source files, and apply the appropriate syntax "
+
103
"        to read the source files, and apply the appropriate syntax "
74
104
"coloring.\n"
75
105
"        "
76
106
msgstr ""
77
107
"Gitar est un projet hobby de moi, pour rendre facile pour les gens de faire "
78
108
"défiler le code que je publie, d'une manière simple. Il utilise <a class="
79
109
"\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/\">Pygments</a> "
80
110
"pour lire les fichiers sources, et appliquer la coloration de syntaxe "
81
111
"appropriée."
82
112
83
113
#: gitar/templates/gitar/index.html:27
84
-
msgid ""
+
114
msgid ""
85
115
"All repositories are automatically updated when changes\n"
86
116
"        have been pushed to the server, without any manual intervention from "
87
117
"me.\n"
88
118
"        Special attention goes to clean URL design, adhering to web "
89
119
"standards,\n"
90
120
"        and responsive design across all screen types."
91
121
msgstr ""
92
122
"Tous les dépôts sont automatiquement mis à jour lorsque des changements ont "
93
123
"été poussés sur le serveur, sans aucune intervention manuelle de moi. Une "
94
124
"attention particulière va à la conception d'URL propre, adhérant aux normes "
95
125
"Web, et la conception réactive de tous les types d'écran."
96
126
97
127
#: gitar/templates/gitar/index.html:32
98
-
msgid ""
+
128
msgid ""
99
129
"Gitar <b>is a project under development!</b>\n"
100
130
"        While it's certainly presentable, there's still a lot of room for "
101
131
"improvement.<br />\n"
102
132
"        Also, if you happen to walk in while I'm working, it's possible "
103
133
"you'll\n"
104
134
"        fall through the floor, so be warned =D"
105
135
msgstr ""
106
136
"Gitar est un projet <strong>en cours de développement!</strong> Bien qu'il "
107
137
"soit certainement présentable, il y a encore beaucoup de place pour "
108
138
"l'amélioration.<br>\n"
109
139
"Aussi, si vous arrivez à marcher pendant que je travaille, il est possible "
110
140
"que vous allez\n"
111
141
"tombez par terre, alors soyez prudent =D"
112
142
113
143
#: gitar/templates/gitar/index.html:39
114
-
msgid "Public repositories"
+
144
msgid "Public repositories"
115
145
msgstr "Repositories public"
116
146
+
147
#~ msgid ""
+
148
#~ "Gitar is a simple web app to easily host Git repositories using the "
+
149
#~ "Django framework."
+
150
#~ msgstr ""
+
151
#~ "Gitar est une simple application web pour héberger facilement les dépôts "
+
152
#~ "Git en utilisant le cadre logiciel Django."
+
153

templates/gitar/locale/nl/LC_MESSAGES/django.po

61 additions and 24 deletions.

View changes Hide changes
1
1
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2
2
# This file is distributed under the same license as the PACKAGE package.
3
3
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
4
#
5
5
#, fuzzy
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version: PACKAGE VERSION\n"
9
9
"Report-Msgid-Bugs-To: \n"
10
10
"POT-Creation-Date: 2018-04-09 20:09+0000\n"
11
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
"Language-Team: LANGUAGE <LL@li.org>\n"
14
14
"Language: \n"
15
15
"MIME-Version: 1.0\n"
16
16
"Content-Type: text/plain; charset=UTF-8\n"
17
17
"Content-Transfer-Encoding: 8bit\n"
18
18
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
19
20
20
#: gitar/templates/gitar/directory.html:16
21
-
msgid "Description"
+
21
msgid "Author"
+
22
msgstr ""
+
23
+
24
#: gitar/templates/gitar/commit.djhtml:34
+
25
#, fuzzy
+
26
#| msgid "Commits"
+
27
msgid "Commited by"
+
28
msgstr "Commits"
+
29
+
30
#: gitar/templates/gitar/directory.djhtml:31
+
31
msgid "Name"
+
32
msgstr ""
+
33
+
34
#: gitar/templates/gitar/directory.djhtml:32
+
35
msgid "Latest commit"
+
36
msgstr ""
+
37
+
38
#: gitar/templates/gitar/directory.djhtml:33
+
39
msgid "Latest update"
+
40
msgstr ""
+
41
+
42
#: gitar/templates/gitar/directory.djhtml:63
+
43
msgid "Description"
22
44
msgstr "Beschrijving"
23
45
24
46
#: gitar/templates/gitar/directory.html:18
25
-
msgid "Branches"
+
47
msgid "Branches"
26
48
msgstr "Takken"
27
49
28
50
#: gitar/templates/gitar/directory.html:24
29
-
msgid "Extra information"
+
51
msgid "Extra information"
30
52
msgstr "Extra informatie"
31
53
32
54
#: gitar/templates/gitar/directory.html:36
33
-
msgid "Files"
+
55
msgid "Files"
34
56
msgstr "Bestanden"
35
57
36
58
#: gitar/templates/gitar/directory.html:67
37
-
msgid "Commits"
+
59
msgid "Commits"
38
60
msgstr "Commits"
39
61
40
62
#: gitar/templates/gitar/directory.html:79
41
-
msgid "by"
+
63
msgid "by"
42
64
msgstr "door"
43
65
44
66
#: gitar/templates/gitar/index.html:4
45
-
msgid "Gitar | Index page"
+
67
msgid "Gitar | Index page"
46
68
msgstr "Gitar | Hoofdpagina"
47
69
48
70
#: gitar/templates/gitar/index.html:6
49
-
msgid "My personal answer to GitHub."
+
71
msgid "My personal answer to GitHub."
50
72
msgstr "Mijn persoonlijke antwoord op Github."
51
73
52
74
#: gitar/templates/gitar/index.html:13
53
-
msgid ""
54
-
"Gitar is a simple web app to easily host Git repositories using the Django "
55
-
"framework."
56
-
msgstr ""
+
75
msgid "Front page"
+
76
msgstr ""
57
77
"Gitar is een simpele web app om gemakkelijk Git-repo's te hosten met behulp "
58
-
"van het Django-framework."
59
-
60
78
#: gitar/templates/gitar/index.html:17
61
-
msgid "About Gitar"
+
79
msgid "About Gitar"
62
80
msgstr "Over Gitar"
63
81
64
82
#: gitar/templates/gitar/index.html:19
65
-
#, python-format
66
-
msgid ""
+
83
#, fuzzy
+
84
#| msgid ""
+
85
#| "Gitar is a hobby project of me, to make it easy for\n"
+
86
#| "        people to scroll through the code I publish, in a read-only "
+
87
#| "fashion. It\n"
+
88
#| "        makes use of\n"
+
89
#| "        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments."
+
90
#| "org/\">Pygments</a>\n"
+
91
#| "        to read the source files, and apply the appropriate syntax "
+
92
#| "coloring.\n"
+
93
#| "        "
+
94
msgid ""
67
95
"Gitar is a hobby project of me, to make it easy for\n"
68
-
"        people to scroll through the code I publish, in a read-only fashion. "
+
96
"\t\tGitar is a simple web app to easily host Git repositories using the "
+
97
"Django framework.\n"
+
98
"        It's a hobby project of me, to make it easy for\n"
+
99
"        people to scroll through the code I publish, in a read-only fashion. "
69
100
"It\n"
70
101
"        makes use of\n"
71
102
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
72
-
"\">Pygments</a>\n"
73
-
"        to read the source files, and apply the appropriate syntax "
+
103
"        to read the source files, and apply the appropriate syntax "
74
104
"coloring.\n"
75
105
"        "
76
106
msgstr ""
77
107
"Gitar is een persoonlijk hobbyproject, om het makkelijk te maken voor mensen "
78
108
"om door mijn code te scrollen, zoals deze in mijn repo's te zien is. Het "
79
109
"maakt gebruik van <a class=\"%(mdac)s-text text-accent-3\" href=\"http://"
80
110
"pygments.org/\">Pygments</a> om de code te lezen, en de juiste "
81
111
"syntaxkleuring toe te passen."
82
112
83
113
#: gitar/templates/gitar/index.html:27
84
-
msgid ""
+
114
msgid ""
85
115
"All repositories are automatically updated when changes\n"
86
116
"        have been pushed to the server, without any manual intervention from "
87
117
"me.\n"
88
118
"        Special attention goes to clean URL design, adhering to web "
89
119
"standards,\n"
90
120
"        and responsive design across all screen types."
91
121
msgstr ""
92
122
"Alle repositories worden automatisch geüpdatet als er veranderingen naar de "
93
123
"server gestuurd worden, zonder manuele toedracht van mijn kant. Er wordt "
94
124
"aandacht besteedt aan het maken van propere en duidelijke URL's, het volgen "
95
125
"van de juiste webstandaarden, en een gebruiksvriendelijk ontwerp op alle "
96
126
"soorten schermen."
97
127
98
128
#: gitar/templates/gitar/index.html:32
99
-
msgid ""
+
129
msgid ""
100
130
"Gitar <b>is a project under development!</b>\n"
101
131
"        While it's certainly presentable, there's still a lot of room for "
102
132
"improvement.<br />\n"
103
133
"        Also, if you happen to walk in while I'm working, it's possible "
104
134
"you'll\n"
105
135
"        fall through the floor, so be warned =D"
106
136
msgstr ""
107
137
"Gitar <b>is een project dat nog niet af is!</b>\n"
108
138
"Alheowel het presentabel is, is er nog meer dan genoeg ruimte voor "
109
139
"verbetering. Het kan dus zijn dat ik aan het prullen ben, en de website "
110
140
"plots ineenstort, je bent gewaarschuwd. ;)"
111
141
112
142
#: gitar/templates/gitar/index.html:39
113
-
msgid "Public repositories"
+
143
msgid "Public repositories"
114
144
msgstr "Publieke repositories"
115
145
+
146
#~ msgid ""
+
147
#~ "Gitar is a simple web app to easily host Git repositories using the "
+
148
#~ "Django framework."
+
149
#~ msgstr ""
+
150
#~ "Gitar is een simpele web app om gemakkelijk Git-repo's te hosten met "
+
151
#~ "behulp van het Django-framework."
+
152

urls.py

10 additions and 5 deletions.

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

views.py

57 additions and 8 deletions.

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.shortcuts import get_object_or_404, render  # This allows to render the template with the view here. It's pretty cool and important.
18
18
from django.http import HttpResponseRedirect, HttpResponse
19
19
from django.urls import reverse
20
20
from .models import *
21
21
22
22
from .GitActions import RepoInfo
23
-
from django.utils.translation import ugettext as _
+
23
from django.utils.translation import ugettext as _
24
24
25
25
from django.utils.translation import ugettext as _
26
26
from git import Repo  # GitPython functionality.
27
27
import git
28
28
+
29
+
30
import datetime
+
31
29
32
from .syntax import *
30
33
31
34
# First, I list some standard variables that are common for most of the sites of this app.
32
35
33
36
def footer_description():
34
37
    return _("Gitar is a simple web app that allows its users to easily share Git repos in combination with the Django framework.")
35
38
36
39
def footer_links():
37
40
    footer_links = [
38
41
            #['Source', 'OHGODHELPNOTDONEYET'],
39
-
            [_('Home page'), reverse('about-index')],
40
42
            [_('Source code'), reverse('gitar-repository', kwargs={'repository_name':'gitar'})],
41
-
            ]
+
43
            ]
42
44
    return footer_links
43
45
44
46
def standard_context():
45
47
    context = {
46
48
            'navbar_title': "Gitar",
47
49
            'navbar_backArrow': False,
48
50
            'footer_title': "Gitar",
49
51
            'footer_description': footer_description(),
50
52
            'footer_links': footer_links(),
51
53
            'stylesheet_name': "gitar",
52
54
            }
53
55
    return context
54
56
55
57
# From here, the actual views start.
+
58
    pass
+
59
def download_git(request):
+
60
    pass
+
61
def commit(request, repository_name, commit_hash):
+
62
    template = "gitar/commit.djhtml"
+
63
+
64
    repository_model = RepoInfo.get_repository_model(repository_name)
+
65
    commit_repo = pydriller.Repository(repository_model.directory_path, single=commit_hash)
+
66
    context = standard_context()
+
67
    file_html_code = dict()
+
68
    for c in commit_repo.traverse_commits():
+
69
        context["commit"] = c
+
70
        for modified_file in c.modified_files:
+
71
            html_code_before = None
+
72
            html_code = None
+
73
            if modified_file.source_code_before is not None:
+
74
                html_code_before = code_to_HTML(
+
75
                    modified_file.source_code_before,
+
76
                    modified_file.filename)
+
77
            if modified_file.source_code is not None:
+
78
                html_code = code_to_HTML(
+
79
                    modified_file.source_code,
+
80
                    modified_file.filename)
+
81
            # XXX: This function WILL OVERWRITE the presented code of a file if
+
82
            # this particular commit includes multiple files with the same name,
+
83
            # but a different path. I'll update this in the future...
+
84
            file_html_code[modified_file.filename] = (html_code_before, html_code)
+
85
    context["file_html_code"] = file_html_code
+
86
            
+
87
    #context["subdirectories"] = subdirectories
+
88
    #context["commits"] = commits
+
89
    #context["branch"] = branch
+
90
    context["repository_name"] = repository_name
+
91
    # Adding the html code for the files
+
92
    context["file_html_code"]
+
93
    #context["repository_description"] = repository.description
+
94
    html_code = code_to_HTML(raw_file_data, file.name)
+
95
+
96
    return render(request, template, context)
+
97
             
+
98
def file_commit(request):
+
99
    pass
+
100
+
101
# From here, the actual views start.
56
102
def index(request):
57
103
    """ The start page of Gitar.
58
104
59
105
    The goal of this view, is to collect all the available repositories,
60
106
    including some additional information, such as programming language,
61
107
    license, description, ... in order to give a fast overview of the most
62
108
    prominent information.
63
109
    """
64
110
65
111
    # Collecting the available repositories:
66
112
    # Template:
67
113
    template = "gitar/index.djhtml"
68
114
    # Requesting the repositories:
69
115
    modelRepos = Repository.objects.all()
70
116
    # From here, we start collecting info about all the repositories:
71
117
    class BlankRepository: pass  # Blank object in which all data will be collected.
72
118
    repositories = []
73
119
    for modelRepo in modelRepos:
74
120
        repository = BlankRepository()
75
121
        # TODO: Find a way to add all of modelRepo's fields without having to
76
122
        # hardcode them. This is prone to errors and is redundant.
77
123
        repository.name = str(modelRepo)
78
124
        repository.programmingLanguage = modelRepo.programmingLanguage
79
125
        repository.license = modelRepo.license
80
126
        repository.description = RepoInfo.get_description(modelRepo)
81
127
82
128
        #gitRepo = Repo.init(modelRepo.directory(), bare=True)  # Connects to the Git Repo.
83
129
        # See tests.py, which assures all repositories exist. Tests are handy.
84
130
        #repository.description = gitRepo.description
85
131
        # This is mostly personal taste, but I like to show the amount of files.
86
132
        #repoTree = gitRepo.heads.master.commit.tree
87
133
        #repository.fileCount = len(repoTree.blobs)  # blobs are files.
88
134
        repositories.append(repository)
89
135
    # After that, I extend the standard context with the repositories:
90
136
    context = standard_context()
91
137
    context['repositories'] = repositories
92
138
    # And finally, sending everything back.
93
139
    return render(request, template, context)
94
140
95
141
def commit(request, repository, commit):
96
-
    pass  # TODO
97
-
98
-
def repositories(request, repository_name, branch="master"):
99
142
    # A repo's root is a directory by default, so this will automatically return
100
143
    # a directory view. But still, this is a bit nicer.
101
144
    return path_explorer(request, repository_name, branch, "")
102
145
103
146
def path_explorer(request, repository_name, branch, path):
104
-
    """ Checks whether the given path is a file or a directory, and calls the
+
147
    """ Checks whether the given path is a file or a directory, and calls the
105
148
    appropriate view function accordingly.
106
149
    """
107
150
    repository = RepoInfo.get_repository_object(repository_name)
108
151
    # From the GitPython documentation:
109
152
    # You can obtain the tree object of a repository, which is the directory of
110
153
    # that repo. This tree can be accessed as if it were a native Python list,
111
154
    # where the elements are the subdirectories and files. So, the idea to
112
155
    # determine whether a file, or a directory was requested, is simple:
113
156
    # 1. Split the path with "/" as seperator.
114
157
    # 2. Replace the current tree variable with the one retrieved from the
115
158
    # subtree element
116
159
    # 3. Repeat 2. until all parts of the given path are exhausted.
117
160
    # If we now still have a tree, we're looking at a directory, so display the
118
161
    # files (and subdirectories) of this directory.
119
162
    # Else, if we hit a blob, display the file contents.
120
163
    path_parts = path.split(sep="/")
121
164
    # FIXME: This is a bug at the URL regex part that I haven't been able to fix
122
165
    # yet. This serves as a temporary fix:
123
166
    # If the last part of the path is an empty string (which happens when the
124
167
    # last symbol was a '/'), remove that part from the list.
125
168
    # Of course, this is bad monkeypatching, but I suck at regex, so as long as
126
169
    # I don't find the solution, this'll have to do.
127
170
128
171
129
172
    #print(path_parts)
130
173
131
174
    if path_parts[len(path_parts)-1] == "":
132
175
        path_parts.pop()
133
176
134
177
    if len(path_parts) == 0:
135
178
        directory = repository.heads[branch].commit.tree
136
179
        return directory_view(request, repository_name, branch, path, directory)
137
180
138
181
    assert len(path_parts) != 0
139
182
140
183
    # FIXME: If the user gives a "<something>/../<somethingElse>", that should
141
184
    # become "<something>". Obviously, although I think that's done by default
142
185
    # already.
143
186
    directory = repository.heads[branch].commit.tree
144
187
    for i in range(len(path_parts)):
145
188
        subdirectories = directory.trees
146
189
        #if len(subdirectories) == 0:
147
190
            # This can't happen, as this would imply there is a directory inside
148
191
            # a file.
149
192
        #    assert False
150
193
        #else:
151
194
        for subdirectory in subdirectories:
152
195
            if subdirectory.name == path_parts[i]:
153
196
                directory = subdirectory
154
197
                #break  # Useless optimization
155
198
    # When there are no more directories to traverse, check if the last part of
156
199
    # the path is either a file, or a directory:
157
200
    blobs = directory.blobs
158
201
    #print(path_parts)
159
202
    last_part = path_parts[len(path_parts)-1]
160
203
    for blob in directory.blobs:
161
204
        #print(blob.name)
162
205
        if blob.name == last_part:
163
206
            file_blob = blob
164
207
            #print("Returning file view")
165
208
            return file_view(request, repository_name, branch, path, file_blob)
166
209
        else:
167
210
            pass
168
211
            #print("blob name: " + blob.name)
169
212
            #print("last part: " + last_part)
170
213
    return directory_view(request, repository_name, branch, path, directory)
171
214
172
215
def directory_view(request, repository_name, branch, path, directory):
173
216
    """ Collects the given directories's files and subdirectories, and renders a
174
217
    template to display this data.
175
218
    """
176
219
177
220
    # Collecting files in this directory
178
221
    repository = RepoInfo.get_repository_object(repository_name)
179
222
    files = []
180
223
    for file in directory.blobs:
181
224
        files.append({
+
225
        older_than_one_month = (datetime.datetime.now(datetime.timezone.utc) - latest_commit_object.committer_date).days > 30
+
226
        print(latest_commit_object)
+
227
        files.append({
182
228
            "name":file.name,
183
229
            "path":file.path,
184
230
            "commit":"",#FileInfo.last_commit(repository, file).hexsha[:20],
185
-
            })
+
231
            "commit": latest_commit_object,
+
232
            "older_than_one_month": older_than_one_month,
+
233
            })
186
234
    # Collecting commits for this branch
+
235
    # Collecting commits for this branch
187
236
    commits = []
188
237
    for commit in repository.iter_commits(branch):
189
238
        commits.append({
190
239
            "hash":commit.hexsha[:20],
191
240
            "author":commit.author,
192
241
            "description":commit.summary,
193
242
            })
194
243
    # Collecting subdirectories
195
244
    subdirectories = []
196
245
    for subdirectory in directory.trees:
197
246
        subdirectories.append({
198
247
            "path":subdirectory.path,
199
248
            "name":subdirectory.name,
200
249
            })
201
250
    # Collecting rendering information:
202
251
    template = "gitar/directory.djhtml"
203
252
    context = standard_context()
204
253
    context["files"] = files
205
254
    context["subdirectories"] = subdirectories
206
255
    context["commits"] = commits
207
256
    context["branch"] = branch
208
257
    context["repository_name"] = repository_name
209
258
    context["repository_description"] = repository.description
210
259
    # Collection repo information
211
260
    for repo in Repository.objects.all():
212
261
        if str(repo) == repository_name:
213
262
            context["repository_language"] = repo.programmingLanguage
214
263
            context["repository_license"] = repo.license
215
264
            break
216
265
    branches = []
217
266
    for bbranch in repository.heads:
218
267
        branches.append(bbranch.name)
219
268
    context["branches"] = branches
220
269
    return render(request, template, context)
221
270
222
271
223
272
def file_view(request, repository_name, branch, path, file):
224
273
    """ Collects the file contents of the given file path, and returns it to the
225
274
    template, with the file contents already formatted in HTML using Pygments.
226
275
    """
227
276
228
277
    # Turning the file's contents in HTML ready output:
229
278
    raw_file_data = file.data_stream.read()
230
279
    html_code = code_to_HTML(raw_file_data, file.name)
231
280
    # Collecting rendering information:
232
281
    template = "gitar/file.djhtml"
233
282
    context = standard_context()
234
283
    context["content"] = html_code
235
284
    context["file_name"] = file.name
236
285
    context["repository_name"] = repository_name
237
286
    return render(request, template, context)
238
287
    
239
288