blog

Mostly language changes and stuff

Author
Maarten Vangeneugden
Date
Sept. 13, 2020, 1:31 p.m.
Hash
d6b7f80b59eed008c3474f60d00e23452f843101
Parent
a032ee58d61e90aaab168e8a0531ea5238a2a473
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/blog/index.djhtml
templates/blog/post.djhtml
templates/blog/weekly_archive.djhtml
urls.py
views.py

locale/de/LC_MESSAGES/django.po

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

locale/es/LC_MESSAGES/django.po

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

locale/fr/LC_MESSAGES/django.po

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

locale/nl/LC_MESSAGES/django.po

9 additions and 3 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/views.py:21
21
21
msgid "Blog main page"
22
-
msgstr "Blog // Hoofdpagina"
+
22
#| msgid "Blog main page"
+
23
msgid "Back to main page"
+
24
msgstr "Blog // Hoofdpagina"
23
25
24
26
#: blog/views.py:22
25
27
msgid "Contact"
26
28
msgstr ""
27
29
28
30
#: blog/views.py:24
29
31
msgid "Maarten's personal blog, with sprinkles and a dollop of healthy bugs."
30
32
msgstr ""
31
33
"Maartens persoonlijke blog, met sprinkeltjes en een doperwtje aan gezonde "
32
34
"bugs."
33
35
34
36
#: blog/views.py:104
35
-
msgid "Notepad from a student"
+
37
msgid "Notepad from a student"
36
38
msgstr "Studentikoos kladblok"
37
39
+
40
#: blog/views.py:182
+
41
msgid "Weekly-archief"
+
42
msgstr ""
+
43

templates/blog/index.djhtml

39 additions and 6 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
{% endblock %}
+
7
    img {
+
8
    width: 80%;
+
9
     display: block;
+
10
  margin-left: auto;
+
11
  margin-right: auto;
+
12
    }
+
13
    video {
+
14
    width: 80%;
+
15
    } 
+
16
    </style>
+
17
     <link href="{% static "website/blog.css" %}" rel="stylesheet" media="screen, projection" />
+
18
{% endblock %}
7
19
8
20
{% block title %}{% trans "Maarten's blog" %}{% endblock title %}
9
21
10
22
{% block description %}{% blocktrans %}The always coherently put together, yet
11
23
fuzzy blog of whatever sprouts in my mind.{% endblocktrans %}
12
24
{% endblock description %}
13
25
14
26
{% block main %}
+
27
<header>                                                                                                                                                                                         
+
28
    <h1>{% trans "Notepad of a student" %}</h1>  
+
29
    <label for="nav-drawer-toggle"></label>
+
30
</header>
+
31
{% endblock header %}
+
32
+
33
{% block nav %}
+
34
<input id="nav-drawer-toggle" type="checkbox" />
+
35
<nav>
+
36
    <label for="nav-drawer-toggle"><!--🡨-->🡠</label>
+
37
    <h2>{% trans "Navigation" %}</h2>
+
38
    {% for title, date, blog_text, link in posts %}
+
39
    <a class="nav-link" href="{{ link }}">{{ title }}</a>
+
40
    {% endfor %}
+
41
    <hr class="half" />
+
42
    <a class="nav-link" href="{% url 'about-index' %}">{% trans "Front page" %}</a>
+
43
  </nav>
+
44
{% endblock nav %}
+
45
+
46
{% block main %}
15
47
16
48
<section class="emphasis">
17
49
    <h1>{% trans "Blog" %}</h1>
18
50
    <p>
19
51
        {% blocktrans %}Welcome to my blog. Here, I write
20
52
        about things that interest me. Politics, coding,
21
53
        studying, life, or anything else I fancy rambling
22
54
        about. If you're in luck, I may've written it in a
23
55
        language that you understand better than English.
24
56
        {% endblocktrans %}
25
57
    </p>
26
58
</section>
27
59
28
60
<div class="fixed-action-btn">
29
-
    <a href="{% url 'blog-feed' %}" id="feed-fab" class="btn-floating waves-effect waves-light btn-large orange accent-4">
30
-
    <i class="large material-icons">rss_feed</i>
+
61
    <a href="{% url 'blog-feed' %}" id="feed-fab"> 
+
62
    <i class="large material-icons">rss_feed</i>
31
63
    </a>
