blog

Fix bugs resulting from overhaul

Author
Maarten Vangeneugden
Date
Feb. 20, 2022, 7:19 p.m.
Hash
210bc6f31148748ba94e33e6cd484a89b00a5021
Parent
68708a08cb93b5efe5d9d30733855940c45a0c46
Modified files
admin.py
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.djhtml
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
urls.py
views.py

admin.py

1 addition and 0 deletions.

View changes Hide changes
1
1
2
2
from .models import *
3
3
4
4
admin.site.register(Post)
+
5
admin.site.register(Post)
5
6
admin.site.register(Comment)
6
7
admin.site.register(FeedItem)
7
8

locale/de/LC_MESSAGES/django.po

6 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
#: blog/views.py:21
21
-
msgid "Back to main page"
+
21
msgid "Back to main page"
22
22
msgstr ""
23
23
24
24
#: blog/views.py:22
25
-
msgid "Contact"
+
25
msgid "Contact"
26
26
msgstr ""
27
27
28
28
#: blog/views.py:24
29
-
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
29
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
30
30
msgstr ""
31
31
32
32
#: blog/views.py:85
33
-
msgid "Notepad from a student"
+
33
msgid "Notepad from a student"
34
34
msgstr ""
35
35
36
36
#: blog/views.py:182
37
-
msgid "Weekly-archief"
+
37
msgid "Weekly-archief"
38
38
msgstr ""
39
39

locale/es/LC_MESSAGES/django.po

6 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
#: blog/views.py:21
21
-
msgid "Back to main page"
+
21
msgid "Back to main page"
22
22
msgstr ""
23
23
24
24
#: blog/views.py:22
25
-
msgid "Contact"
+
25
msgid "Contact"
26
26
msgstr ""
27
27
28
28
#: blog/views.py:24
29
-
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
29
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
30
30
msgstr ""
31
31
32
32
#: blog/views.py:85
33
-
msgid "Notepad from a student"
+
33
msgid "Notepad from a student"
34
34
msgstr ""
35
35
36
36
#: blog/views.py:182
37
-
msgid "Weekly-archief"
+
37
msgid "Weekly-archief"
38
38
msgstr ""
39
39

locale/fr/LC_MESSAGES/django.po

6 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
#: blog/views.py:21
21
-
#, fuzzy
+
21
#, fuzzy
22
22
#| msgid "Blog main page"
23
23
msgid "Back to main page"
24
24
msgstr "Blog // Page principal"
25
25
26
26
#: blog/views.py:22
27
-
msgid "Contact"
+
27
msgid "Contact"
28
28
msgstr "Contact"
29
29
30
30
#: blog/views.py:24
31
-
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
31
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
32
32
msgstr ""
33
33
"Blog personnel de Maarten, avec des sprinkles et un cuillerée des bogues "
34
34
"sains."
35
35
36
36
#: blog/views.py:85
37
-
msgid "Notepad from a student"
+
37
msgid "Notepad from a student"
38
38
msgstr "Bloc-notes d'un étudiant"
39
39
40
40
#: blog/views.py:182
41
-
msgid "Weekly-archief"
+
41
msgid "Weekly-archief"
42
42
msgstr ""
43
43

locale/nl/LC_MESSAGES/django.po

8 additions and 8 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: 2020-06-14 17:28+0200\n"
10
-
"PO-Revision-Date: 2021-10-30 16:10+0200\n"
+
10
"PO-Revision-Date: 2021-10-30 16:10+0200\n"
11
11
"Language: nl\n"
+
12
"Language-Team: \n"
+
13
"Language: nl\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
#: blog/views.py:21
21
-
#, fuzzy
+
21
#, fuzzy
22
22
#| msgid "Blog main page"
23
23
msgid "Back to main page"
24
24
msgstr "Blog // Hoofdpagina"
25
25
26
26
#: blog/views.py:22
27
-
msgid "Contact"
+
27
msgid "Contact"
28
28
msgstr "Contact"
29
29
30
30
#: blog/views.py:24
31
-
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
+
31
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
32
32
msgstr ""
33
33
"Maartens persoonlijke blog, met sprinkeltjes en een doperwtje aan gezonde "
34
34
"bugs."
35
35
36
36
#: blog/views.py:85
37
-
msgid "Notepad from a student"
+
37
msgid "Notepad from a student"
38
38
msgstr "Studentikoos kladblok"
39
39
40
40
#: blog/views.py:182
41
-
msgid "Weekly-archief"
+
41
msgid "Weekly-archief"
42
42
msgstr "Weekly-archief"
43
43

models.py

67 additions and 62 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
from django.conf import settings  # Necessary to get the link to the media root folder
5
5
import datetime
6
6
import os
7
7
+
8
8
9
""" New version:
9
10
- For each post, there's no longer a mandatory Dutch and English
10
11
  version. Instead, only the title needs to be in multiple languages.
11
12
- There's a new table for the links to the articles themselves. These include a
12
13
  language code and a foreign key to the post they belong to.
13
14
- If an article is available in the active language, but not tagged for the same
14
15
  dialect, then it should just show up without any warnings.
15
16
- If an article is not available in the active language, only the title should
16
17
  show up, but where the short intro text would normally be, there should be an
17
18
  explanation that it's only available in other languages, and provide links to
18
19
  those versions.
19
20
"""
20
21
21
22
def org_to_html(file_path):
+
23
# migrations with manage.py, so here it stays, being empty and hollow like the
+
24
# piece of shit it is.
+
25
def post_title_directory():
+
26
    pass
