gitar

Remove loading of Fira Code for monospace font

I have removed this, because I tried using a CDN. Mistake I won't repeat anytime soon. Basically sent a giant amount of JS from Google, Amazon, doubleclick, analytics, ... to my website. I don't care how it works, I don't want it, I don't need it. I removed it and it's done forever.

Author
Maarten 'Vngngdn' Vangeneugden
Date
Oct. 19, 2017, 6:05 a.m.
Hash
ecb197b6acbe073d40cb56f2c84cee1aa7b250cc
Parent
efdf0b5d600f3ba47fea33c1866e76ed0c4718f3
Modified files
GitActions/RepoInfo.py
templates/gitar/file.html

GitActions/RepoInfo.py

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

templates/gitar/file.html

6 additions and 3 deletions.

View changes Hide changes
1
1
2
2
{% block title %}{{repository_name}}/{{file_name}} | Gitar{% endblock title %}
3
3
4
4
{% block stylesheets %}
5
5
<link href="/static/website/materialize/css/google-icons.css" rel="stylesheet" />
6
6
<link href="/static/website/materialize/css/materialize.css" rel="stylesheet" media="screen, projection" />
7
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
-
<!--<style>
+
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>
10
13
td {
11
14
	padding: 0 0 0 0;
12
15
}
13
16
pre {
14
17
	margin-top: 10px;
15
18
	margin-bottom: 10px;
16
19
}
17
20
table {
18
21
	line-height: 0px;
19
22
	padding-top: 0px;
20
23
	padding-bottom: 0px;
21
24
	border-spacing: 0 0;
22
25
	margin-top: 0px;
23
26
	margin-bottom: 0px;
24
27
}
25
28
</style>-->
26
29
{# For the syntax coloring of Gitar. TODO for later. #}
27
30
<link rel="stylesheet" type="text/css" href="/static/website/syntax.css" />
28
31
<link rel="stylesheet" type="text/css" href="/static/gitar/css/file.css" />
29
32
{% endblock stylesheets %}
30
33
31
34
{% block description %}
32
35
Content of {{file_name}} in {{repository_name}}
33
36
{% endblock description %}
34
37
{% block main %}
35
38
{% with mdac=materialDesign_accentColor mdc=materialDesign_color %} {# You'll see why this is handy shortly. #}
36
39
<div class="section {{ materialDesign_color }} lighten-2">
37
40
</div>
38
41
<div class="container section" style="font-family: 'Fira Code', monospace;">
39
42
    <h3 class="{{mdac}}-text text-accent-3">{{file_name}}</h3>
40
43
	<table class="highlight">
41
44
		{% for line in content %}
42
45
		<tr>
43
46
			  <td id="{{ forloop.counter }}" class="line-number">
44
-
            <a
+
47
            <a
45
48
                class="{{mdc}}-text"
46
49
                style="a:hover { color: #00e676;}"
47
50
                href="#{{ forloop.counter }}">
48
51
                <pre>{{ forloop.counter }}</pre></a></td>
49
52
			<td><pre>{{ line|safe }}</pre></td>
50
53
		</tr>
51
54
		{% endfor %}
52
55
	</table>
53
56
{% endwith %}
54
57
{% endblock main %}
55
58