+
64
    </a>
32
65
</div>
33
-
+
66
34
67
<section>
35
68
    <h1>Monthly</h1>
36
69
    <a class="btn" href="{% url "monthly-archive" %}"> {% trans "Open archive" %}</a>
37
-
    {% include "blog/weekly.html" %}
38
-
</section>
+
70
    {% include "blog/monthly.html" %}
+
71
</section>
39
72
40
73
<div class="cards">
41
74
    {% for title, date, blog_text, link in posts %}
42
75
        <div class="card">
43
76
            <h3>{{ title }}</h3>
44
77
            <h4>{{ date|date:"DATE_FORMAT" }}</h4>
45
78
        <p>{{ blog_text|safe|truncatewords_html:100 }}</p>
46
79
        <a class="btn flat" href="{{link}}">📚 {% trans "Read on" %}</a>
47
-
        </div>
+
80
        </div>
48
81
    {% endfor %}
49
82
</div>
50
83
51
84
{% endblock main %}
52
85

templates/blog/post.djhtml

18 additions and 13 deletions.

View changes Hide changes
1
1
{% load humanize %}
2
2
{% load i18n %}
3
3
{% load static %}
4
4
5
5
{% block stylesheets %}
6
6
{{ block.super }}
7
7
<link href="{% static "blog/stylesheet.css" %}" rel="stylesheet" media="screen, projection" />
8
-
{% endblock %}
+
8
{#<link href="{% static "blog/stylesheet.css" %}" rel="stylesheet"
+
9
media="screen, projection" />#}
+
10
{% endblock %}
9
11
10
12
{% block description %}
11
13
{{ article|safe|truncatewords_html:10 }}
12
14
{% endblock description %}
13
15
{% block title %}📚 {{ navbar_title }}{% endblock title %}
14
16
15
17
16
18
{% block main %}
+
19
<header>
+
20
<h1>{{ navbar_title }}</h1>
+
21
</header>
+
22
{% endblock header %}
+
23
{% block main %}
17
24
{% with color="brown" accent_color="yellow" %}
18
-
<div class="section {{ color }} lighten-1 z-depth-3">
19
-
    <div class="container">
20
-
        <article style="font-family:serif;">
21
-
            {{ article|safe }}
22
-
        </article>
23
-
24
-
+
25
    <!--<article style="font-family:serif;">-->
+
26
        {{ article|safe }}
+
27
    <!--</article>-->
+
28
</section>
+
29
25
30
<h5 class="white-text">{% trans "This article in other languages" %}</h5>
26
31
27
32
{% get_language_info for 'nl' as LANG %}
28
33
<a {% if dutch_link %} href="{{dutch_link}}" {% endif %}
29
34
   class="btn
30
-
   {% if not dutch_link %}disabled{% endif %}">
+
35
   {% if not dutch_link %}disabled{% endif %}">
31
36
    🇧🇪 {{ LANG.name_translated}} 🇳🇱
32
37
</a>
33
38
{% get_current_language as lang %}
34
39
{% get_language_info for 'fr' as LANG %}
35
40
<a {% if french_link %} href="{{french_link}}" {% endif %}
36
41
   class="btn
37
-
   {% if not french_link %}disabled{% endif %}">
+
42
   {% if not french_link %}disabled{% endif %}">
38
43
    🇧🇪 {{ LANG.name_translated}} 🇫🇷
39
44
</a>
40
45
{% get_language_info for 'en' as LANG %}
41
46
<a {% if english_link %} href="{{english_link}}" {% endif %}
42
47
   class="btn
43
-
   {% if not english_link %}disabled{% endif %}">
+
48
   {% if not english_link %}disabled{% endif %}">
44
49
    🇬🇧 {{ LANG.name_translated}} 🇺🇸
45
50
</a>
46
51
{% get_language_info for 'de' as LANG %}
+
52
{% get_language_info for 'de' as LANG %}
47
53
<a {% if german_link %} href="{{german_link}}" {% endif %}
48
54
   class="btn
49
-
   {% if not german_link %}disabled{% endif %}">
+
55
   {% if not german_link %}disabled{% endif %}">
50
56
    🇧🇪 {{ LANG.name_translated}} 🇩🇪
51
57
</a>
52
58
{% comment %}
53
59
{% get_language_info for 'es' as LANG %}
54
60
<a {% if spanish_link %} href="{{spanish_link}}" {% endif %}
55
61
   class="btn
56
62
   {% if not spanish_link %}disabled{% endif %}">
57
63
    🇪🇸 {{ LANG.name_translated}} 🇲🇽
58
64
</a>
59
65
60
66
<h5 class="white-text">{% trans "Comments" %}</h5>
61
67
{% for comment in comments %} {# Whoops =P #}
62
68
    <span class="white-text">{{ comment.name|title }} | </span>
63
69
    <time class="grey-text" datetime="{{ comment.date|date:'c' }}">{{ comment.date|naturaltime }}</time>
64
70
    <br />
65
71
    <p class="white-text">{{ comment.text|urlize }}</p>
66
72
    <hr />
67
73
{% endfor %}
68
74
    {# Form for new comment #}
69
75
    <form action="" method="POST">
70
76
        {% csrf_token %}
71
77
        {{ form.name.label_tag }}
72
78
        <input class="white-text browser-default" type="text" id="id_name" name="name" maxlength="64" required />
73
79
        {{ form.text.label_tag }}
74
80
        <textarea id="id_text" class="white-text" name="text" maxlength="1000" required></textarea>
75
81
        <input type="submit" value="{% trans "Submit" %}" />
76
82
    </form>
77
83
78
84
79
85
{% comment %}
80
86
<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>
81
87
    {# TODO: Change to rainbow flag when possible #}
82
88
{% endcomment %}
83
89
    </div>
84
90
85
91
</div>
86
92
<div class="container">
87
93
    {% for title, date, description, link in post_links %}
88
94
        <h2 class="{{ color}}-text">{{ title }}</h2>
89
95
        {# FIXME: Date is in all languages of the same format. Fix for each language #}
90
96
        <span class="grey-text">{{ date|date:"l j F Y" }}</span>
91
97
        {#<p class="hide-on-small-only">{{ description }}</p>#}
92
98
        <p class="hide-on-small-only">{% lorem %}</p>
93
99
        <a class="btn {{accent_color}} accent-3" href="{{link}}">
94
100
            {% trans "Read on"%}
95
101
        </a>
96
102
        <hr />
97
103
    {% endfor %}
98
104
</div>
99
105
{% endwith %}
100
-
{% endblock main %}
101
106

templates/blog/weekly_archive.djhtml

0 additions and 41 deletions.

View changes Hide changes
1
-
{% load i18n %}
2
-
{% load static %}
3
-
4
-
{% block stylesheets %}
5
-
{{ block.super }}
6
-
{% endblock stylesheets %}
7
-
8
-
{% block title %}{% trans "Weekly | Archief" %}{% endblock title %}
9
-
10
-
{% block description %}
11
-
{% trans "Voor een duik terug in de geschiedenis van mijn publieke dagboek." %}
12
-
{% endblock description %}
13
-
14
-
{% block main %}
15
-
<section class="emphasis">
16
-
	<p>
17
-
        Dit is het archief van de vorige weekly's, een soort van
18
-
	    "(bijna-)wekelijks" dagboek, waarin ik kort praat over de dingen die er die
19
-
	    week gebeurd zijn. Ik maak vanaf nu ook de vorige posts beschikbaar voor wie
20
-
		ze wilt inkijken.
21
-
    </p>
22
-
</section>
23
-
24
-
<section>
25
-
	<h1 id="2017">2017</h1>
26
-
	{{ t2017|safe }}
27
-
</section>
28
-
<section>
29
-
	<h1 id="2018">2018</h1>
30
-
	{{ t2018|safe }}
31
-
</section>
32
-
<section>
33
-
	<h1 id="2019">2019</h1>
34
-
	{{ t2019|safe }}
35
-
</section>
36
-
<section>
37
-
	<h1 id="2020">2020</h1>
38
-
	{{ t2020|safe }}
39
-
</section>
40
-
{% endblock main %}
41
-

urls.py

1 addition and 1 deletion.

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
    url(r'^$', views.index, name='blog-index'),
6
6
    url(r'^feed.rss$', views.rss, name='blog-feed'),
7
7
    url(r'^(?P<language>(.){2})/(?P<post_slug>(.)+)$', views.post, name='blog-post-language'),
8
8
    url(r'^weekly-archive$', views.weekly_archive, name="weekly-archive"),
9
-
    url(r'^(?P<post_slug>(.)+)$', views.post, name='blog-post'),
+
9
    url(r'^(?P<post_slug>(.)+)$', views.post, name='blog-post'),
10
10
        ]
11
11

views.py

4 additions and 4 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.urls import reverse
7
7
from django.template import loader # This allows to actually load the template.
8
8
from .models import *
9
9
from .forms import CommentForm
10
10
from django.core.exceptions import ObjectDoesNotExist
11
11
from django.utils import translation
12
12
13
13
GERMAN = "de"
14
14
SPANISH = "es"
15
15
FRENCH = "fr"
16
16
DUTCH = "nl"
17
17
ENGLISH = "en"
18
18
19
19
footer_links = [
20
20
        [_("Back to main page"), "/blog"],
21
21
        [_("Contact"), "mailto:maarten.vangeneugden@student.uhasselt.be"],
22
22
        ]
23
23
footer_description = _("Maarten's personal blog, with sprinkles and a dollop of healthy bugs.")
24
24
25
25
def org_to_html(file_path):
26
26
    """ Converts the given org formatted file to HTML.
27
27
    This function directly returns the resulting HTML code. This function uses
28
28
    the amazing Haskell library Pandoc to convert the file (and takes care
29
29
    of header id's and all that stuff).
30
30
    """
31
31
    # FIXME: Remove hardcoded link to media. Replace with media tag!
32
32
    # XXX: The reason I'm first converting all occurences of .jpg][ and .png][
33
33
    # to .jpgPANDOCBUG][ and .pngPANDOCBUG][, is because of a Pandoc bug that
34
34
    # removes the text links for images. It is afterwards converted back, no
35
35
    # worries.
36
36
    file = open("/srv/django/website/media/"+file_path, "r", encoding="utf-8")
37
37
    text = file.read()
38
38
    file.close()
39
39
    text = text.replace(".jpg][", ".jpgPANDOCBUG][")
40
40
    text = text.replace(".png][", ".pngPANDOCBUG][")
41
41
    file = open("/tmp/blog-file.org", "w", encoding="utf-8")
42
42
    file.write(text)
43
43
    file.close()
44
44
    html_text = subprocess.check_output(["pandoc", "--from=org", "--to=html","/tmp/blog-file.org"])
45
45
    html_text = html_text.decode("utf-8").replace(".jpgPANDOCBUG", ".jpg")
46
46
    html_text = html_text.replace(".pngPANDOCBUG", ".png")
47
47
    return html_text
48
48
49
49
def get_available_post_languages(post):
50
50
    """ Returns the language codes for which a blog post exists. This function
51
51
    always returns English (because that field mustn't be empty).
52
52
    So say a blog post has an English, Dutch and French version (which means
53
53
    english_file, french_file and dutch_file aren't empty), the function will return {"en",
54
54
    "fr", "nl"}. """
55
55
    available_languages = {ENGLISH}
56
56
    if post.german_file != "":
57
57
        available_languages.add(GERMAN)
58
58
    if post.spanish_file != "":
59
59
        available_languages.add(SPANISH)
60
60
    if post.french_file != "":
61
61
        available_languages.add(FRENCH)
62
62
    if post.dutch_file != "":
63
63
        available_languages.add(DUTCH)
64
64
    return available_languages
65
65
66
66
def index(request):
67
67
    template = "blog/index.html"
68
-
    posts = Post.objects.all()
+
68
    posts = Post.objects.all()
69
69
    language = translation.get_language()
70
70
71
71
    post_links = []
72
72
    for post in posts:
73
73
        blog_file = post.text_file(language)
74
74
        blog_text = org_to_html(blog_file.name)
75
75
        # TODO: The link can possibly be reversed in the DTL using the title, which is actually
76
76
        # a cleaner way to do it. Investigate.
77
77
        link = reverse("blog-post-language", args=[language, post.slug(language)])
78
78
        post_links.append([post.title(language), post.published, blog_text, link])
79
79
80
80
    context = {
81
81
            'posts': post_links,
82
82
            'materialDesign_color': "brown",
83
83
            'materialDesign_accentColor': "blue",
84
84
            'navbar_title': _("Notepad from a student"),
85
85
            'navbar_backArrow': True,
86
86
            'footer_links': footer_links,
87
87
            'footer_description': footer_description,
88
88
            }
89
89
    if not request.session.get("feed-fab-introduction-seen", default=False):
90
90
        context['introduce_feed'] = True
91
91
        request.session['feed-fab-introduction-seen'] = True
92
92
    return render(request, template, context)
93
93
94
94
def post(request, post_slug, language=None):
95
95
    if request.method == "POST":  # Handling a reply if one is sent
96
96
        form = CommentForm(request.POST)
97
97
        for post in Post.objects.all():
98
98
            if post.slug(language) == post_slug:
99
99
                form.post = post
100
100
                break
101
101
        if form.is_valid():
102
102
            new_comment = form.save(commit=False)
103
103
            for post in Post.objects.all():
104
104
                if post.slug(language) == post_slug:
105
105
                    new_comment.post = post
106
106
                    new_comment.save()
107
107
    if language is not None:
108
108
        if translation.check_for_language(language):
109
109
            translation.activate(language)
110
110
            request.session[translation.LANGUAGE_SESSION_KEY] = language
111
111
            #return post(request, post_slug)
112
112
    else:
113
113
        language = translation.get_language()
114
114
115
115
    template = "blog/post.html"
116
-
    posts = Post.objects.all()
+
116
    posts = Post.objects.all()
117
117
    #comments = Comment.objects.filter(post
118
118
    for post in posts:
119
119
        if post.slug(language) == post_slug:
120
120
            comments = Comment.objects.filter(post=post)
121
121
            form = CommentForm()
122
122
            post_file = post.text_file(language)
123
123
            post_text = org_to_html(post_file.name)
124
124
            context = {
125
125
                'comments': comments,
126
126
                'form' : form,
127
127
                'human_post_title': post.title(language),
128
128
                'materialDesign_color': "brown",
129
129
                'materialDesign_accentColor': "blue",
130
130
                'article': post_text,
131
131
                'title': post.title(language),
132
132
                'navbar_title': post.title(language),
133
133
                'navbar_backArrow': False,
134
134
                'post_slug': post_slug,
135
135
                'footer_links': footer_links,
136
136
                'footer_description': footer_description,
137
137
                }
138
138
139
139
            # Getting all available article links
140
140
            available = get_available_post_languages(post)
141
141
            if ENGLISH in available:
142
142
                context['english_link'] = reverse("blog-post-language", args=[ENGLISH, post.slug(ENGLISH)])
143
143
            if DUTCH in available:
144
144
                context['dutch_link'] = reverse("blog-post-language", args=[DUTCH, post.slug(DUTCH)])
145
145
146
146
            if FRENCH in available:
147
147
                context['french_link'] = reverse("blog-post-language", args=[FRENCH, post.slug(FRENCH)])
148
148
149
149
            if SPANISH in available:
150
150
                context['spanish_link'] = reverse("blog-post-language", args=[SPANISH, post.slug(SPANISH)])
151
151
152
152
            if GERMAN in available:
153
153
                context['german_link'] = reverse("blog-post-language", args=[GERMAN, post.slug(GERMAN)])
154
154
155
155
            return render(request, template, context)
156
156
157
157
def rss(request):
158
158
    template = "blog/feed.rss"
159
159
    context = {
160
160
        'items': FeedItem.objects.all(),
161
161
        }
162
162
    return render(request, template, context)
163
163
164
164
165
165
def weekly_archive(request):
166
-
    template = "blog/weekly_archive.html"
167
-
    language = translation.get_language()
+
166
    template = "blog/monthly_archive.djhtml"
+
167
    language = translation.get_language()
168
168
169
169
    file_2017 = org_to_html("blog/weekly/2017.org")
170
170
    file_2018 = org_to_html("blog/weekly/2018.org")
171
171
    file_2019 = org_to_html("blog/weekly/2019.org")
172
172
173
173
174
174
175
175
    context = {
176
176
        't2017': file_2017,
177
177
        't2018': file_2018,
178
178
        't2019': file_2019,
179
179
            'materialDesign_color': "brown",
180
180
            'materialDesign_accentColor': "blue",
181
181
            'navbar_title': _("Weekly-archief"),
182
182
            'navbar_backArrow': True,
183
183
            'footer_links': footer_links,
184
184
            'footer_description': footer_description,
185
185
            }
186
186
    return render(request, template, context)
187
187