blog

Updates to translations and code

Author
Maarten Vangeneugden
Date
March 25, 2018, 3:30 a.m.
Hash
3374cfa78210b806a7a4c3475e733ca508e9516d
Parent
a63d7baae9a651b3327347bc7a48dae00c2e6b39
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
models.py
templates/blog/index.html
templates/blog/locale/de/LC_MESSAGES/django.po
templates/blog/locale/es/LC_MESSAGES/django.po
templates/blog/locale/fr/LC_MESSAGES/django.po
templates/blog/locale/nl/LC_MESSAGES/django.po
templates/blog/post.html
views.py

locale/de/LC_MESSAGES/django.po

14 additions and 2 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 20:08+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
#: blog/views.py:95
21
-
msgid "Notepad from a student"
+
21
msgid "Blog main page"
+
22
msgstr ""
+
23
+
24
#: views.py:23
+
25
msgid "Contact"
+
26
msgstr ""
+
27
+
28
#: views.py:25
+
29
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
30
msgstr ""
+
31
+
32
#: views.py:105
+
33
msgid "Notepad from a student"
22
34
msgstr ""
23
35

locale/es/LC_MESSAGES/django.po

14 additions and 2 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 20:08+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
#: blog/views.py:95
21
-
msgid "Notepad from a student"
+
21
msgid "Blog main page"
+
22
msgstr ""
+
23
+
24
#: views.py:23
+
25
msgid "Contact"
+
26
msgstr ""
+
27
+
28
#: views.py:25
+
29
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
30
msgstr ""
+
31
+
32
#: views.py:105
+
33
msgid "Notepad from a student"
22
34
msgstr ""
23
35

locale/fr/LC_MESSAGES/django.po

16 additions and 2 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 20:08+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
#: blog/views.py:95
21
-
msgid "Notepad from a student"
+
21
msgid "Blog main page"
+
22
msgstr "Blog // Page principal"
+
23
+
24
#: views.py:23
+
25
msgid "Contact"
+
26
msgstr "Contact"
+
27
+
28
#: views.py:25
+
29
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
30
msgstr ""
+
31
"Blog personnel de Maarten, avec des sprinkles et un cuillerée des bogues "
+
32
"sains."
+
33
+
34
#: views.py:105
+
35
msgid "Notepad from a student"
22
36
msgstr "Bloc-notes d'un étudiant"
23
37

locale/nl/LC_MESSAGES/django.po

16 additions and 2 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 20:08+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
#: blog/views.py:95
21
-
msgid "Notepad from a student"
+
21
msgid "Blog main page"
+
22
msgstr "Blog // Hoofdpagina"
+
23
+
24
#: views.py:23
+
25
msgid "Contact"
+
26
msgstr ""
+
27
+
28
#: views.py:25
+
29
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
30
msgstr ""
+
31
"Maartens persoonlijke blog, met sprinkeltjes en een doperwtje aan gezonde "
+
32
"bugs."
+
33
+
34
#: views.py:105
+
35
msgid "Notepad from a student"
22
36
msgstr "Studentikoos kladblok"
23
37

models.py

4 additions and 4 deletions.

View changes Hide changes
1
1
from django.utils import translation
2
2
from django.template.defaultfilters import slugify
3
3
from django.db import models
4
4
import datetime
5
5
import os
6
6
7
7
def post_title_directory(instance, filename):
8
8
    """ Files will be uploaded to MEDIA_ROOT/blog/<year of publishing>/<blog
9
9
    title>
10
10
    The blog title is determined by the text before the first period (".") in
11
11
    the filename. So if the file has the name "Trains are bæ.en.md", the file
12
12
    will be stored in "blog/<this year>/Trains are bæ". Name your files
13
13
    properly!
14
14
    It should also be noted that all files are stored in the same folder if they
15
15
    belong to the same blogpost, regardless of language. The titles that are
16
16
    displayed to the user however, should be the titles of the files themselves,
17
17
    which should be in the native language. So if a blog post is titled
18
18
    "Universities of Belgium", its Dutch counterpart should be titled
19
19
    "Universiteiten van België", so the correct title can be derived from the
20
20
    filename.
21
21
22
22
    Recommended way to name the uploaded file: "<name of blog post in language
23
23
    it's written>.org". This removes the maximum amount of redundancy (e.g. the
24
24
    language of the file can be derived from the title, no ".fr.org" or something
25
25
    like that necessary), and can directly be used for the end user (the title
26
26
    is what should be displayed).
27
27
    """
