gitar

Apparently a lot of changes =o

Author
Maarten Vangeneugden
Date
Sept. 10, 2020, 11:27 p.m.
Hash
a95db70d50b8bfc4e06210bb403a603676eb9cad
Parent
757ce47c23372f81564e095c137e32c1df4eaa6c
Modified files
locale/de/LC_MESSAGES/django.po
locale/es/LC_MESSAGES/django.po
locale/fr/LC_MESSAGES/django.po
locale/nl/LC_MESSAGES/django.po
templates/gitar/directory.html
templates/gitar/file.html
templates/gitar/header.html
templates/gitar/index.html
templates/gitar/locale/de/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
templates/gitar/repositories.html
tests.py
views.py

locale/de/LC_MESSAGES/django.po

5 additions and 4 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: 2017-10-19 18:27+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
#: gitar/views.py:33
20
-
msgid ""
+
20
#: gitar/views.py:34
+
21
msgid ""
21
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
22
23
"combination with the Django framework."
23
24
msgstr ""
24
25
25
26
#: gitar/views.py:38
26
-
msgid "Home page"
+
27
msgid "Home page"
27
28
msgstr ""
28
29
29
30
#: gitar/views.py:39
30
-
msgid "Source code"
+
31
msgid "Source code"
31
32
msgstr ""
32
33

locale/es/LC_MESSAGES/django.po

5 additions and 4 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: 2017-10-19 18:27+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
#: gitar/views.py:33
20
-
msgid ""
+
20
#: gitar/views.py:34
+
21
msgid ""
21
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
22
23
"combination with the Django framework."
23
24
msgstr ""
24
25
25
26
#: gitar/views.py:38
26
-
msgid "Home page"
+
27
msgid "Home page"
27
28
msgstr ""
28
29
29
30
#: gitar/views.py:39
30
-
msgid "Source code"
+
31
msgid "Source code"
31
32
msgstr ""
32
33

locale/fr/LC_MESSAGES/django.po

7 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: 2017-10-19 18:27+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
#: gitar/views.py:33
20
-
msgid ""
+
20
#: gitar/views.py:34
+
21
msgid ""
21
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
22
23
"combination with the Django framework."
23
24
msgstr ""
24
25
"Gitar est un application qui permet à ses utilisateurs de partager facilement "
25
-
"des repos Git, grace á le cadriciel Django."
26
-
+
26
"facilement des repos Git, grace á le cadriciel Django."
+
27
27
28
#: gitar/views.py:38
28
-
msgid "Home page"
+
29
msgid "Home page"
29
30
msgstr "Page d'acceuil"
30
31
31
32
#: gitar/views.py:39
32
-
msgid "Source code"
+
33
msgid "Source code"
33
34
msgstr "Code source"
34
35

locale/nl/LC_MESSAGES/django.po

7 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: 2017-10-19 18:27+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
#: gitar/views.py:33
20
-
msgid ""
+
20
#: gitar/views.py:34
+
21
msgid ""
21
22
"Gitar is a simple web app that allows its users to easily share Git repos in "
22
23
"combination with the Django framework."
23
24
msgstr ""
24
25
"Gitar is een simpele <i>web app</i> dat gebruikers toelaat gemakkelijk "
25
-
"Git-repo's met elkaar te delen, in combinatie met Django."
26
-
+
26
"met elkaar te delen, in combinatie met Django."
+
27
27
28
#: gitar/views.py:38
28
-
msgid "Home page"
+
29
msgid "Home page"
29
30
msgstr "Homepage"
30
31
31
32
#: gitar/views.py:39
32
-
msgid "Source code"
+
33
msgid "Source code"
33
34
msgstr "Broncode"
34
35

templates/gitar/directory.html

0 additions and 87 deletions.