+
27
        
+
28
+
29
class Post(models.Model):
+
30
    """ Represents a blog post."""
+
31
    published = models.DateTimeField(auto_now_add=True)
+
32
+
33
    title_en = models.CharField(max_length=64, unique=False, blank=False)
+
34
    title_nl = models.CharField(max_length=64, unique=False, blank=False)
+
35
    title_fr = models.CharField(max_length=64, unique=False, blank=True)
+
36
    title_de = models.CharField(max_length=64, unique=False, blank=True)
+
37
    title_es = models.CharField(max_length=64, unique=False, blank=True)
+
38
    title_eo = models.CharField(max_length=64, unique=False, blank=True)
+
39
    title_af = models.CharField(max_length=64, unique=False, blank=True)
+
40
+
41
+
42
    def __str__(self):
+
43
        return self.title()
+
44
+
45
+
46
    def articles(self):
+
47
        #print(len(Article.objects.filter(post=self)))
+
48
        return Article.objects.filter(post=self)
+
49
        
+
50
    def article(self):
+
51
        language_code = translation.get_language()
+
52
        print(language_code)
+
53
        # Retrieves all articles that have this post as their foreign key
+
54
        articles = Article.objects.filter(post=self)
+
55
        for a in articles:
+
56
            if a.language_code == language_code:
+
57
                return a
+
58
        # If no exact match was found, try again, but now accept other dialects
+
59
        # as well:
+
60
        for a in articles:
+
61
            if a.language_code.startswith(language_code):
+
62
                return a
+
63
        
+
64
        # If still no article was found, return None
+
65
        return None
+
66
+
67
    def title(self):
+
68
        language_code = translation.get_language()
+
69
        options = {'af': self.title_af,
+
70
                   'de': self.title_de,
+
71
                   'es': self.title_es,
+
72
                   'en': self.title_en,
+
73
                   'eo': self.title_eo,
+
74
                   'fr': self.title_fr,
+
75
                   'nl': self.title_nl}
+
76
        for code, translated_title in options.items():
+
77
            if language_code.startswith(code):
+
78
                return translated_title
+
79
        # If no return has happened, default to English
+
80
        return self.title_en
+
81
+
82
def org_to_html(file_path):
22
83
    """ Converts the given org formatted file to HTML.
23
84
    This function directly returns the resulting HTML code. This function uses
24
85
    the amazing Haskell library Pandoc to convert the file (and takes care
25
86
    of header id's and all that stuff).
26
87
    """
27
88
    # FIXME: Remove hardcoded link to media. Replace with media tag!
28
89
    # XXX: The reason I'm first converting all occurences of .jpg][ and .png][
29
90
    # to .jpgPANDOCBUG][ and .pngPANDOCBUG][, is because of a Pandoc bug that
30
91
    # removes the text links for images. It is afterwards converted back, no
31
92
    # worries.
32
93
    file = open("/srv/django/website/media/"+file_path, "r", encoding="utf-8")
33
-
    text = file.read()
+
94
    text = file.read()
34
95
    file.close()
35
96
    text = text.replace(".jpg][", ".jpgPANDOCBUG][")
36
97
    text = text.replace(".png][", ".pngPANDOCBUG][")
37
98
    file = open("/tmp/blog-file.org", "w", encoding="utf-8")
38
99
    file.write(text)
39
100
    file.close()
40
101
    html_text = subprocess.check_output(["pandoc", "--from=org", "--to=html","/tmp/blog-file.org"])
41
102
    html_text = html_text.decode("utf-8").replace(".jpgPANDOCBUG", ".jpg")
42
103
    html_text = html_text.replace(".pngPANDOCBUG", ".png")
43
104
    return html_text
44
105
45
106
class Article(models.Model):
46
107
    AFRIKAANS = 'af'
47
108
    BELGIAN_FRENCH = 'fr-be'
48
109
    DUTCH = 'nl'
49
110
    ESPERANTO = 'eo'
50
111
    FLEMISH = 'nl-be'
+
112
    FLEMISH = 'nl-be'
51
113
    FRENCH = 'fr'
52
114
    GERMAN = 'de'
53
115
    SPANISH = 'es'
54
116
55
117
    LANGUAGE_CODES = [
56
118
        (AFRIKAANS, 'Afrikaans'),
57
119
        (BELGIAN_FRENCH, 'Français (Belgique)'),
58
120
        (DUTCH, 'Nederlands'),
59
121
        (ESPERANTO, 'Esperanto'),
60
122
        (FLEMISH, 'Vlaams'),
+
123
        (FLEMISH, 'Vlaams'),
61
124
        (FRENCH, 'Français'),
62
125
        (GERMAN, 'Deutsch'),
63
126
        (SPANISH, 'Español')]
64
127
65
128
    # auto_now_add should normally be True, but by changing a lot of the
66
-
    # internals I had to temporary disable it
67
-
    visible = models.BooleanField(default=True)
68
129
    post = models.ForeignKey(Post, on_delete=models.CASCADE)
69
130
    language_code = models.CharField(max_length=16,
70
131
                                      choices = LANGUAGE_CODES,
71
132
                                      blank=False)