28
28
    english_file_name = os.path.basename(instance.english_file.name) # TODO: Test if this returns the file name!
29
29
    english_title = english_file_name.rpartition(".")[0]
30
30
    year = datetime.date.today().year
31
31
32
32
    return "blog/{0}/{1}/{2}".format(year, english_title, filename)
33
33
34
34
class Post(models.Model):
35
35
    """ Represents a blog post. The title of the blog post is determnined by the name
36
36
    of the files.
37
37
    A blog post can be in 5 different languages: German, Spanish, English, French,
38
38
    and Dutch. For all these languages, a seperate field exists. Thus, a
39
39
    translated blog post has a seperate file for each translation, and is
40
40
    seperated from Django's internationalization/localization system.
41
41
    Only the English field is mandatory. The others may contain a value if a
42
42
    translated version exists, which will be displayed accordingly.
43
43
    """
44
44
    published = models.DateTimeField(auto_now_add=True)
45
45
    english_file = models.FileField(upload_to=post_title_directory, unique=True, blank=False)
46
46
    dutch_file = models.FileField(upload_to=post_title_directory, blank=True)
47
47
    french_file = models.FileField(upload_to=post_title_directory, blank=True)
48
48
    german_file = models.FileField(upload_to=post_title_directory, blank=True)
49
49
    spanish_file = models.FileField(upload_to=post_title_directory, blank=True)
50
50
    # Only the English file can be unique, because apparantly, there can't be
51
51
    # two blank fields in a unique column. Okay then.
52
52
53
53
    def __str__(self):
54
54
        return self.slug("en")
55
55
56
56
    def slug(self, language_code=translation.get_language()):
57
57
        """ Returns a slug of the requested language, or None if no version exists in that language. """
58
58
        possibilities = {
59
59
            "en" : self.english_file,
60
60
            "de" : self.german_file,
61
61
            "nl" : self.dutch_file,
62
62
            "fr" : self.french_file,
63
63
            "es" : self.spanish_file,
64
64
            }
65
65
        if possibilities[language_code]:
66
66
            return slugify(os.path.basename(possibilities[language].name).rpartition(".")[0])
67
-
        else:
+
67
        else:
68
68
            return None
69
69
70
70
class Comment(models.Model):
71
-
    """ Represents a comment on a blog post.
+
71
    """ Represents a comment on a blog post.
72
72
73
73
    Comments are not linked to an account or anything, I'm trusting the
74
74
    commenter that he is honest with his credentials. That being said:
75
75
    XXX: Remember to put up a notification that comments are not checked for
76
76
    identity, and, unless verified by a trustworthy source, cannot be seen as
77
77
    being an actual statement from the commenter.