View changes Hide changes
1
-
{% load i18n %}
2
-
{% block title %}{{ repository_name }} | Gitar{% endblock title %}
3
-
{% block description %}
4
-
{{repository_description}}
5
-
{% endblock description %}
6
-
{% block main %}
7
-
{% with mdac=materialDesign_accentColor mdc=materialDesign_color %} {# You'll see why this is handy shortly. #}
8
-
<div class="section {{ materialDesign_color }} lighten-2">
9
-
</div>
10
-
<div class="section">
11
-
    <div class="row">
12
-
        <div class="col hide-on-med-and-down l4">
13
-
            <!-- Add tertiary information such as branches and licensing here.  -->
14
-
            <h3 class="{{mdc}}-text">{{repository_name}}</h3>
15
-
            <h5 class="{{mdc}}-text">{% trans "Description" %}</h5>
16
-
            {{repository_description}}
17
-
            <h5 class="{{mdc}}-text">{% trans "Branches" %}</h5>
18
-
            {% for bbranch in branches %}
19
-
            <a class="{{mdac}}-text text-accent-3" href="{% url 'gitar-repository' repository_name bbranch %}">
20
-
                {{bbranch}}
21
-
            </a><br />
22
-
            {% endfor %}
23
-
            <h5 class="{{mdc}}-text">{% trans "Extra information" %}</h5>
24
-
            <div class="chip">
25
-
                {{repository_language}}
26
-
                <i class="material-icons {{mdac}}-text text-accent-3">code</i>
27
-
            </div><br />
28
-
            <div class="chip">
29
-
                {{repository_license}}
30
-
                <i class="material-icons {{mdac}}-text text-accent-3">copyright</i>
31
-
            </div><br />
32
-
        </div>
33
-
        <div class="col s12 m8 l5">
34
-
            <!-- Main area with links to files and subdirectories -->
35
-
            <h3 class="{{mdc}}-text">{% trans "Files" %}</h3>
36
-
            <table class="highlight">
37
-
                {% if subdirectories %}
38
-
                <thead>
39
-
                    {% for subdirectory in subdirectories %}
40
-
                    <tr>
41
-
                        <th>
42
-
                        <a class="{{mdac}}-text text-accent-4" href="{% url 'gitar-path-explorer' repository_name branch subdirectory.path %}">
43
-
                            {{subdirectory.name}}
44
-
                        </a>
45
-
                        </th>
46
-
                    </tr>
47
-
                    {% endfor %}
48
-
                </thead>
49
-
                {% endif %}
50
-
                <tbody>
51
-
                    {% for file in files %}
52
-
                    <tr>
53
-
                        <td>
54
-
                        <a class="{{mdac}}-text text-accent-3" href="{% url 'gitar-path-explorer' repository_name branch file.path %}">
55
-
                            {{file.name}}
56
-
                        </a>
57
-
                        </td>
58
-
                            <td>{{file.commit|truncatechars:6}}</td>
59
-
                    </tr>
60
-
                    {% endfor %}
61
-
                </tbody>
62
-
            </table>
63
-
        </div>
64
-
        <div class="col hide-on-small-only m4 l3">
65
-
            <!-- List of commits on the current branch, chronologically. -->
66
-
            <h3 class="{{mdc}}-text">{% trans "Commits" %}</h3>
67
-
            {% for commit in commits %}
68
-
            <hr />
69
-
            <a
70
-
                class="{{mdac}}-text text-accent-3 tooltipped"
71
-
                {# href="{% url 'gitar-commit' repository_name commit.hash %}" #}
72
-
                data-position="left"
73
-
                data-delay="50"
74
-
                data-tooltip="Viewing commits is not implemented yet!">
75
-
                {{commit.hash|truncatechars:15}}
76
-
            </a>
77
-
            <span class="{{mdc}}-text text-lighten-2">
78
-
                {% trans "by" %} {{commit.author}}
79
-
            </span><br />
80
-
            {{commit.description|lower|capfirst}}{% if commit.description|last != "." %}.{% endif %}
81
-
            {% endfor %}
82
-
        </div>
83
-
    </div>
84
-
</div>
85
-
{% endwith %}
86
-
{% endblock main %}
87
-

templates/gitar/file.html

0 additions and 59 deletions.

View changes Hide changes
1
-
2
-
{% block title %}{{repository_name}}/{{file_name}} | Gitar{% endblock title %}
3
-
4
-
{% block stylesheets %}
5
-
<link href="/static/website/materialize/css/google-icons.css" rel="stylesheet" />
6
-
<link href="/static/website/materialize/css/materialize.css" rel="stylesheet" media="screen, projection" />
7
-
<!--<link rel="stylesheet href="https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css">-->
8
-
<!-- TODO: Download Fira Code stylesheet and serve via the static folder!
9
-
    This is necessary BEFORE activating the Fira Code ligature font, because
10
-
    using a CDN I do not controll brings in tonnes of JS code from Google,
11
-
    Amazon, and whatnot. -->
12
-
<!--<style>
13
-
td {
14
-
	padding: 0 0 0 0;
15
-
}
16
-
pre {
17
-
	margin-top: 10px;
18
-
	margin-bottom: 10px;
19
-
}
20
-
table {
21
-
	line-height: 0px;
22
-
	padding-top: 0px;
23
-
	padding-bottom: 0px;
24
-
	border-spacing: 0 0;
25
-
	margin-top: 0px;
26
-
	margin-bottom: 0px;
27
-
}
28
-
</style>-->
29
-
{# For the syntax coloring of Gitar. TODO for later. #}
30
-
<link rel="stylesheet" type="text/css" href="/static/website/syntax.css" />
31
-
<link rel="stylesheet" type="text/css" href="/static/gitar/css/file.css" />
32
-
{% endblock stylesheets %}
33
-
34
-
{% block description %}
35
-
Content of {{file_name}} in {{repository_name}}
36
-
{% endblock description %}
37
-
{% block main %}
38
-
{% with mdac=materialDesign_accentColor mdc=materialDesign_color %} {# You'll see why this is handy shortly. #}
39
-
<div class="section {{ materialDesign_color }} lighten-2">
40
-
</div>
41
-
<div class="container section" style="font-family: 'Fira Code', monospace;">
42
-
    <h3 class="{{mdac}}-text text-accent-3">{{file_name}}</h3>
43
-
	<table class="highlight">
44
-
		{% for line in content %}
45
-
		<tr>
46
-
			  <td id="{{ forloop.counter }}" class="line-number"
47
-
                                    style=":hover { background-color: #00E676;}">
48
-
            <a
49
-
                class="{{mdc}}-text"
50
-
                style="a:hover { background-color: #00e676;}"
51
-
                href="#{{ forloop.counter }}">
52
-
                <pre>{{ forloop.counter }}</pre></a></td>
53
-
			<td><pre>{{ line|safe }}</pre></td>
54
-
		</tr>
55
-
		{% endfor %}
56
-
	</table>
57
-
{% endwith %}
58
-
{% endblock main %}
59
-

templates/gitar/header.html

0 additions and 36 deletions.

View changes Hide changes
1
-
	Copyright 2015 Maarten Vangeneugden
2
-
3
-
	Licensed under the Apache License, Version 2.0 (the "License");
4
-
	you may not use this file except in compliance with the License.
5
-
	You may obtain a copy of the License at
6
-
7
-
	   https://www.apache.org/licenses/LICENSE-2.0
8
-
9
-
	Unless required by applicable law or agreed to in writing, software
10
-
	distributed under the License is distributed on an "AS IS" BASIS,
11
-
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-
	See the License for the specific language governing permissions and
13
-
	limitations under the License.
14
-
{% endcomment %}
15
-
<!DOCTYPE html>
16
-
<html>
17
-
	<head>
18
-
		<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
19
-
		<link href="/static/website/materialize/css/materialize.css" rel="stylesheet" media="screen, projection" />
20
-
		<meta charset="utf-8" /> <!-- Just in case you didn't know ASCII sucks. -->
21
-
		<meta name="author" content="Vngngdn (Maarten Vangeneugden)"> <!-- Yep, yours truly. Forward any solliciting to /dev/null. -->
22
-
		<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <!--Because this page is suited for mobile devices.-->
23
-
		<meta name="description" content="Vngngdn's personal web page. That should intrigue you enough to get over here." />
24
-
	</head>
25
-
	<body>
26
-
		{# This is actually the navigation bar. Perhaps it should be in its own template file. #}
27
-
		<header>
28
-
			<div class="navbar-fixed"> <!-- Fixes the navbar to the top. I like that. -->
29
-
				<nav>
30
-
					<div class="nav-wrapper blue"> <!-- I admit this looks redundant, but hey, at least it's not DreamWeaver. -->
31
-
						<a class="brand-logo">Vngngdn</a>
32
-
					</div>
33
-
				</nav>
34
-
			</div>
35
-
		</header>
36
-

templates/gitar/index.html

0 additions and 65 deletions.

View changes Hide changes
1
-
{% load i18n %}
2
-
3
-
{% block title %}{% trans "Gitar | Index page" %}{% endblock title %}
4
-
{% block description %}
5
-
{% trans "My personal answer to GitHub." %}
6
-
{% endblock description %}
7
-
{% block main %}
8
-
{% with mdac=materialDesign_accentColor %} {# You'll see why this is handy shortly. #}
9
-
{% with mdc=materialDesign_color %}
10
-
<div class="section {{ materialDesign_color }} lighten-2">
11
-
	<p class="flow-text container white-text">
12
-
		{% trans "Gitar is a simple web app to easily host Git repositories using the Django framework. %}
13
-
	</p>
14
-
</div>
15
-
<div class="container section">
16
-
    <h3 class="{{ materialDesign_color }}-text">{% trans "About Gitar" %}</h3>
17
-
    <p>
18
-
        {% blocktrans %}Gitar is a hobby project of me, to make it easy for
19
-
        people to scroll through the code I publish, in a read-only fashion. It
20
-
        makes use of
21
-
        <a class="{{ mdac }}-text text-accent-3" href="http://pygments.org/">Pygments</a>
22
-
        to read the source files, and apply the appropriate syntax coloring.
23
-
        {% endblocktrans %}
24
-
    </p>
25
-
    <p>
26
-
        {% blocktrans %}All repositories are automatically updated when changes
27
-
        have been pushed to the server, without any manual intervention from me.
28
-
        Special attention goes to clean URL design, adhering to web standards,
29
-
        and responsive design across all screen types.{% endblocktrans %}
30
-
    <p>
31
-
        {% blocktrans %}Gitar <b>is a project under development!</b>
32
-
        While it's certainly presentable, there's still a lot of room for improvement.<br />
33
-
        Also, if you happen to walk in while I'm working, it's possible you'll
34
-
        fall through the floor, so be warned =D{% endblocktrans %}
35
-
    </p>
36
-
</div>
37
-
<div class="container section">
38
-
    <h3 class="{{ materialDesign_color }}-text">{% trans "Public repositories" %}</h3>
39
-
		{% for repository in repositories %} {# ARGH DON'T YOU LOVE THE READABILITY #}
40
-
        <div class="row">
41
-
            <div class="col m3 valign-wrapper">
42
-
                <a class="valign waves-effect btn white {{ mdac }} accent-3" href="{% url 'gitar-repository' repository_name=repository.name %}">
43
-
                    {{ repository.name }}
44
-
                </a>
45
-
            </div>
46
-
            <div class="col m7">
47
-
                <p> {{ repository.description }} </p>
48
-
            </div>
49
-
            <div class="col m2">
50
-
            <ul>
51
-
                <li><i class="material-icons {{ mdac }}-text text-accent-3">code</i>
52
-
                    {{ repository.programmingLanguage }}</li>
53
-
                <!--<li><i class="material-icons">description</i> 
54
-
                    {{ repository.fileCount }}</li>-->
55
-
                <li><i class="material-icons {{ mdc }}-text">copyright</i>
56
-
                    {{ repository.license }}</li>
57
-
            </ul>
58
-
            </div>
59
-
        </div>
60
-
		{% endfor %}
61
-
	</div>
62
-
{% endwith %}
63
-
{% endwith %}
64
-
{% endblock main %}
65
-

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

8 additions and 1 deletion.

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: 2017-10-19 18:27+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
#: gitar/templates/gitar/directory.html:16
+
20
#: gitar/templates/gitar/directory.html:16
20
21
msgid "Description"
21
22
msgstr ""
22
23
23
24
#: gitar/templates/gitar/directory.html:18
24
25
msgid "Branches"
25
26
msgstr ""
26
27
27
28
#: gitar/templates/gitar/directory.html:24
28
29
msgid "Extra information"
29
30
msgstr ""
30
31
31
32
#: gitar/templates/gitar/directory.html:36
32
33
msgid "Files"
33
34
msgstr ""
34
35
35
36
#: gitar/templates/gitar/directory.html:67
36
37
msgid "Commits"
37
38
msgstr ""
38
39
39
40
#: gitar/templates/gitar/directory.html:79
40
41
msgid "by"
41
42
msgstr ""
42
43
43
44
#: gitar/templates/gitar/index.html:4
44
45
msgid "Gitar | Index page"
45
46
msgstr ""
46
47
47
48
#: gitar/templates/gitar/index.html:6
48
49
msgid "My personal answer to GitHub."
49
50
msgstr ""
50
51
51
52
#: gitar/templates/gitar/index.html:17
+
53
msgid ""
+
54
"Gitar is a simple web app to easily host Git repositories using the Django "
+
55
"framework."
+
56
msgstr ""
+
57
+
58
#: gitar/templates/gitar/index.html:17
52
59
msgid "About Gitar"
53
60
msgstr ""
54
61
55
62
#: gitar/templates/gitar/index.html:19
56
63
#, python-format
57
64
msgid ""
58
65
"Gitar is a hobby project of me, to make it easy for\n"
59
66
"        people to scroll through the code I publish, in a read-only fashion. "
60
67
"It\n"
61
68
"        makes use of\n"
62
69
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
63
70
"\">Pygments</a>\n"
64
71
"        to read the source files, and apply the appropriate syntax "
65
72
"coloring.\n"
66
73
"        "
67
74
msgstr ""
68
75
69
76
#: gitar/templates/gitar/index.html:27
70
77
msgid ""
71
78
"All repositories are automatically updated when changes\n"
72
79
"        have been pushed to the server, without any manual intervention from "
73
80
"me.\n"
74
81
"        Special attention goes to clean URL design, adhering to web "
75
82
"standards,\n"
76
83
"        and responsive design across all screen types."
77
84
msgstr ""
78
85
79
86
#: gitar/templates/gitar/index.html:32
80
87
msgid ""
81
88
"Gitar <b>is a project under development!</b>\n"
82
89
"        While it's certainly presentable, there's still a lot of room for "
83
90
"improvement.<br />\n"
84
91
"        Also, if you happen to walk in while I'm working, it's possible "
85
92
"you'll\n"
86
93
"        fall through the floor, so be warned =D"
87
94
msgstr ""
88
95
89
96
#: gitar/templates/gitar/index.html:39
90
97
msgid "Public repositories"
91
98
msgstr ""
92
99

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

8 additions and 1 deletion.

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: 2017-10-19 18:27+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
#: gitar/templates/gitar/directory.html:16
+
20
#: gitar/templates/gitar/directory.html:16
20
21
msgid "Description"
21
22
msgstr ""
22
23
23
24
#: gitar/templates/gitar/directory.html:18
24
25
msgid "Branches"
25
26
msgstr ""
26
27
27
28
#: gitar/templates/gitar/directory.html:24
28
29
msgid "Extra information"
29
30
msgstr ""
30
31
31
32
#: gitar/templates/gitar/directory.html:36
32
33
msgid "Files"
33
34
msgstr ""
34
35
35
36
#: gitar/templates/gitar/directory.html:67
36
37
msgid "Commits"
37
38
msgstr ""
38
39
39
40
#: gitar/templates/gitar/directory.html:79
40
41
msgid "by"
41
42
msgstr ""
42
43
43
44
#: gitar/templates/gitar/index.html:4
44
45
msgid "Gitar | Index page"
45
46
msgstr ""
46
47
47
48
#: gitar/templates/gitar/index.html:6
48
49
msgid "My personal answer to GitHub."
49
50
msgstr ""
50
51
51
52
#: gitar/templates/gitar/index.html:17
+
53
msgid ""
+
54
"Gitar is a simple web app to easily host Git repositories using the Django "
+
55
"framework."
+
56
msgstr ""
+
57
+
58
#: gitar/templates/gitar/index.html:17
52
59
msgid "About Gitar"
53
60
msgstr ""
54
61
55
62
#: gitar/templates/gitar/index.html:19
56
63
#, python-format
57
64
msgid ""
58
65
"Gitar is a hobby project of me, to make it easy for\n"
59
66
"        people to scroll through the code I publish, in a read-only fashion. "
60
67
"It\n"
61
68
"        makes use of\n"
62
69
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
63
70
"\">Pygments</a>\n"
64
71
"        to read the source files, and apply the appropriate syntax "
65
72
"coloring.\n"
66
73
"        "
67
74
msgstr ""
68
75
69
76
#: gitar/templates/gitar/index.html:27
70
77
msgid ""
71
78
"All repositories are automatically updated when changes\n"
72
79
"        have been pushed to the server, without any manual intervention from "
73
80
"me.\n"
74
81
"        Special attention goes to clean URL design, adhering to web "
75
82
"standards,\n"
76
83
"        and responsive design across all screen types."
77
84
msgstr ""
78
85
79
86
#: gitar/templates/gitar/index.html:32
80
87
msgid ""
81
88
"Gitar <b>is a project under development!</b>\n"
82
89
"        While it's certainly presentable, there's still a lot of room for "
83
90
"improvement.<br />\n"
84
91
"        Also, if you happen to walk in while I'm working, it's possible "
85
92
"you'll\n"
86
93
"        fall through the floor, so be warned =D"
87
94
msgstr ""
88
95
89
96
#: gitar/templates/gitar/index.html:39
90
97
msgid "Public repositories"
91
98
msgstr ""
92
99

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

8 additions and 1 deletion.

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: 2017-10-19 18:27+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
#: gitar/templates/gitar/directory.html:16
+
20
#: gitar/templates/gitar/directory.html:16
20
21
msgid "Description"
21
22
msgstr "Description"
22
23
23
24
#: gitar/templates/gitar/directory.html:18
24
25
msgid "Branches"
25
26
msgstr "Branches"
26
27
27
28
#: gitar/templates/gitar/directory.html:24
28
29
msgid "Extra information"
29
30
msgstr "Information additionel"
30
31
31
32
#: gitar/templates/gitar/directory.html:36
32
33
msgid "Files"
33
34
msgstr "Fichiers"
34
35
35
36
#: gitar/templates/gitar/directory.html:67
36
37
msgid "Commits"
37
38
msgstr "Commits"
38
39
39
40
#: gitar/templates/gitar/directory.html:79
40
41
msgid "by"
41
42
msgstr "par"
42
43
43
44
#: gitar/templates/gitar/index.html:4
44
45
msgid "Gitar | Index page"
45
46
msgstr "Gitar | Page d'acceuil"
46
47
47
48
#: gitar/templates/gitar/index.html:6
48
49
msgid "My personal answer to GitHub."
49
50
msgstr "Mon réponse personnel á GitHub."
50
51
51
52
#: gitar/templates/gitar/index.html:17
+
53
msgid ""
+
54
"Gitar is a simple web app to easily host Git repositories using the Django "
+
55
"framework."
+
56
msgstr ""
+
57
+
58
#: gitar/templates/gitar/index.html:17
52
59
msgid "About Gitar"
53
60
msgstr "À propos de Gitar"
54
61
55
62
#: gitar/templates/gitar/index.html:19
56
63
#, python-format
57
64
msgid ""
58
65
"Gitar is a hobby project of me, to make it easy for\n"
59
66
"        people to scroll through the code I publish, in a read-only fashion. "
60
67
"It\n"
61
68
"        makes use of\n"
62
69
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
63
70
"\">Pygments</a>\n"
64
71
"        to read the source files, and apply the appropriate syntax "
65
72
"coloring.\n"
66
73
"        "
67
74
msgstr ""
68
75
69
76
#: gitar/templates/gitar/index.html:27
70
77
msgid ""
71
78
"All repositories are automatically updated when changes\n"
72
79
"        have been pushed to the server, without any manual intervention from "
73
80
"me.\n"
74
81
"        Special attention goes to clean URL design, adhering to web "
75
82
"standards,\n"
76
83
"        and responsive design across all screen types."
77
84
msgstr ""
78
85
79
86
#: gitar/templates/gitar/index.html:32
80
87
msgid ""
81
88
"Gitar <b>is a project under development!</b>\n"
82
89
"        While it's certainly presentable, there's still a lot of room for "
83
90
"improvement.<br />\n"
84
91
"        Also, if you happen to walk in while I'm working, it's possible "
85
92
"you'll\n"
86
93
"        fall through the floor, so be warned =D"
87
94
msgstr ""
88
95
89
96
#: gitar/templates/gitar/index.html:39
90
97
msgid "Public repositories"
91
98
msgstr "Repositories public"
92
99

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

21 additions and 13 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: 2017-10-19 18:27+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
#: gitar/templates/gitar/directory.html:16
+
20
#: gitar/templates/gitar/directory.html:16
20
21
msgid "Description"
21
22
msgstr "Beschrijving"
22
23
23
24
#: gitar/templates/gitar/directory.html:18
24
25
msgid "Branches"
25
26
msgstr "Branches"
26
27
27
28
#: gitar/templates/gitar/directory.html:24
28
29
msgid "Extra information"
29
30
msgstr "Extra informatie"
30
31
31
32
#: gitar/templates/gitar/directory.html:36
32
33
msgid "Files"
33
34
msgstr "Bestanden"
34
35
35
36
#: gitar/templates/gitar/directory.html:67
36
37
msgid "Commits"
37
38
msgstr "Commits"
38
39
39
40
#: gitar/templates/gitar/directory.html:79
40
41
msgid "by"
41
42
msgstr "door"
42
43
43
44
#: gitar/templates/gitar/index.html:4
44
45
msgid "Gitar | Index page"
45
46
msgstr "Gitar | Hoofdpagina"
46
47
47
48
#: gitar/templates/gitar/index.html:6
48
49
msgid "My personal answer to GitHub."
49
50
msgstr "Mijn persoonlijke antwoord op Github."
50
51
51
52
#: gitar/templates/gitar/index.html:17
+
53
msgid ""
+
54
"Gitar is a simple web app to easily host Git repositories using the Django "
+
55
"framework."
+
56
msgstr ""
+
57
"Gitar is een simpele web app om gemakkelijk Git-repo's te hosten met behulp "
+
58
"van het Django-framework."
+
59
+
60
#: gitar/templates/gitar/index.html:17
52
61
msgid "About Gitar"
53
62
msgstr "Over Gitar"
54
63
55
64
#: gitar/templates/gitar/index.html:19
56
65
#, python-format
57
66
msgid ""
58
67
"Gitar is a hobby project of me, to make it easy for\n"
59
68
"        people to scroll through the code I publish, in a read-only fashion. "
60
69
"It\n"
61
70
"        makes use of\n"
62
71
"        <a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/"
63
72
"\">Pygments</a>\n"
64
73
"        to read the source files, and apply the appropriate syntax "
65
74
"coloring.\n"
66
75
"        "
67
76
msgstr ""
68
77
"Gitar is een persoonlijk hobbyproject, om het makkelijk te maken voor mensen "
69
78
"om door mijn code te scrollen, zoals deze in mijn repo's te zien is. "
70
-
"Het maakt gebruik van "
71
-
"<a class=\"%(mdac)s-text text-accent-3\" href=\"http://pygments.org/\">"
72
-
"Pygments</a> om de code te lezen, en de juiste syntaxkleuring toe te passen.\n"
73
-
+
79
"maakt gebruik van <a class=\"%(mdac)s-text text-accent-3\" href=\"http://"
+
80
"pygments.org/\">Pygments</a> om de code te lezen, en de juiste "
+
81
"syntaxkleuring toe te passen."
+
82
74
83
#: gitar/templates/gitar/index.html:27
75
84
msgid ""
76
85
"All repositories are automatically updated when changes\n"
77
86
"        have been pushed to the server, without any manual intervention from "
78
87
"me.\n"
79
88
"        Special attention goes to clean URL design, adhering to web "
80
89
"standards,\n"
81
90
"        and responsive design across all screen types."
82
91
msgstr ""
83
92
"Alle repositories worden automatisch geüpdatet als er veranderingen naar de "
84
93
"server gestuurd worden, zonder manuele toedracht van mijn kant. "
85
-
"Er wordt aandacht besteedt aan het maken van propere en duidelijke URL's, "
86
-
"het volgen van de juiste webstandaarden, en een gebruiksvriendelijk ontwerp "
87
-
"op alle soorten schermen."
88
-
+
94
"aandacht besteedt aan het maken van propere en duidelijke URL's, het volgen "
+
95
"van de juiste webstandaarden, en een gebruiksvriendelijk ontwerp op alle "
+
96
"soorten schermen."
+
97
89
98
#: gitar/templates/gitar/index.html:32
90
99
msgid ""
91
100
"Gitar <b>is a project under development!</b>\n"
92
101
"        While it's certainly presentable, there's still a lot of room for "
93
102
"improvement.<br />\n"
94
103
"        Also, if you happen to walk in while I'm working, it's possible "
95
104
"you'll\n"
96
105
"        fall through the floor, so be warned =D"
97
106
msgstr ""
98
107
"Gitar <b>is een project dat nog niet af is!</b>\n"
99
108
"Alheowel het presentabel is, is er nog meer dan genoeg ruimte voor verbetering. "
100
-
"Het kan dus zijn dat ik aan het prullen ben, en de website plots ineenstort, je "
101
-
"bent gewaarschuwd. ;)"
102
-
103
-
+
109
"verbetering. Het kan dus zijn dat ik aan het prullen ben, en de website "
+
110
"plots ineenstort, je bent gewaarschuwd. ;)"
+
111
104
112
#: gitar/templates/gitar/index.html:39
105
113
msgid "Public repositories"
106
114
msgstr "Publieke repositories"
107
115

templates/gitar/repositories.html

0 additions and 23 deletions.

View changes Hide changes
1
-
2
-
{% block title %}Gitar | Index page{% endblock title %}
3
-
{% block description %}
4
-
Vngngdn's Gitar app. Really nothing more to say, except that it FREAKING ROCKS!
5
-
{% endblock description %}
6
-
{% block main %}
7
-
{% with mdac=materialDesign_accentColor %} {# You'll see why this is handy shortly. #}
8
-
<div class="section {{ materialDesign_color }} lighten-2">
9
-
	<p class="flow-text container white-text">
10
-
		Gitar is a simple web app to easily host Git repositories using the Django framework.
11
-
	</p>
12
-
</div>
13
-
<div class="container section">
14
-
15
-
	<ul>
16
-
	{% for file in files %}
17
-
	<li>{{ file }}</li>
18
-
	{% endfor %}
19
-
	</ul>
20
-
	</div>
21
-
{% endwith %}
22
-
{% endblock main %}
23
-

tests.py

1 addition 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.test import TestCase
18
18
from .models import *
19
19
20
20
from GitPython import Repo # Necessary in order to test for repository existence.
21
-
+
21
22
22
class ReposTests(TestCase):
23
23
    def all_stored_repos_exist():
24
24
        repositories = Repository.objects.all()
25
25
        for repository in repositories:
26
26
            gitRepo = Repo(repository.directory)
27
27
            assert gitRepo # If a repo doesn't exist, the test fails.
28
28
    def all_repos_are_bare():
29
29
        repositories = Repository.objects.all()
30
30
        for repository in repositories:
31
31
            gitRepo = Repo(repository.directory)
32
32
            assert gitRepo.bare # All repos must be bare, or the test fails.
33
33
    def fuck_PHP(): # WHOOHOOO EASTER EGG
34
34
        repositories = Repository.objects.all()
35
35
        for repository in repositories:
36
36
            assert not repository.programmingLanguage == "PHP", \
37
37
                    "PHP is too horrible of a language to program in."
38
38

views.py

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