72
133
    # file_path shouldn't be unique, because the same article file could be used
73
134
    # for multiple dialects of the same language.
74
135
    file_path = models.FilePathField(path=settings.MEDIA_ROOT + "blog/articles/",
75
136
                                     blank=False)
76
137
    # Same reason, slug shouldn't be unique
77
138
    slug = models.SlugField(unique=False, blank=False, allow_unicode=True)
78
139
+
140
79
141
    def text(self):
80
142
        return org_to_html(self.file_path)
81
143
82
144
    def title(self):
83
-
        return self.post.title(self.language_code)
84
-
        
85
-
86
-
87
-
class Post(models.Model):
88
-
    """ Represents a blog post."""
89
-
    published = models.DateTimeField(auto_now_add=False)
90
-
91
-
    title_en = models.CharField(max_length=64, unique=True, blank=False)
92
-
    title_nl = models.CharField(max_length=64, unique=True, blank=False)
93
-
    title_fr = models.CharField(max_length=64, unique=True, blank=True)
94
-
    title_de = models.CharField(max_length=64, unique=True, blank=True)
95
-
    title_es = models.CharField(max_length=64, unique=True, blank=True)
96
-
    title_eo = models.CharField(max_length=64, unique=True, blank=True)
97
-
    title_af = models.CharField(max_length=64, unique=True, blank=True)
98
-
99
-
100
-
    def __str__(self):
101
-
        return self.title()
102
-
103
-
104
-
    def articles(self):
105
-
        return Article.objects.filter(post=self)  
106
-
        
107
-
    def article(self, language_code=translation.get_language()):
108
-
        # Retrieves all articles that have this post as their foreign key
109
-
        articles = Article.objects.filter(post=self)  
110
-
        for a in articles:
111
-
            if a.language_code == language_code:
112
-
                return a
113
-
        # If no exact match was found, try again, but now accept other dialects
114
-
        # as well:
115
-
        for a in articles:
116
-
            if language_code.startswith(a.language_code):
117
-
                return a
118
-
        
119
-
        # If still no article was found, return None
120
-
        return None
121
-
122
-
    def title(self, language_code=translation.get_language()):
123
-
        options = {'af': self.title_af,
124
-
                   'de': self.title_de,
125
-
                   'es': self.title_es,
126
-
                   'en': self.title_en,
127
-
                   'eo': self.title_eo,
128
-
                   'fr': self.title_fr,
129
-
                   'nl': self.title_nl}
130
-
        for code, translated_title in options.items():
131
-
            if language_code.startswith(code):
132
-
                return translated_title
133
-
        # If no return has happened, default to English
134
-
        return self.title_en
135
-
    def text(self):
136
-
137
-
class Comment(models.Model):
138
145
    """ Represents a comment on a blog post.
139
146
    Comments are not filtered by language; a
140
147
    comment made by someone reading the article in Dutch, that's written in
141
148
    Dutch, will show up (unedited) for somebody whom's reading the Spanish
142
149
    version.
143
150
    """
144
151
    # Allows me to manually hide certain messages if need be
145
152
    visible = models.BooleanField(default=True)
146
153
    # auto_now_add should normally be True, but by changing a lot of the
147
-
    # internals I had to temporary disable it
148
-
    date = models.DateTimeField(auto_now_add=False)
149
-
    name = models.CharField(max_length=64, blank=True)
+
154
    name = models.CharField(max_length=64, blank=True)
150
155
    text = models.TextField(max_length=10000, blank=False)  # Should be more than enough
151
156
    # reaction_to is null if it's not a reaction to an existing comment
152
157
    reaction_to = models.ForeignKey(Comment, on_delete=models.CASCADE, null=True)
