Add translation files
- Author
- Maarten Vangeneugden
- Date
- Oct. 19, 2017, 6:28 p.m.
- Hash
- 9056b03d04dda24c4f5972131a00a9410e0df98a
- Parent
- 48b5846371344afadece22adfa9e2e73e3d96dbe
- 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.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 ¶
22 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
+ |
19 |
#: blog/views.py:95 |
+ |
20 |
msgid "Notepad from a student" |
+ |
21 |
msgstr "" |
+ |
22 |
locale/es/LC_MESSAGES/django.po ¶
22 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
+ |
19 |
#: blog/views.py:95 |
+ |
20 |
msgid "Notepad from a student" |
+ |
21 |
msgstr "" |
+ |
22 |
locale/fr/LC_MESSAGES/django.po ¶
22 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
+ |
19 |
#: blog/views.py:95 |
+ |
20 |
msgid "Notepad from a student" |
+ |
21 |
msgstr "" |
+ |
22 |
locale/nl/LC_MESSAGES/django.po ¶
22 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
+ |
19 |
#: blog/views.py:95 |
+ |
20 |
msgid "Notepad from a student" |
+ |
21 |
msgstr "" |
+ |
22 |
templates/blog/index.html ¶
2 additions and 2 deletions.
View changes Hide changes
1 |
1 |
{% load i18n %} |
2 |
2 |
|
3 |
3 |
{% block title %}{% trans "Maarten's blog" %}{% endblock title %} |
4 |
4 |
|
5 |
5 |
{% block description %}{% blocktrans %}The always coherently put together, yet |
6 |
6 |
fuzzy blog of whatever sprouts in my mind.{% endblocktrans %} |
7 |
7 |
{% endblock description %} |
8 |
8 |
|
9 |
9 |
{% block main %} |
10 |
10 |
{% with color="brown" accent_color="yellow" %} |
11 |
11 |
<div class="section {{ color }} z-depth-3"> |
12 |
12 |
<div class="container"> |
13 |
13 |
<div class="white-text"> |
14 |
14 |
<h3>{% trans "Blog" %}</h3> |
15 |
15 |
<p> |
16 |
16 |
{% blocktrans %}Welcome to my blog. Here, I write |
17 |
17 |
about things that interest me. Politics, coding, |
18 |
18 |
studying, life, or anything else I fancy rambling |
19 |
19 |
about. If you're in luck, I may've written it in a |
20 |
20 |
language that you understand better than English. |
21 |
21 |
{% endblocktrans %} |
22 |
22 |
</p> |
23 |
23 |
</div> |
24 |
24 |
</div> |
25 |
25 |
</div> |
26 |
26 |
|
27 |
27 |
<div class="container"> |
28 |
28 |
{% for title, date, description, link in post_links %} |
29 |
29 |
<h2 class="{{ color}}-text">{{ title }}</h2> |
30 |
30 |
{# FIXME: Date is in all languages of the same format. Fix for each language #} |
31 |
31 |
<span class="grey-text">{{ date|date:"l j F Y" }}</span> |
32 |
32 |
<p class="hide-on-small-only">{{ description|safe }}</p> |
33 |
- | {#<p class="hide-on-small-only">{% lorem %}</p>#} |
+ |
33 |
{#<p class="hide-on-small-only">{% lorem %}</p>#} |
34 |
34 |
<a class="btn {{accent_color}} accent-3" href="{{link}}"> |
35 |
- | {% trans "Read on"%} |
+ |
35 |
{% trans "Read on"%} |
36 |
36 |
</a> |
37 |
37 |
<hr /> |
38 |
38 |
{% endfor %} |
39 |
39 |
</div> |
40 |
40 |
{% endwith %} |
41 |
41 |
{% endblock main %} |
42 |
42 |
templates/blog/locale/de/LC_MESSAGES/django.po ¶
46 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
+ |
19 |
#: blog/templates/blog/index.html:4 |
+ |
20 |
msgid "Maarten's blog" |
+ |
21 |
msgstr "" |
+ |
22 |
|
+ |
23 |
#: blog/templates/blog/index.html:6 |
+ |
24 |
msgid "" |
+ |
25 |
"The always coherently put together, yet\n" |
+ |
26 |
"fuzzy blog of whatever sprouts in my mind." |
+ |
27 |
msgstr "" |
+ |
28 |
|
+ |
29 |
#: blog/templates/blog/index.html:15 |
+ |
30 |
msgid "Blog" |
+ |
31 |
msgstr "" |
+ |
32 |
|
+ |
33 |
#: blog/templates/blog/index.html:17 |
+ |
34 |
msgid "" |
+ |
35 |
"Welcome to my blog. Here, I write\n" |
+ |
36 |
" about things that interest me. Politics, coding,\n" |
+ |
37 |
" studying, life, or anything else I fancy rambling\n" |
+ |
38 |
" about. If you're in luck, I may've written it in a\n" |
+ |
39 |
" language that you understand better than English.\n" |
+ |
40 |
" " |
+ |
41 |
msgstr "" |
+ |
42 |
|
+ |
43 |
#: blog/templates/blog/index.html:36 |
+ |
44 |
msgid "Read on" |
+ |
45 |
msgstr "" |
+ |
46 |
templates/blog/locale/es/LC_MESSAGES/django.po ¶
46 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
+ |
19 |
#: blog/templates/blog/index.html:4 |
+ |
20 |
msgid "Maarten's blog" |
+ |
21 |
msgstr "" |
+ |
22 |
|
+ |
23 |
#: blog/templates/blog/index.html:6 |
+ |
24 |
msgid "" |
+ |
25 |
"The always coherently put together, yet\n" |
+ |
26 |
"fuzzy blog of whatever sprouts in my mind." |
+ |
27 |
msgstr "" |
+ |
28 |
|
+ |
29 |
#: blog/templates/blog/index.html:15 |
+ |
30 |
msgid "Blog" |
+ |
31 |
msgstr "" |
+ |
32 |
|
+ |
33 |
#: blog/templates/blog/index.html:17 |
+ |
34 |
msgid "" |
+ |
35 |
"Welcome to my blog. Here, I write\n" |
+ |
36 |
" about things that interest me. Politics, coding,\n" |
+ |
37 |
" studying, life, or anything else I fancy rambling\n" |
+ |
38 |
" about. If you're in luck, I may've written it in a\n" |
+ |
39 |
" language that you understand better than English.\n" |
+ |
40 |
" " |
+ |
41 |
msgstr "" |
+ |
42 |
|
+ |
43 |
#: blog/templates/blog/index.html:36 |
+ |
44 |
msgid "Read on" |
+ |
45 |
msgstr "" |
+ |
46 |
templates/blog/locale/fr/LC_MESSAGES/django.po ¶
46 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
+ |
19 |
#: blog/templates/blog/index.html:4 |
+ |
20 |
msgid "Maarten's blog" |
+ |
21 |
msgstr "" |
+ |
22 |
|
+ |
23 |
#: blog/templates/blog/index.html:6 |
+ |
24 |
msgid "" |
+ |
25 |
"The always coherently put together, yet\n" |
+ |
26 |
"fuzzy blog of whatever sprouts in my mind." |
+ |
27 |
msgstr "" |
+ |
28 |
|
+ |
29 |
#: blog/templates/blog/index.html:15 |
+ |
30 |
msgid "Blog" |
+ |
31 |
msgstr "" |
+ |
32 |
|
+ |
33 |
#: blog/templates/blog/index.html:17 |
+ |
34 |
msgid "" |
+ |
35 |
"Welcome to my blog. Here, I write\n" |
+ |
36 |
" about things that interest me. Politics, coding,\n" |
+ |
37 |
" studying, life, or anything else I fancy rambling\n" |
+ |
38 |
" about. If you're in luck, I may've written it in a\n" |
+ |
39 |
" language that you understand better than English.\n" |
+ |
40 |
" " |
+ |
41 |
msgstr "" |
+ |
42 |
|
+ |
43 |
#: blog/templates/blog/index.html:36 |
+ |
44 |
msgid "Read on" |
+ |
45 |
msgstr "" |
+ |
46 |
templates/blog/locale/nl/LC_MESSAGES/django.po ¶
46 additions and 0 deletions.
View changes Hide changes
+ |
1 |
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
+ |
2 |
# This file is distributed under the same license as the PACKAGE package. |
+ |
3 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
+ |
4 |
# |
+ |
5 |
#, fuzzy |
+ |
6 |
msgid "" |
+ |
7 |
msgstr "" |
+ |
8 |
"Project-Id-Version: PACKAGE VERSION\n" |
+ |
9 |
"Report-Msgid-Bugs-To: \n" |
+ |
10 |
"POT-Creation-Date: 2017-10-19 18:27+0200\n" |
+ |
11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
+ |
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
+ |
13 |
"Language-Team: LANGUAGE <LL@li.org>\n" |
+ |
14 |
"Language: \n" |
+ |
15 |
"MIME-Version: 1.0\n" |
+ |
16 |
"Content-Type: text/plain; charset=UTF-8\n" |
+ |
17 |
"Content-Transfer-Encoding: 8bit\n" |
+ |
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
+ |
19 |
#: blog/templates/blog/index.html:4 |
+ |
20 |
msgid "Maarten's blog" |
+ |
21 |
msgstr "" |
+ |
22 |
|
+ |
23 |
#: blog/templates/blog/index.html:6 |
+ |
24 |
msgid "" |
+ |
25 |
"The always coherently put together, yet\n" |
+ |
26 |
"fuzzy blog of whatever sprouts in my mind." |
+ |
27 |
msgstr "" |
+ |
28 |
|
+ |
29 |
#: blog/templates/blog/index.html:15 |
+ |
30 |
msgid "Blog" |
+ |
31 |
msgstr "" |
+ |
32 |
|
+ |
33 |
#: blog/templates/blog/index.html:17 |
+ |
34 |
msgid "" |
+ |
35 |
"Welcome to my blog. Here, I write\n" |
+ |
36 |
" about things that interest me. Politics, coding,\n" |
+ |
37 |
" studying, life, or anything else I fancy rambling\n" |
+ |
38 |
" about. If you're in luck, I may've written it in a\n" |
+ |
39 |
" language that you understand better than English.\n" |
+ |
40 |
" " |
+ |
41 |
msgstr "" |
+ |
42 |
|
+ |
43 |
#: blog/templates/blog/index.html:36 |
+ |
44 |
msgid "Read on" |
+ |
45 |
msgstr "" |
+ |
46 |
templates/blog/post.html ¶
13 additions and 13 deletions.
View changes Hide changes
1 |
1 |
{% load i18n %} |
2 |
2 |
|
3 |
3 |
{% block title %}{{ post-title }} | Blog{% endblock title %} |
4 |
- | |
+ |
4 |
|
5 |
5 |
{% block description %}{{ post-description }}{% endblock description %} |
6 |
- | |
+ |
6 |
|
7 |
7 |
{% block main %} |
8 |
8 |
{% with color="brown" accent_color="yellow" %} |
9 |
9 |
<div class="section {{ color }} z-depth-3"> |
10 |
- | <div class="container"> |
+ |
10 |
<div class="container"> |
11 |
11 |
<div class="white-text" style="font-family:serif;"> |
12 |
- | {{ blog-post }} |
13 |
- | </div> |
+ |
12 |
{{ article|safe }} |
+ |
13 |
</div> |
14 |
14 |
</div> |
15 |
15 |
</div> |
16 |
16 |
|
17 |
- | {% get_language_info for "en" as lang %} |
+ |
17 |
{% get_language_info for "en" as lang %} |
18 |
18 |
<a href="{% url 'blog-post' 'en' post-url %}"class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans 'Share the English version>{{lang.name_translated}}</a> |
19 |
- | |
20 |
- | <a href="{% url 'blog-post' l1nguage post %}"class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans ">Hover me!</a> |
21 |
- | <a href="{% url 'blog-post' l1nguage post %}"class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans ">Hover me!</a> |
22 |
- | <a href="{% url 'blog-post' l1nguage post %}"class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans ">Hover me!</a> |
23 |
- | <a href="{% url 'blog-post' post-url %}" 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 possible languages" %}</a> |
24 |
- | |
25 |
- | |
+ |
19 |
data-position="bottom" data-delay="50" data-tooltip="{% trans 'Share the English version' %}">{{lang.name_translated}}</a> |
+ |
20 |
<a href="{% url 'blog_post' l1nguage post %}" class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans ">Hover me!</a> |
+ |
21 |
<a href="{% url 'blog_post' l1nguage post %}"class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans ">Hover me!</a> |
+ |
22 |
<a href="{% url 'blog_post' l1nguage post %}"class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="{% trans ">Hover me!</a> |
+ |
23 |
<a href="{% url 'blog_post' post_url %}" 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 possible languages" %}</a> |
+ |
24 |
|
26 |
25 |
<div class="container"> |
27 |
26 |
{% for title, date, description, link in post_links %} |
28 |
27 |
<h2 class="{{ color}}-text">{{ title }}</h2> |
29 |
28 |
{# FIXME: Date is in all languages of the same format. Fix for each language #} |
30 |
29 |
<span class="grey-text">{{ date|date:"l j F Y" }}</span> |
31 |
30 |
{#<p class="hide-on-small-only">{{ description }}</p>#} |
32 |
31 |
<p class="hide-on-small-only">{% lorem %}</p> |
33 |
32 |
<a class="btn {{accent_color}} accent-3" href="{{link}}"> |
34 |
33 |
{% trans "Read on"%} |
35 |
34 |
</a> |
36 |
35 |
<hr /> |
37 |
36 |
{% endfor %} |
38 |
37 |
</div> |
39 |
38 |
{% endwith %} |
+ |
39 |
{% endwith %} |
40 |
40 |
{% endblock main %} |
41 |
41 |
views.py ¶
9 additions and 0 deletions.
View changes Hide changes
1 |
1 |
import subprocess |
2 |
2 |
|
3 |
3 |
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. |
+ |
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. |
4 |
5 |
from django.http import HttpResponseRedirect, HttpResponse |
5 |
6 |
from django.core.urlresolvers import reverse # Why? |
6 |
7 |
from django.template import loader # This allows to actually load the template. |
7 |
8 |
from django.contrib.auth.decorators import login_required |
8 |
9 |
from django.contrib.auth import authenticate, login |
9 |
10 |
from .models import Post |
10 |
11 |
from django.core.exceptions import ObjectDoesNotExist |
11 |
12 |
from django.utils import translation |
12 |
13 |
|
13 |
14 |
# FIXME: Remove this template trash. THIS IS A VIEW, NOT A FUCKING TEMPLATE FFS |
14 |
15 |
context = { |
15 |
16 |
'materialDesign_color': "green", |
16 |
17 |
'materialDesign_accentColor': "purple", |
17 |
18 |
'navbar_title': "Blog", |
18 |
19 |
'navbar_fixed': True, |
19 |
20 |
'navbar_backArrow': True, |
20 |
21 |
#'footer_title': "Maarten's blog", |
21 |
22 |
#'footer_description': "My personal scribbly notepad.", |
22 |
23 |
#'footer_links': footer_links, |
23 |
24 |
} |
24 |
25 |
|
25 |
26 |
def markdown_to_html(file_path): |
26 |
27 |
""" Converts the given Markdown formatted file to HTML. |
27 |
28 |
This function directly returns the resulting HTML code. This function uses |
28 |
29 |
the amazing Haskell library Pandoc to convert the file (and takes care |
29 |
30 |
of header id's and all that stuff). |
30 |
31 |
""" |
31 |
32 |
return subprocess.check_output(["pandoc", "--from=markdown", "--to=html", "/srv/django/website/media/"+file_path]) |
32 |
33 |
|
33 |
34 |
def get_available_post_languages(post): |
34 |
35 |
""" Returns the language codes for which a blog post exists. This function |
35 |
36 |
always returns English (because that field mustn't be empty). |
36 |
37 |
So say a blog post has an English, Dutch and French version (which means |
37 |
38 |
english_file, french_file and dutch_file aren't empty), the function will return {"en", |
38 |
39 |
"fr", "nl"}. """ |
39 |
40 |
available_languages = {"en"} |
40 |
41 |
if post.german_file is not None: |
41 |
42 |
available_languages.add("de") |
42 |
43 |
if post.spanish_file is not None: |
43 |
44 |
available_languages.add("es") |
44 |
45 |
if post.french_file is not None: |
45 |
46 |
available_languages.add("fr") |
46 |
47 |
if post.dutch_file is not None: |
47 |
48 |
available_languages.add("nl") |
48 |
49 |
return available_languages |
49 |
50 |
|
50 |
51 |
def get_preferred_post_language(post, language): |
51 |
52 |
""" Returns the post language file that best suits the given language. This |
52 |
53 |
is handy if you know what language the user prefers, but aren't sure whether |
53 |
54 |
you can provide that language. This function will try to provide the file |
54 |
55 |
for that language, or return English if that's not possible. """ |
55 |
56 |
if language == "de" and post.german_file is not None: |
56 |
57 |
return post.german_file |
57 |
58 |
if language == "es" and post.spanish_file is not None: |
58 |
59 |
return post.spanish_file |
59 |
60 |
if language == "fr" and post.french_file is not None: |
60 |
61 |
return post.french_file |
61 |
62 |
if language == "nl" and post.dutch_file is not None: |
62 |
63 |
return post.dutch_file |
63 |
64 |
return post.english_file # Returned if all other choices wouldn't be satisfactory, or the requested language is English. |
64 |
65 |
|
65 |
66 |
def index(request): |
66 |
67 |
template = "blog/index.html" |
67 |
68 |
posts = Post.objects.all() |
68 |
69 |
language = translation.get_language() |
69 |
70 |
|
70 |
71 |
post_links = [] |
71 |
72 |
for post in posts: |
72 |
73 |
blog_file = get_preferred_post_language(post, language) |
73 |
74 |
# TODO: Find a cleaner way to determine the title. First and foremost: |
74 |
75 |
# If the language differs from English, the other language file needs to |
75 |
76 |
# be loaded. Plus: look for a built in function to remove the full path |
76 |
77 |
# and only return the file name. |
77 |
78 |
title = (blog_file.name.rpartition("/")[2]).rpartition(".")[0] |
78 |
79 |
date = post.published |
79 |
80 |
#description = "Lorem ipsum" |
80 |
81 |
blog_text = markdown_to_html(blog_file.name) |
81 |
82 |
#blog_text = blog_text.replace("\\n\\n", "</p><p>") |
82 |
83 |
#blog_text = blog_text.replace("\\n", " ") |
83 |
84 |
description = blog_text |
84 |
85 |
# TODO: The link can possibly be reversed in the DTL using the title, which is actually |
85 |
86 |
# a cleaner way to do it. Investigate. |
86 |
87 |
link = reverse("blog-post", args=[str(post)]) |
87 |
88 |
post_links.append([title, date, description, link]) |
88 |
89 |
|
89 |
90 |
context = { |
90 |
91 |
'post_links': post_links, |
91 |
92 |
} |
+ |
93 |
'materialDesign_accentColor': "yellow", |
+ |
94 |
'navbar_title': _("Notepad from a student"), |
+ |
95 |
'navbar_backArrow': True, |
+ |
96 |
} |
92 |
97 |
return render(request, template, context) |
93 |
98 |
|
94 |
99 |
def post(request, title): |
95 |
100 |
template = "blog/post.html" |
96 |
101 |
posts = Post.objects.all() |
97 |
102 |
for post in posts: |
98 |
103 |
if str(post)==title: |
99 |
104 |
language = translation.get_language() |
100 |
105 |
blog_file = get_preferred_post_language(post, language) |
101 |
106 |
blog_text = markdown_to_html(blog_file.name) |
102 |
107 |
context = { |
103 |
108 |
'article': blog_text, |
+ |
109 |
'materialDesign_accentColor': "yellow", |
+ |
110 |
'article': blog_text, |
104 |
111 |
'title': blog_file.name, |
105 |
112 |
} |
+ |
113 |
'navbar_backArrow': True, |
+ |
114 |
} |
106 |
115 |
return render(request, template, context) |
107 |
116 |