78
78
    Comments are linked to a blogpost, and are not filtered by language. (So a
79
79
    comment made by someone reading the article in Dutch, that's written in
80
80
    Dutch, will show up (unedited) for somebody whom's reading the Spanish
81
81
    version.
82
82
    XXX: Remember to notify (tiny footnote or something) that comments showing
83
83
    up in a foreign language is by design, and not a bug.
84
84
    """
85
85
    date = models.DateTimeField(auto_now_add=True)
86
-
    name = models.CharField(max_length=64)
+
86
    name = models.CharField(max_length=64)
87
87
    text = models.TextField()
88
88
    post = models.ForeignKey(Post) # TODO: Finish this class and the shit...
89
89
90
-
+
90

templates/blog/index.html

17 additions and 15 deletions.

View changes Hide changes
1
1
{% load i18n %}
2
2
{% load static %}
3
3
4
4
{% block stylesheets %}
5
5
{{ block.super }}
6
6
<link href="{% static "blog/stylesheet.css" %}" rel="stylesheet" media="screen, projection" />
7
-
{% endblock %}
+
7
{% endblock %}
8
8
9
9
{% block title %}{% trans "Maarten's blog" %}{% endblock title %}
10
10
11
11
{% block description %}{% blocktrans %}The always coherently put together, yet
12
12
fuzzy blog of whatever sprouts in my mind.{% endblocktrans %}
13
13
{% endblock description %}
14
14
15
15
{% block main %}
16
16
{% with color="brown" accent_color="yellow" %}
17
17
<div class="section {{ color }} z-depth-3">
18
18
    <div class="container">
19
19
        <div class="white-text">
20
20
            <h3>{% trans "Blog" %}</h3>
21
21
            <p>
22
22
                {% blocktrans %}Welcome to my blog. Here, I write
23
23
                about things that interest me. Politics, coding,
24
24
                studying, life, or anything else I fancy rambling
25
25
                about. If you're in luck, I may've written it in a
26
26
                language that you understand better than English.
27
27
                {% endblocktrans %}
28
28
            </p>
29
29
        </div>
30
30
    </div>
31
31
</div>
32
32
33
33
<div class="container" style=" font-size:16px; font-family: Merriweather;">
34
-
    <h1 id="Weekboek" class="{{ color }}-text">Weekboek</h1>
35
-
    {% include "blog/weekly.html" %}
36
-
</div>
37
-
<div class="container">
38
-
    {% for title, date, blog_text, link in posts %}
39
-
        <h2 class="{{ color}}-text">{{ title }}</h2>
40
-
        <span class="grey-text">{{ date|date:"DATE_FORMAT" }}</span>
41
-
        <p class="hide-on-small-only">{{ blog_text|safe|truncatewords_html:100 }}</p>
42
-
        <a class="btn {{accent_color}} accent-4" href="{{link}}">
43
-
            📚 {% trans "Read on"%}
44
-
        </a>
45
-
        <hr />
46
-
    {% endfor %}
47
-
</div>
+
34
    <div class="col s12 m6">
+
35
        <h1 id="weekly" class="{{ color }}-text">Weekly</h1>
+
36
        {% include "blog/weekly.html" %}
+
37
    </div>
+
38
    <div class="container col s12 m6">
+
39
        {% for title, date, blog_text, link in posts %}
+
40
            <h1 class="{{ color}}-text">{{ title }}</h2>
+
41
            <span class="grey-text">{{ date|date:"DATE_FORMAT" }}</span>
+
42
            <p class="hide-on-small-only">{{ blog_text|safe|truncatewords_html:100 }}</p>
+
43
            <a class="btn black-text waves-effect {{accent_color}} accent-4" href="{{link}}">
+
44
                📚 {% trans "Read on"%}
+
45
            </a>
+
46
            <hr />
+
47
        {% endfor %}
+
48
    </div>
+
49
</div>
48
50
{% endwith %}
49
51
{% endblock main %}
50
52

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

10 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 20:08+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
#: blog/templates/blog/index.html:4
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr ""
23
23
24
24
#: blog/templates/blog/index.html:6
25
-
msgid ""
+
25
msgid ""
26
26
"The always coherently put together, yet\n"
27
27
"fuzzy blog of whatever sprouts in my mind."
28
28
msgstr ""
29
29
30
30
#: blog/templates/blog/index.html:15
31
-
msgid "Blog"
+
31
msgid "Blog"
32
32
msgstr ""
33
33
34
34
#: blog/templates/blog/index.html:17
35
-
msgid ""
+
35
msgid ""
36
36
"Welcome to my blog. Here, I write\n"
37
37
"                about things that interest me. Politics, coding,\n"
38
38
"                studying, life, or anything else I fancy rambling\n"
39
39
"                about. If you're in luck, I may've written it in a\n"
40
40
"                language that you understand better than English.\n"
41
41
"                "
42
42
msgstr ""
43
43
44
44
#: blog/templates/blog/index.html:36
45
-
msgid "Read on"
+
45
msgid "Read on"
46
46
msgstr ""
47
47
+
48
#: templates/blog/post.html:23
+
49
msgid "This article in other languages"
+
50
msgstr "Dieser Artikel in anderen Sprachen"
+
51

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

10 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 20:08+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
#: blog/templates/blog/index.html:4
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr ""
23
23
24
24
#: blog/templates/blog/index.html:6
25
-
msgid ""
+
25
msgid ""
26
26
"The always coherently put together, yet\n"
27
27
"fuzzy blog of whatever sprouts in my mind."
28
28
msgstr ""
29
29
30
30
#: blog/templates/blog/index.html:15
31
-
msgid "Blog"
+
31
msgid "Blog"
32
32
msgstr ""
33
33
34
34
#: blog/templates/blog/index.html:17
35
-
msgid ""
+
35
msgid ""
36
36
"Welcome to my blog. Here, I write\n"
37
37
"                about things that interest me. Politics, coding,\n"
38
38
"                studying, life, or anything else I fancy rambling\n"
39
39
"                about. If you're in luck, I may've written it in a\n"
40
40
"                language that you understand better than English.\n"
41
41
"                "
42
42
msgstr ""
43
43
44
44
#: blog/templates/blog/index.html:36
45
-
msgid "Read on"
+
45
msgid "Read on"
46
46
msgstr ""
47
47
+
48
#: templates/blog/post.html:23
+
49
msgid "This article in other languages"
+
50
msgstr ""
+
51

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

10 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 20:08+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
#: blog/templates/blog/index.html:4
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr "Blog de Maarten"
23
23
24
24
#: blog/templates/blog/index.html:6
25
-
msgid ""
+
25
msgid ""
26
26
"The always coherently put together, yet\n"
27
27
"fuzzy blog of whatever sprouts in my mind."
28
28
msgstr ""
29
29
"Le toujours mis de façon cohérente ensemble, mais floue de ce que les germes "
30
30
"dans mon esprit."
31
31
32
32
#: blog/templates/blog/index.html:15
33
-
msgid "Blog"
+
33
msgid "Blog"
34
34
msgstr "Blog"
35
35
36
36
#: blog/templates/blog/index.html:17
37
-
msgid ""
+
37
msgid ""
38
38
"Welcome to my blog. Here, I write\n"
39
39
"                about things that interest me. Politics, coding,\n"
40
40
"                studying, life, or anything else I fancy rambling\n"
41
41
"                about. If you're in luck, I may've written it in a\n"
42
42
"                language that you understand better than English.\n"
43
43
"                "
44
44
msgstr ""
45
45
46
46
#: blog/templates/blog/index.html:36
47
-
msgid "Read on"
+
47
msgid "Read on"
48
48
msgstr "Lire plus"
49
49
+
50
#: templates/blog/post.html:23
+
51
msgid "This article in other languages"
+
52
msgstr "Cet article en autres langues"
+
53

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

10 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 20:08+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
#: blog/templates/blog/index.html:4
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr "Maartens blog"
23
23
24
24
#: blog/templates/blog/index.html:6
25
-
msgid ""
+
25
msgid ""
26
26
"The always coherently put together, yet\n"
27
27
"fuzzy blog of whatever sprouts in my mind."
28
28
msgstr ""
29
29
"Een zeer weloverwogen geschreven, en toch warrige blog over vanalles wat in "
30
30
"mij opkomt."
31
31
32
32
#: blog/templates/blog/index.html:15
33
-
msgid "Blog"
+
33
msgid "Blog"
34
34
msgstr "Blog"
35
35
36
36
#: blog/templates/blog/index.html:17
37
-
msgid ""
+
37
msgid ""
38
38
"Welcome to my blog. Here, I write\n"
39
39
"                about things that interest me. Politics, coding,\n"
40
40
"                studying, life, or anything else I fancy rambling\n"
41
41
"                about. If you're in luck, I may've written it in a\n"
42
42
"                language that you understand better than English.\n"
43
43
"                "
44
44
msgstr ""
45
45
"Welkom op mijn blog. Hier schrijf ik over onderwerpen die mij interesseren. "
46
46
"Politiek, programmeren, studeren en het leven, plus alles waar ik goesting "
47
47
"in heb om over te schrijven."
48
48
49
49
#: blog/templates/blog/index.html:36
50
-
msgid "Read on"
+
50
msgid "Read on"
51
51
msgstr "Verder lezen"
52
52
+
53
#: templates/blog/post.html:23
+
54
msgid "This article in other languages"
+
55
msgstr "Dit artikel in andere talen"
+
56

templates/blog/post.html

46 additions and 28 deletions.

View changes Hide changes
1
1
{% load i18n %}
2
2
{% load static %}
3
3
4
4
{% block stylesheets %}
5
5
{{ block.super }}
6
6
<link href="{% static "blog/stylesheet.css" %}" rel="stylesheet" media="screen, projection" />
7
7
{% endblock %}
8
8
9
9
{% block title %}📚 {{ post_title }}{% endblock title %}
10
-
+
10
{{ article|safe|truncatewords_html:20 }}
+
11
{% endblock description %}
+
12
{% block title %}📚 {{ navbar_title }}{% endblock title %}
+
13
11
14
{% block description %}{{ article|safe|truncatewords_html:100 }}{% endblock description %}
12
-
13
15
{% block main %}
14
16
{% with color="brown" accent_color="yellow" %}
15
17
<div class="section {{ color }} lighten-1 z-depth-3">
16
18
    <div class="container">
17
19
        <div class="white-text flow-text" style="font-family:serif;">
18
-
            {{ article|safe }}
+
20
            {{ article|safe }}
19
21
        </div>
20
-
    </div>
21
-
</div>
22
-
+
22
+
23
+
24
<h5 class="white-text">{% trans "This article in other languages" %}</h5>
+
25
23
26
<hr />
24
-
25
-
<h5>{% trans "This article in other languages" %}</h5>
26
-
{% for slug, language in localized_links %}
27
-
    {% get_language_info for language as lang %}
28
-
    <a href="{% url 'blog-post-language' language slug %}" class="btn">
29
-
        {% if lang.code == "en" %}
30
-
        🇬🇧 {{ lang.name_translated}} 🇺🇸
31
-
        {% elif lang.code == "es" %}
32
-
        🇪🇸 {{ lang.name_translated}} 🇲🇽
33
-
        {% elif lang.code == "nl" %}
34
-
        🇧🇪 {{ lang.name_translated}} 🇳🇱
35
-
        {% elif lang.code == "fr" %}
36
-
        🇧🇪 {{ lang.name_translated}} 🇫🇷
37
-
        {% elif lang.code == "de" %}
38
-
        🇧🇪 {{ lang.name_translated }} 🇩🇪
39
-
        {% endif %}
40
-
    </a>
41
-
{% endfor %}
42
-
43
-
    <a href="{% url 'blog-post' post-slug %}" class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans 'Multilingual link. Links to the version in the viewer's preferred language.' %}">🏳️‍🌈 {% trans "All available languages" %}</a>
44
-
+
27
<a {% if dutch_link %} href="{{dutch_link}}" {% endif %}
+
28
   class="btn {{accent_color}} accent-4 black-text waves-effect
+
29
   {% if not dutch_link %}disabled{% endif %}">
+
30
    🇧🇪 {{ LANG.name_translated}} 🇳🇱
+
31
</a>
+
32
{% get_current_language as lang %}
+
33
{% get_language_info for 'fr' as LANG %}
+
34
<a {% if french_link %} href="{{french_link}}" {% endif %}
+
35
   class="btn {{accent_color}} accent-4 black-text waves-effect
+
36
   {% if not french_link %}disabled{% endif %}">
+
37
    🇧🇪 {{ LANG.name_translated}} 🇫🇷
+
38
</a>
+
39
{% get_language_info for 'en' as LANG %}
+
40
<a {% if english_link %} href="{{english_link}}" {% endif %}
+
41
   class="btn {{accent_color}} accent-4 black-text waves-effect
+
42
   {% if not english_link %}disabled{% endif %}">
+
43
    🇬🇧 {{ LANG.name_translated}} 🇺🇸
+
44
</a>
+
45
{% get_language_info for 'de' as LANG %}
+
46
<a {% if german_link %} href="{{german_link}}" {% endif %}
+
47
   class="btn {{accent_color}} accent-4 black-text waves-effect
+
48
   {% if not german_link %}disabled{% endif %}">
+
49
    🇧🇪 {{ LANG.name_translated}} 🇩🇪
+
50
</a>
+
51
{% get_language_info for 'es' as LANG %}
+
52
<a {% if spanish_link %} href="{{spanish_link}}" {% endif %}
+
53
   class="btn {{accent_color}} accent-4 black-text waves-effect
+
54
   {% if not spanish_link %}disabled{% endif %}">
+
55
    🇪🇸 {{ LANG.name_translated}} 🇲🇽
+
56
</a>
+
57
{% comment %}
+
58
<a href="{% url 'blog-post' post_slug %}" class="btn {{accent_color}} accent-4 black-text tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans "Multilingual link. Links to the version in the viewer's preferred language." %}">🏳️‍🌈 {% trans "All available languages" %}</a>
+
59
    {# TODO: Change to rainbow flag when possible #}
+
60
{% endcomment %}
+
61
    </div>
+
62
45
63
<div class="container">
+
64
<div class="container">
46
65
    {% for title, date, description, link in post_links %}
47
66
        <h2 class="{{ color}}-text">{{ title }}</h2>
48
67
        {# FIXME: Date is in all languages of the same format. Fix for each language #}
49
68
        <span class="grey-text">{{ date|date:"l j F Y" }}</span>
50
69
        {#<p class="hide-on-small-only">{{ description }}</p>#}
51
70
        <p class="hide-on-small-only">{% lorem %}</p>
52
71
        <a class="btn {{accent_color}} accent-3" href="{{link}}">
53
72
            {% trans "Read on"%}
54
73
        </a>
55
74
        <hr />
56
75
    {% endfor %}
57
76
</div>
58
77
{% endcomment %}
59
-
{% endwith %}
60
78
{% endblock main %}
61
79

views.py

35 additions and 7 deletions.

View changes Hide changes
1
1
import subprocess
2
2
3
3
from django.utils.translation import ugettext as _
4
4
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.
5
5
from django.http import HttpResponseRedirect, HttpResponse
6
6
from django.core.urlresolvers import reverse # Why?
7
7
from django.template import loader # This allows to actually load the template.
8
8
from django.contrib.auth.decorators import login_required
9
9
from django.contrib.auth import authenticate, login
10
10
from .models import Post
11
11
from django.core.exceptions import ObjectDoesNotExist
12
12
from django.utils import translation
13
13
14
14
GERMAN = "de"
15
15
SPANISH = "es"
16
16
FRENCH = "fr"
17
17
DUTCH = "nl"
18
18
ENGLISH = "en"
19
19
20
20
# FIXME: Remove this template trash. THIS IS A VIEW, NOT A FUCKING TEMPLATE FFS
+
21
        [_("Blog main page"), "/blog"],
+
22
        [_("Contact"), "mailto:maarten.vangeneugden@student.uhasselt.be"],
+
23
        ]
+
24
footer_description = _("Maarten's personal blog, with sprinkles and a dollop of healthy bugs.")
+
25
+
26
# FIXME: Remove this template trash. THIS IS A VIEW, NOT A FUCKING TEMPLATE FFS
21
27
context = {
22
28
    'materialDesign_color': "green",
23
29
    'materialDesign_accentColor': "purple",
24
30
    'navbar_title': "Blog",
25
31
    'navbar_fixed': True,
26
32
    'navbar_backArrow': True,
27
33
    #'footer_title': "Maarten's blog",
28
34
    #'footer_description': "My personal scribbly notepad.",
29
35
    #'footer_links': footer_links,
30
36
    }
31
37
32
38
def org_to_html(file_path):
33
39
    """ Converts the given org formatted file to HTML.
34
40
    This function directly returns the resulting HTML code. This function uses
35
41
    the amazing Haskell library Pandoc to convert the file (and takes care
36
42
    of header id's and all that stuff).
37
43
    """
38
44
    # FIXME: Remove hardcoded link to media. Replace with media tag!
39
45
    return subprocess.check_output(["pandoc", "--from=org", "--to=html", "/srv/django/website/media/"+file_path])
40
46
41
47
def get_available_post_languages(post):
42
48
    """ Returns the language codes for which a blog post exists. This function
43
49
    always returns English (because that field mustn't be empty).
44
50
    So say a blog post has an English, Dutch and French version (which means
45
51
    english_file, french_file and dutch_file aren't empty), the function will return {"en",
46
52
    "fr", "nl"}. """
47
53
    available_languages = {ENGLISH}
48
54
    if post.german_file is not None:
49
-
        available_languages.add(GERMAN)
+
55
        available_languages.add(GERMAN)
50
56
    if post.spanish_file is not None:
51
-
        available_languages.add(SPANISH)
+
57
        available_languages.add(SPANISH)
52
58
    if post.french_file is not None:
53
-
        available_languages.add(FRENCH)
+
59
        available_languages.add(FRENCH)
54
60
    if post.dutch_file is not None:
55
-
        available_languages.add(DUTCH)
+
61
        available_languages.add(DUTCH)
56
62
    return available_languages
57
63
58
64
def get_preferred_post_language(post, language):
59
65
    """ Returns the post language file that best suits the given language. This
60
66
    is handy if you know what language the user prefers, but aren't sure whether
61
67
    you can provide that language. This function will try to provide the file
62
68
    for that language, or return English if that's not possible. """
63
69
    if language == GERMAN and post.german_file is not None:
64
70
        return post.german_file
65
71
    if language == SPANISH and post.spanish_file is not None:
66
72
        return post.spanish_file
67
73
    if language == FRENCH and post.french_file is not None:
68
74
        return post.french_file
69
75
    if language == DUTCH and post.dutch_file is not None:
70
76
        return post.dutch_file
71
77
    return post.english_file  # Returned if all other choices wouldn't be satisfactory, or the requested language is English.
72
78
73
79
def index(request):
74
80
    template = "blog/index.html"
75
81
    posts = Post.objects.all()
76
82
    language = translation.get_language()
77
83
78
84
    post_links = []
79
85
    for post in posts:
80
86
        blog_file = get_preferred_post_language(post, language)
81
87
        # TODO: Find a cleaner way to determine the title. First and foremost:
82
88
        # If the language differs from English, the other language file needs to
83
89
        # be loaded. Plus: look for a built in function to remove the full path
84
90
        # and only return the file name.
85
91
        title = (blog_file.name.rpartition("/")[2]).rpartition(".")[0]
86
92
        human_title = title.replace("_"," ")
87
93
        date = post.published
88
94
        blog_text = org_to_html(blog_file.name)
89
95
        # TODO: The link can possibly be reversed in the DTL using the title, which is actually
90
96
        # a cleaner way to do it. Investigate.
91
97
        link = reverse("blog-post-language", args=[language, post.slug(language)])
92
98
        post_links.append([title, date, blog_text, link])
93
-
+
99
94
100
    context = {
95
101
            'posts': post_links,
96
102
            'materialDesign_color': "brown",
97
103
            'materialDesign_accentColor': "yellow",
98
104
            'navbar_title': _("Notepad from a student"),
99
105
            'navbar_backArrow': True,
100
106
            }
+
107
            'footer_description': footer_description,
+
108
            }
101
109
    return render(request, template, context)
102
110
103
111
def post(request, post_slug, language=None):
104
112
    if language is not None:
105
113
        if translation.check_for_language(language):
106
114
            translation.activate(language)
107
115
            request.session[translation.LANGUAGE_SESSION_KEY] = language
108
116
        return post(request, post_slug)
109
-
    else:
+
117
    else:
110
118
        language = translation.get_language()
111
119
112
120
    template = "blog/post.html"
113
121
    posts = Post.objects.all()
114
122
    for post in posts:
115
123
        if post.slug(language) == post_slug:
116
124
            blog_file = get_preferred_post_language(post, language)
117
125
            blog_text = org_to_html(blog_file.name)
118
126
            context = {
119
127
                'human_post_title': blog_file.name.replace("_"," "),
120
128
                'materialDesign_color': "brown",
121
129
                'materialDesign_accentColor': "yellow",
122
130
                'article': blog_text,
123
131
                'title': str(blog_file),
124
132
                'navbar_title': ((blog_file.name.rpartition("/")[2]).rpartition(".")[0]).replace("_"," "),
125
133
                'navbar_backArrow': True,
126
-
                }
+
134
                'post_slug': post_slug,
+
135
                'footer_links': footer_links,
+
136
                'footer_description': footer_description,
+
137
                }
127
138
            return render(request, template, context)
+
139
            # Getting all available article links
+
140
            available = get_available_post_languages(post)
+
141
            if ENGLISH in available:
+
142
                context['english_link'] = reverse("blog-post-language", args=[ENGLISH, post.slug(ENGLISH)])
+
143
            if DUTCH in available:
+
144
                context['dutch_link'] = reverse("blog-post-language", args=[DUTCH, post.slug(DUTCH)])
+
145
+
146
            if FRENCH in available:
+
147
                context['french_link'] = reverse("blog-post-language", args=[FRENCH, post.slug(FRENCH)])
+
148
+
149
            if SPANISH in available:
+
150
                context['spanish_link'] = reverse("blog-post-language", args=[SPANISH, post.slug(SPANISH)])
+
151
+
152
            if GERMAN in available:
+
153
                context['german_link'] = reverse("blog-post-language", args=[GERMAN, post.slug(GERMAN)])
+
154
+
155
            return render(request, template, context)
128
156