153
-
    post = models.ForeignKey(
+
158
    post = models.ForeignKey(
154
159
        Post,
155
160
        on_delete=models.CASCADE,
156
161
        null=False,
157
162
        )
158
163
    class meta:
159
164
        ordering = ['date']  # When printed, prints the oldest comment first.
160
165
161
166
class FeedItem(models.Model):
162
167
    """ An item that shows up in the RSS feed."""
163
168
    title = models.CharField(max_length=64)
164
169
    added = models.DateTimeField(auto_now_add=True)
165
170
    description = models.CharField(max_length=400)
166
171
    link = models.URLField()
167
172

templates/blog/index.djhtml

15 additions and 5 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
    <style>
7
7
    img {
8
8
    width: 80%;
9
9
     display: block;
10
10
  margin-left: auto;
11
11
  margin-right: auto;
12
12
    }
13
13
    video {
14
14
    width: 80%;
15
15
    } 
16
16
    </style>
17
17
{% endblock %}
18
18
19
19
{% block title %}{% trans "Maarten's blog" %}{% endblock title %}
20
20
21
21
{% block description %}{% blocktrans %}The always coherently put together, yet
22
22
fuzzy blog of whatever sprouts in my mind.{% endblocktrans %}
23
23
{% endblock description %}
24
24
25
25
{% block header %}
26
26
<header>                                                                                                                                                                                         
27
27
    <h1>{% trans "Notepad of a student" %}</h1>  
28
28
    <label for="nav-drawer-toggle"></label>
29
29
</header>
30
30
{% endblock header %}
31
31
32
32
{% block nav %}
33
33
<input id="nav-drawer-toggle" type="checkbox" />
34
34
<nav>
35
35
    <label for="nav-drawer-toggle"><!--🡨-->🡠</label>
36
36
    <h2>{% trans "Navigation" %}</h2>
37
37
    {% for title, date, blog_text, link in posts %}
38
-
    <a class="nav-link" href="{{ link }}">{{ title }}</a>
+
38
    {% for post in posts %}
+
39
    <a class="nav-link" href="{{ link }}">{{ title }}</a>
39
40
    {% endfor %}
40
41
    <hr class="half" />
+
42
    <hr class="half" />
41
43
    <a class="nav-link" href="{% url 'about-index' %}">{% trans "Front page" %}</a>
42
44
  </nav>
43
45
{% endblock nav %}
44
46
45
47
{% block main %}
46
48
47
49
<section class="emphasis">
48
50
    <h1>{% trans "Blog" %}</h1>
49
51
    <p>
50
52
        {% blocktrans %}Welcome to my blog. Here, I write
51
53
        about things that interest me. Politics, coding,
52
54
        studying, life, or anything else I fancy rambling
53
55
        about. If you're in luck, I may've written it in a
54
56
        language that you understand better than English.
55
57
        {% endblocktrans %}
56
58
    </p>
57
59
</section>
58
60
59
61
<div class="fab">
60
62
    <a href="{% url 'blog-feed' %}" id="feed-fab"> 
61
63
    <b>RSS</b>
62
64
    </a>
63
65
</div>
64
66
65
67
<section>
66
68
    <h1>Monthly</h1>
67
69
    <a class="btn fill" href="{% url "arkivo" %}"> {% translate "Open archive" %}</a>
68
-
    {% include "blog/monthly.html" %}
+
70
    {% include "blog/monthly.html" %}
69
71
</section>
70
72
71
73
<div class="cards">
72
74
    {% for post in posts %}
73
75
        <div class="card">
74
76
            <h3>{{ post.title }}</h3>
75
77
            <h4>{{ post.published|date:"DATE_FORMAT" }}</h4>
76
78
            {% if post.article %}
77
79
                {# No need for surrounding <p> tags #}
78
80
                {{ post.article_text|safe|truncatewords_html:100 }}
79
-
                {# Pandoc automatically makes those #}
+
81
                {# Pandoc automatically makes those #}
80
82
                <a class="btn outline" href="{% url 'blog-post' post.article.language_code post.article.slug %}">
81
83
                    📚 {% translate "Read on" %}</a>
82
84
            {% else %}
83
85
                {% get_current_language as CUR_LANG %}
84
86
                <p>{% blocktranslate cur_lang=CUR_LANG.name_translated %}This blog
85
-
               post is not available in {{ cur_lang }}.{% endblocktranslate %}
+
87
                {{ CUR_LANG.name_translated }}
+
88
                <p>{% blocktranslate with cur_lang=lang.name_translated %}This blog
+
89
               post is not available in {{ cur_lang }}.{% endblocktranslate %}
86
90
                    {% blocktranslate count counter=post.articles|length %}
87
91
                    However, it is available in 
88
92
                    {% plural %}
89
93
                    If you want, you can choose to read it in one of these
90
94
                    languages: <br>
91
95
                    {% endblocktranslate %}
92
96
                    {% for article in post.articles %}
93
97
                        {% get_language_info for article.language_code as lang %}
+
98
                        {% translate "Flemish" %}:
+
99
                        {% elif article.language_code == "fr-be" %}
+
100
                        {% translate "Belgian French" %}:
+
101
                        {% else %}
+
102
                        {% get_language_info for article.language_code as lang %}
94
103
                        {{ lang.name_translated }}: 
95
104
                        <a href="{% url blog-post article.language_code article.slug %}">
96
-
                            {{ article.title }}
+
105
                        <a href="{% url 'blog-post' article.language_code article.slug %}">
+
106
                            {{ article.title }}
97
107
                        </a>
98
108
                        {% if not forloop.last %}<br>{% endif %}
99
109
                    {% endfor %}
100
110
                </p>
101
111
            {% endif %}
102
112
        </div>
103
113
    {% endfor %}
104
114
    {% comment %}
105
115
    {% for title, date, blog_text, link in posts %}
106
116
        <div class="card">
107
117
            <h3>{{ title }}</h3>
108
118
            <h4>{{ date|date:"DATE_FORMAT" }}</h4>
109
119
        <a class="btn outline" href="{{link}}">📚 {% translate "Read on" %}</a>
110
120
        </div>
111
121
    {% endfor %}
112
122
    {% endcomment %}
113
123
</div>
114
124
115
125
{% endblock main %}
116
126

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

32 additions and 28 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
#: blog/templates/blog/index.html:14
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr ""
23
23
24
24
#: blog/templates/blog/index.html:16
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:25
31
-
msgid "Blog"
+
31
msgid "Notepad of a student"
+
32
msgstr ""
+
33
+
34
#: blog/templates/blog/index.djhtml:37
+
35
msgid "Navigation"
+
36
msgstr ""
+
37
+
38
#: blog/templates/blog/index.djhtml:42
+
39
msgid "Front page"
+
40
msgstr ""
+
41
+
42
#: blog/templates/blog/index.djhtml:49
+
43
msgid "Blog"
32
44
msgstr ""
33
45
34
46
#: blog/templates/blog/index.html:27
35
-
msgid ""
+
47
msgid ""
36
48
"Welcome to my blog. Here, I write\n"
37
49
"                about things that interest me. Politics, coding,\n"
38
-
"                studying, life, or anything else I fancy rambling\n"
39
-
"                about. If you're in luck, I may've written it in a\n"
40
-
"                language that you understand better than English.\n"
41
-
"                "
42
-
msgstr ""
+
50
"        studying, life, or anything else I fancy rambling\n"
+
51
"        about. If you're in luck, I may've written it in a\n"
+
52
"        language that you understand better than English.\n"
+
53
"        "
+
54
msgstr ""
43
55
44
56
#: blog/templates/blog/index.html:56 blog/templates/blog/post.html:94
45
-
msgid "Read on"
+
57
msgid "Open archive"
+
58
msgstr ""
+
59
+
60
#: blog/templates/blog/index.djhtml:78 blog/templates/blog/post.djhtml:94
+
61
msgid "Read on"
46
62
msgstr ""
47
63
48
64
#: blog/templates/blog/index.html:66
49
-
msgid "Never miss an update again."
50
-
msgstr ""
+
65
msgid "Weekly | Archief"
+
66
msgstr ""
51
67
52
68
#: blog/templates/blog/index.html:67
53
-
msgid ""
54
-
"Getting info on updates to blog posts, major website changes, and other "
55
-
"important\n"
56
-
"                news items is now easy and convenient with RSS.\n"
57
-
"                "
58
-
msgstr ""
+
69
msgid "Voor een duik terug in de geschiedenis van mijn publieke dagboek."
+
70
msgstr ""
59
71
60
72
#: blog/templates/blog/post.html:26
61
-
msgid "This article in other languages"
+
73
msgid "This article in other languages"
62
74
msgstr "Dieser Artikel in anderen Sprachen"
63
75
64
-
#: blog/templates/blog/post.html:60
65
-
msgid "Comments"
66
-
msgstr ""
67
-
68
-
#: blog/templates/blog/post.html:75
69
-
msgid "Submit"
70
-
msgstr ""
71
-

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

32 additions and 28 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
#: blog/templates/blog/index.html:14
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr ""
23
23
24
24
#: blog/templates/blog/index.html:16
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:25
31
-
msgid "Blog"
32
-
msgstr ""
+
31
msgid "Notepad of a student"
+
32
msgstr ""
33
33
34
34
#: blog/templates/blog/index.html:27
35
-
msgid ""
36
-
"Welcome to my blog. Here, I write\n"
37
-
"                about things that interest me. Politics, coding,\n"
38
-
"                studying, life, or anything else I fancy rambling\n"
39
-
"                about. If you're in luck, I may've written it in a\n"
40
-
"                language that you understand better than English.\n"
41
-
"                "
42
-
msgstr ""
+
35
msgid "Navigation"
+
36
msgstr ""
43
37
44
38
#: blog/templates/blog/index.html:56 blog/templates/blog/post.html:94
45
-
msgid "Read on"
46
-
msgstr ""
+
39
msgid "Front page"
+
40
msgstr ""
47
41
48
42
#: blog/templates/blog/index.html:66
49
-
msgid "Never miss an update again."
50
-
msgstr ""
+
43
msgid "Blog"
+
44
msgstr ""
51
45
52
46
#: blog/templates/blog/index.html:67
53
-
msgid ""
+
47
msgid ""
54
48
"Getting info on updates to blog posts, major website changes, and other "
55
-
"important\n"
56
-
"                news items is now easy and convenient with RSS.\n"
57
-
"                "
58
-
msgstr ""
+
49
"        about things that interest me. Politics, coding,\n"
+
50
"        studying, life, or anything else I fancy rambling\n"
+
51
"        about. If you're in luck, I may've written it in a\n"
+
52
"        language that you understand better than English.\n"
+
53
"        "
+
54
msgstr ""
59
55
60
56
#: blog/templates/blog/post.html:26
61
-
msgid "This article in other languages"
62
-
msgstr ""
+
57
msgid "Open archive"
+
58
msgstr ""
63
59
64
60
#: blog/templates/blog/post.html:60
65
-
msgid "Comments"
66
-
msgstr ""
+
61
msgid "Read on"
+
62
msgstr ""
+
63
+
64
#: blog/templates/blog/monthly_archive.djhtml:16
+
65
msgid "Weekly | Archief"
+
66
msgstr ""
67
67
68
68
#: blog/templates/blog/post.html:75
69
-
msgid "Submit"
70
-
msgstr ""
+
69
msgid "Voor een duik terug in de geschiedenis van mijn publieke dagboek."
+
70
msgstr ""
+
71
+
72
#: blog/templates/blog/post.djhtml:24
+
73
msgid "This article in other languages"
+
74
msgstr ""
71
75

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

59 additions and 31 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:01+0200\n"
+
10
"PO-Revision-Date: 2021-10-30 16:01+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
#: blog/templates/blog/index.html:14
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:16
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:25
33
-
msgid "Blog"
+
33
msgid "Notepad of a student"
+
34
msgstr ""
+
35
+
36
#: blog/templates/blog/index.djhtml:37
+
37
msgid "Navigation"
+
38
msgstr ""
+
39
+
40
#: blog/templates/blog/index.djhtml:42
+
41
msgid "Front page"
+
42
msgstr ""
+
43
+
44
#: blog/templates/blog/index.djhtml:49
+
45
msgid "Blog"
34
46
msgstr "Blog"
35
47
36
48
#: blog/templates/blog/index.html:27
37
-
msgid ""
+
49
#, fuzzy
+
50
#| msgid ""
+
51
#| "Welcome to my blog. Here, I write\n"
+
52
#| "                about things that interest me. Politics, coding,\n"
+
53
#| "                studying, life, or anything else I fancy rambling\n"
+
54
#| "                about. If you're in luck, I may've written it in a\n"
+
55
#| "                language that you understand better than English.\n"
+
56
#| "                "
+
57
msgid ""
38
58
"Welcome to my blog. Here, I write\n"
39
59
"                about things that interest me. Politics, coding,\n"
40
-
"                studying, life, or anything else I fancy rambling\n"
41
-
"                about. If you're in luck, I may've written it in a\n"
42
-
"                language that you understand better than English.\n"
43
-
"                "
44
-
msgstr ""
+
60
"        studying, life, or anything else I fancy rambling\n"
+
61
"        about. If you're in luck, I may've written it in a\n"
+
62
"        language that you understand better than English.\n"
+
63
"        "
+
64
msgstr ""
45
65
"Bienvenue dans mon blog. Ici j'écris des choses qui m'intéressent. La "
46
66
"politique, le codage, l'étude, la vie, ou autre chose dont j'ai envie de me "
47
67
"venger."
48
68
49
69
#: blog/templates/blog/index.html:56 blog/templates/blog/post.html:94
50
-
msgid "Read on"
+
70
msgid "Open archive"
+
71
msgstr ""
+
72
+
73
#: blog/templates/blog/index.djhtml:78 blog/templates/blog/post.djhtml:94
+
74
msgid "Read on"
51
75
msgstr "Lire plus"
52
76
53
77
#: blog/templates/blog/index.html:66
54
-
msgid "Never miss an update again."
55
-
msgstr "Ne manquez plus jamais une mise à jour."
56
-
+
78
msgid "Weekly | Archief"
+
79
msgstr ""
+
80
57
81
#: blog/templates/blog/index.html:67
58
-
msgid ""
59
-
"Getting info on updates to blog posts, major website changes, and other "
60
-
"important\n"
61
-
"                news items is now easy and convenient with RSS.\n"
62
-
"                "
63
-
msgstr ""
+
82
msgid "Voor een duik terug in de geschiedenis van mijn publieke dagboek."
+
83
msgstr ""
64
84
"Recevoir des mise à jours du blog, des grands changements du site web et "
65
-
"d'autre information, c'est maitenant facile et pratique avec RSS."
66
-
67
85
#: blog/templates/blog/post.html:26
68
-
msgid "This article in other languages"
+
86
msgid "This article in other languages"
69
87
msgstr "Cet article en autres langues"
70
88
71
89
#: blog/templates/blog/post.html:60
72
-
msgid "Comments"
73
-
msgstr "Commentaires"
74
-
+
90
#~ msgstr "Ne manquez plus jamais une mise à jour."
+
91
+
92
#~ msgid ""
+
93
#~ "Getting info on updates to blog posts, major website changes, and other "
+
94
#~ "important\n"
+
95
#~ "                news items is now easy and convenient with RSS.\n"
+
96
#~ "                "
+
97
#~ msgstr ""
+
98
#~ "Recevoir des mise à jours du blog, des grands changements du site web et "
+
99
#~ "d'autre information, c'est maitenant facile et pratique avec RSS."
+
100
+
101
#~ msgid "Comments"
+
102
#~ msgstr "Commentaires"
+
103
75
104
#: blog/templates/blog/post.html:75
76
-
msgid "Submit"
77
-
msgstr "Envoyer"
78
-
+
105
#~ msgstr "Envoyer"
+
106

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

59 additions and 31 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:11+0200\n"
+
10
"PO-Revision-Date: 2021-10-30 16:11+0200\n"
11
11
"Language: nl\n"
+
12
"Language-Team: \n"
+
13
"Language: nl\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
#: blog/templates/blog/index.html:14
21
-
msgid "Maarten's blog"
+
21
msgid "Maarten's blog"
22
22
msgstr "Maartens blog"
23
23
24
24
#: blog/templates/blog/index.html:16
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:25
33
-
msgid "Blog"
+
33
msgid "Notepad of a student"
+
34
msgstr ""
+
35
+
36
#: blog/templates/blog/index.djhtml:37
+
37
msgid "Navigation"
+
38
msgstr ""
+
39
+
40
#: blog/templates/blog/index.djhtml:42
+
41
msgid "Front page"
+
42
msgstr ""
+
43
+
44
#: blog/templates/blog/index.djhtml:49
+
45
msgid "Blog"
34
46
msgstr "Blog"
35
47
36
48
#: blog/templates/blog/index.html:27
37
-
msgid ""
+
49
#, fuzzy
+
50
#| msgid ""
+
51
#| "Welcome to my blog. Here, I write\n"
+
52
#| "                about things that interest me. Politics, coding,\n"
+
53
#| "                studying, life, or anything else I fancy rambling\n"
+
54
#| "                about. If you're in luck, I may've written it in a\n"
+
55
#| "                language that you understand better than English.\n"
+
56
#| "                "
+
57
msgid ""
38
58
"Welcome to my blog. Here, I write\n"
39
59
"                about things that interest me. Politics, coding,\n"
40
-
"                studying, life, or anything else I fancy rambling\n"
41
-
"                about. If you're in luck, I may've written it in a\n"
42
-
"                language that you understand better than English.\n"
43
-
"                "
44
-
msgstr ""
+
60
"        studying, life, or anything else I fancy rambling\n"
+
61
"        about. If you're in luck, I may've written it in a\n"
+
62
"        language that you understand better than English.\n"
+
63
"        "
+
64
msgstr ""
45
65
"Welkom op mijn blog. Hier schrijf ik over onderwerpen die mij interesseren. "
46
66
"Politiek, programmeren, studeren en het leven, plus alles waar ik goesting "
47
67
"in heb om over te schrijven."
48
68
49
69
#: blog/templates/blog/index.html:56 blog/templates/blog/post.html:94
50
-
msgid "Read on"
+
70
msgid "Open archive"
+
71
msgstr ""
+
72
+
73
#: blog/templates/blog/index.djhtml:78 blog/templates/blog/post.djhtml:94
+
74
msgid "Read on"
51
75
msgstr "Verder lezen"
52
76
53
77
#: blog/templates/blog/index.html:66
54
-
msgid "Never miss an update again."
55
-
msgstr "Mis nooit meer een update."
56
-
+
78
msgid "Weekly | Archief"
+
79
msgstr ""
+
80
57
81
#: blog/templates/blog/index.html:67
58
-
msgid ""
59
-
"Getting info on updates to blog posts, major website changes, and other "
60
-
"important\n"
61
-
"                news items is now easy and convenient with RSS.\n"
62
-
"                "
63
-
msgstr ""
+
82
msgid "Voor een duik terug in de geschiedenis van mijn publieke dagboek."
+
83
msgstr ""
64
84
"Updates van blogartikelen, grote veranderingen op de website en andere "
65
-
"belangrijke nieuwtjes zijn nu makkelijk te verkrijgen met RSS."
66
-
67
85
#: blog/templates/blog/post.html:26
68
-
msgid "This article in other languages"
+
86
msgid "This article in other languages"
69
87
msgstr "Dit artikel in andere talen"
70
88
71
89
#: blog/templates/blog/post.html:60
72
-
msgid "Comments"
73
-
msgstr "Reacties"
74
-
+
90
#~ msgstr "Mis nooit meer een update."
+
91
+
92
#~ msgid ""
+
93
#~ "Getting info on updates to blog posts, major website changes, and other "
+
94
#~ "important\n"
+
95
#~ "                news items is now easy and convenient with RSS.\n"
+
96
#~ "                "
+
97
#~ msgstr ""
+
98
#~ "Updates van blogartikelen, grote veranderingen op de website en andere "
+
99
#~ "belangrijke nieuwtjes zijn nu makkelijk te verkrijgen met RSS."
+
100
+
101
#~ msgid "Comments"
+
102
#~ msgstr "Reacties"
+
103
75
104
#: blog/templates/blog/post.html:75
76
-
msgid "Submit"
77
-
msgstr "Reageren"
78
-
+
105
#~ msgstr "Reageren"
+
106

urls.py

2 additions and 2 deletions.

View changes Hide changes
1
-
+
1
2
2
from . import views # Imports the views from the same directory (which is views.py).
3
3
4
4
urlpatterns = [
5
5
    path('', views.index, name='blog-index'),
6
6
    path('feed.rss', views.rss, name='blog-feed'),
7
7
    path('<slug:language_code>/<slug:post_slug>', views.post, name='blog-post'),
8
8
    path('arkivo' views.archive, name='blog-archive'),
9
-
    ]
+
9
    ]
10
10
11
11
"""
12
12
urlpatterns = [
13
13
    url(r'^$', views.index, name='blog-index'),
14
14
    url(r'^feed.rss$', views.rss, name='blog-feed'),
15
15
    url(r'^(?P<language>(.){2})/(?P<post_slug>(.)+)$', views.post, name='blog-post-language'),
16
16
    url(r'^monthly-archive$', views.monthly_archive, name="monthly-archive"),
17
17
    url(r'^(?P<post_slug>(.)+)$', views.post, name='blog-post'),
18
18
        ]
19
19
"""
20
20

views.py

2 additions and 3 deletions.

View changes Hide changes
1
1
import subprocess
2
-
import requests
3
2
4
3
5
4
from django.utils.translation import ugettext as _
6
5
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.
7
6
from django.http import HttpResponseRedirect, HttpResponse
8
7
from django.urls import reverse
9
8
from django.template import loader # This allows to actually load the template.
10
9
from .models import *
11
10
from .forms import CommentForm
12
11
from django.core.exceptions import ObjectDoesNotExist
13
12
from django.utils import translation
14
13
15
14
GERMAN = "de"
16
15
SPANISH = "es"
17
16
FRENCH = "fr"
18
17
DUTCH = "nl"
19
18
ENGLISH = "en"
20
19
21
20
22
21
def get_available_post_languages(post):
23
22
    """ Returns the language codes for which a blog post exists. This function
24
23
    always returns English (because that field mustn't be empty).
25
24
    So say a blog post has an English, Dutch and French version (which means
26
25
    english_file, french_file and dutch_file aren't empty), the function will return {"en",
27
26
    "fr", "nl"}. """
28
27
    available_languages = {ENGLISH}
29
28
    if post.german_file != "":
30
29
        available_languages.add(GERMAN)
31
30
    if post.spanish_file != "":
32
31
        available_languages.add(SPANISH)
33
32
    if post.french_file != "":
34
33
        available_languages.add(FRENCH)
35
34
    if post.dutch_file != "":
36
35
        available_languages.add(DUTCH)
37
36
    return available_languages
38
37
39
38
def index(request):
40
39
    template = "blog/index.djhtml"
41
40
    posts = Post.objects.all()
42
41
43
42
44
43
    context = {
45
44
            'posts': posts,
46
45
            'navbar_title': _("Notepad from a student"),
47
46
            'navbar_backArrow': True,
48
47
            'stylesheet_name': "blog",
49
48
            }
50
49
    return render(request, template, context)
51
50
52
51
def post(request, language_code, post_slug):
53
52
    if request.method == "POST":  # Handling a reply if one is sent
54
53
        form = CommentForm(request.POST)
55
54
        for post in Post.objects.all():
56
55
            if post.slug(language) == post_slug:
57
56
                form.post = post
58
57
                break
59
58
        if form.is_valid():
60
59
            new_comment = form.save(commit=False)
61
60
            for post in Post.objects.all():
62
61
                if post.slug(language) == post_slug:
63
62
                    new_comment.post = post
64
63
                    new_comment.save()
65
64
66
65
    template = "blog/post.djhtml"
67
66
    article = Article.objects.get(slug=post_slug, language_code=language_code)
68
67
    comments = Comment.objects.filter(post=article.post)
69
68
    context = {
70
69
            'article': article,
71
70
            'navbar_title': article.post.title(),
72
71
            'title': article.post.title(),
73
72
            'navbar_title': article.post.title(),
74
73
            'navbar_backArrow': True,
75
74
            'stylesheet_name': "blog",
76
-
    #posts = Post.objects.all()
+
75
    #posts = Post.objects.all()
77
76
    #comments = Comment.objects.filter(post
78
77
    """
79
78
    for post in posts:
80
79
        if post.slug(language) == post_slug:
81
80
            comments = Comment.objects.filter(post=post)
82
81
            form = CommentForm()
83
82
            post_file = post.text_file(language)
84
83
            post_text = org_to_html(post_file.name)
85
84
            context = {
86
85
                'comments': comments,
87
86
                'form' : form,
88
87
                'human_post_title': post.title(language),
89
88
                'materialDesign_color': "brown",
90
89
                'materialDesign_accentColor': "blue",
91
90
                'article': post_text,
92
91
                'title': post.title(language),
93
92
                'navbar_title': post.title(language),
94
93
                'navbar_backArrow': False,
95
94
                'post_slug': post_slug,
96
95
                'footer_links': footer_links,
97
96
                'footer_description': footer_description,
98
97
                'stylesheet_name': "blog",
99
98
                }
100
99
101
100
            # Getting all available article links
102
101
            available = get_available_post_languages(post)
103
102
            if ENGLISH in available:
104
103
                context['english_link'] = reverse("blog-post-language", args=[ENGLISH, post.slug(ENGLISH)])
105
104
            if DUTCH in available:
106
105
                context['dutch_link'] = reverse("blog-post-language", args=[DUTCH, post.slug(DUTCH)])
107
106
108
107
            if FRENCH in available:
109
108
                context['french_link'] = reverse("blog-post-language", args=[FRENCH, post.slug(FRENCH)])
110
109
111
110
            if SPANISH in available:
112
111
                context['spanish_link'] = reverse("blog-post-language", args=[SPANISH, post.slug(SPANISH)])
113
112
114
113
            if GERMAN in available:
115
114
                context['german_link'] = reverse("blog-post-language", args=[GERMAN, post.slug(GERMAN)])
116
115
    """
117
116
118
117
    return render(request, template, context)
119
118
120
119
def rss(request):
121
120
    template = "blog/feed.rss"
122
121
    context = {
123
122
        'items': FeedItem.objects.all(),
124
123
        }
125
124
    return render(request, template, context, content_type="application/rss+xml")
126
125
127
126
128
127
def monthly_archive(request):
129
-
    template = "blog/monthly_archive.djhtml"
+
128
    template = "blog/monthly_archive.djhtml"
130
129
    language = translation.get_language()
131
130
132
131
    file_2017 = org_to_html("blog/weekly/2017.org")
133
132
    file_2018 = org_to_html("blog/weekly/2018.org")
134
133
    file_2019 = org_to_html("blog/weekly/2019.org")
135
134
136
135
137
136
138
137
    context = {
139
138
        't2017': file_2017,
140
139
        't2018': file_2018,
141
140
        't2019': file_2019,
142
141
            'materialDesign_color': "brown",
143
142
            'materialDesign_accentColor': "blue",
144
143
            'navbar_title': _("Weekly-archief"),
145
144
            'navbar_backArrow': True,
146
145
            'footer_links': footer_links,
147
146
            'footer_description': footer_description,
148
147
            'stylesheet_name': "blog",
149
148
            }
150
149
    return render(request, template, context)
151
150