improved languages' layout

parent 26fcefaf
h2 {
text-align: center;
}
content {
display: grid;
grid-template-areas:
'natw conw';
}
natlangw {
grid-area: natw;
overflow-y: auto;
}
conlangw {
grid-area: conw;
overflow-y: auto;
}
.wordblock {
......
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
@font-face {
font-family: "DoulosSIL";
......@@ -14,27 +13,10 @@ body {
display: grid;
overflow: auto;
height: 100vh;
grid-template-columns: 300px auto;
grid-template-areas:
'sidebar content';
color: #404040;
}
.h1 {
margin-bottom: .2em;
font-size: 175%;
font-family: "Roboto Slab", "ff-tisa-web-pro", "Georgia", Arial, sans-serif;
font-weight: 700;
text-align: center;
}
.p {
font-size: inherit;
line-height: 24px;
margin: 0 0 24px 0;
box-sizing: border-box;
display: block;
font-family: "DoulosSIL", "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif;
grid-template-columns: 300px auto;
}
sidebar {
......@@ -52,11 +34,9 @@ sidebar {
content {
margin: 10px;
padding: 20px;
grid-area: content;
}
content {
max-width: 900px;
max-width: 1200px;
background-color: #fcfcfc;
overflow-y: auto;
overflow-x: hidden;
......@@ -69,6 +49,23 @@ errormessage {
font-family: "DoulosSIL", "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif;
}
.h1 {
margin-bottom: .2em;
font-size: 175%;
font-family: "Roboto Slab", "ff-tisa-web-pro", "Georgia", Arial, sans-serif;
font-weight: 700;
text-align: center;
}
.p {
font-size: inherit;
line-height: 24px;
margin: 0 0 24px 0;
box-sizing: border-box;
display: block;
font-family: "DoulosSIL", "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif;
}
.sidebar-title,
.sidebar-footer {
background: #2980b9;
......@@ -77,7 +74,7 @@ errormessage {
margin-block-end: 0;
text-align: center;
vertical-align: middle;
font-size: 1.5em;
font-size: 1.4em;
}
.sidebar-title {
......@@ -87,6 +84,22 @@ errormessage {
.sidebar-footer {
grid-area: sidebar-footer;
cursor: pointer;
display: grid;
grid-template-areas:
'index back';
}
.index {
grid-area: index;
}
.back {
grid-area: back;
}
.sidebar-footer > a {
color: #fcfcfc;
text-decoration: none;
}
.sidebar-content {
......
......@@ -5,24 +5,36 @@
<head>
<meta charset="UTF-8">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'dictionary/style.css' %}" type="text/css" media="screen" />
<link rel="shortcut icon" href="{% static 'dictionary/mahakala-128x128.png' %}" type="image/png" media="screen" />
<link rel="shortcut icon" href="https://langue.phundrak.fr/favicon.ico" type="image/x-icon" />
<meta property="og:image" content="https://langue.phundrak.fr/img/rich_preview.jpg" />
<link rel="stylesheet"
href="{% static 'dictionary/style.css' %}"
type="text/css"
media="screen" />
<link rel="shortcut icon"
href="{% static 'dictionary/mahakala-128x128.png' %}"
type="image/png"
media="screen" />
<link rel="shortcut icon"
href="{% static 'dictionary/mahakala-128x128.png' %}"
type="image/png" />
<meta property="og:image"
content="https://langue.phundrak.fr/img/rich_preview.jpg" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@phundrak" />
<meta name="twitter:creator" content="@phundrak" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block addhead %}{% endblock %}
</head>
<body>
<sidebar>{% block sidebarcontent %}{% endblock %}</sidebar>
<content>
<errormessage>{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}</errormessage>
<errormessage>
{% if error_message %}
<p><strong>{{ error_message }}</strong></p>
{% endif %}
</errormessage>
{% block body %}
{% endblock %}
</content>
</body>
</html>
......@@ -19,7 +19,7 @@
<!-- SIDEBAR ----------------------------------------------------------------->
{% block sidebarcontent %}
<h1 class="sidebar-title">Detailed Translation</h1>
<h1 class="sidebar-footer" onclick="window.history.go(-1);">Go Back</h1>
{% include "dictionary/footer-back-index.html" %}
{% endblock %}
<!-- BODY -------------------------------------------------------------------->
......
<div class="sidebar-footer">
<a class="index" href="{% url 'dictionary:index' %}">Index</a>
<a class="back" href="#" onclick="history.go(-1)">Go Back</a>
</div>
......@@ -2,7 +2,7 @@
{% load staticfiles %}
<!-- TITLE ------------------------------------------------------------------->
{% block title %}{{from_lang.name}} -> {{to_lang.name}}{% endblock %}
{% block title %}{{natlang.name}} ⇌ {{conlang.name}}{% endblock %}
<!-- HEADERS ----------------------------------------------------------------->
{% block addhead %}
......@@ -11,24 +11,52 @@
<!-- SIDEBAR ----------------------------------------------------------------->
{% block sidebarcontent %}
<h1 class="sidebar-title">Translating from {{from_lang.name}} to {{to_lang.name}}</h1>
<h1 class="sidebar-footer" onclick="window.history.go(-1);">Go Back</h1>
<h1 class="sidebar-title">Translating between {{natlang.name}} and {{conlang.name}}</h1>
{% include "dictionary/footer-back-index.html" %}
{% endblock %}
<!-- BODY -------------------------------------------------------------------->
{% block body %}
<wordlist>
{% for word in words %}
<a href="{% url 'dictionary:details' from_lang.code to_lang.code word.slug %}" class="wordblock">
<word>{{word.word}}</word>
<wclass>{{word.wordclass}}</wclass>
<gender>{{word.gender}}</gender>
<ul class="translations">
{% for trans in word.translation.all %}
<li>{{trans}} ({{trans.language.name}})</li>
<natlangw>
<h2>{{natlang.name}}</h2>
<wordlist>
{% for word in natwords %}
<a href="{% url 'dictionary:details' natlang.code conlang.code word.slug %}" class="wordblock">
<word>{{word.word}}</word>
<wclass>
{% if word.wordclass %}
{{word.wordclass}}
{% endif %}
</wclass>
<gender>{{word.gender}}</gender>
<ul class="translations">
{% for trans in word.translation.all %}
<li>{{trans}} ({{trans.language.name}})</li>
{% endfor %}
</ul>
</a>
{% endfor %}
</ul>
</a>
{% endfor %}
</wordlist>
</wordlist>
</natlangw>
<conlangw>
<h2>{{conlang.name}}</h2>
<wordlist>
{% for word in conwords %}
<a href="{% url 'dictionary:details' conlang.code natlang.code word.slug %}" class="wordblock">
<word>{{word.word}}</word>
<wclass>
{% if word.wordclass %}
{{word.wordclass}}
{% endif %}
</wclass>
<gender>{{word.gender}}</gender>
<ul class="translations">
{% for trans in word.translation.all %}
<li>{{trans}} ({{trans.language.name}})</li>
{% endfor %}
</ul>
</a>
{% endfor %}
</wordlist>
</conlangw>
{% endblock %}
......@@ -14,18 +14,16 @@ urlpatterns = [
# renvoie à la liste des mots de la première initiale de <from_lang>
# /search/<from_lang>/<to_lang>/
# /search/HJP/FRA
# url(r'^from=(?P<from_lang>\w+)/to=(?P<to_lang>\w+)/*$',
url(r'^search/(?P<from_lang>\w+)/(?P<to_lang>\w+)/*$',
url(r'^search/(?P<natlang>\w+)/(?P<conlang>\w+)/*$',
views.index_lang,
name='listinitials'),
name='index_lang'),
# renvoie la liste des mots de `from_lang` et leur traduction abrégée en
# `to_lang` commençant par la lettre `initial`
# renvoie à la liste des mots de la première initiale de <from_lang>
# /search/<from_lang>/<to_lang>/<initial>
# /search/HJP/FRA/a
url(r'^search/(?P<from_lang>\w+)/(?P<to_lang>\w+)/(?P<initial>\S)/*$',
views.listwords,
name='listwords'),
url(r'^search/(?P<from_lang>\w+)/(?P<to_lang>\w+)/(?P<initial>\w)/*$',
views.list_initial,
name='index_initial'),
# renvoie le détail de la traduction de `word` en `from_lang` vers
# `to_lang`
......
......@@ -13,27 +13,23 @@ def index(request):
Will display the list of languages available and let the user choose which
language to get the words from and to which language it will be translated.
The two languages cannot be two natural languages or two conlangs.
View for https://dict.phundrak.fr/
"""
error_message = ""
if request.method == 'POST':
print("POST")
form = SelectLangForm(request.POST)
if form.is_valid():
print("IS VALID")
from_lang = form.cleaned_data['from_lang']
to_lang = form.cleaned_data['to_lang']
print(from_lang.code + " and " + to_lang.code)
if from_lang.conlang != to_lang.conlang:
return HttpResponseRedirect('/search/' +
from_lang.code + '/' +
return HttpResponseRedirect('/search/' + from_lang.code + '/' +
to_lang.code)
error_message = "You cannot select two natural languages or two conlangs."
else:
print("NOT VALID")
print(form.errors)
error_message = form.errors
else:
print("GET")
form = SelectLangForm()
all_languages = Language.objects.all()
return render(request, 'dictionary/index.html', {
......@@ -42,32 +38,34 @@ def index(request):
})
def index_lang(request, from_lang, to_lang):
def index_lang(request, natlang, conlang):
"""
Will list all the words from the language `from_lang` translated to the
language `to_lang`
Will list all the words from the language `natlang` translated to the
language `conlang` and vice-versa
View for https://dict.phundrak.fr/search/from_lang/to_lang
"""
words = Word.objects.filter(language__code=from_lang)
from_lang = Language.objects.get(code=from_lang)
to_lang = Language.objects.get(code=to_lang)
natwords = Word.objects.filter(language__code=natlang)
conwords = Word.objects.filter(language__code=conlang)
natlang = Language.objects.get(code=natlang)
conlang = Language.objects.get(code=conlang)
return render(request, 'dictionary/language.html', {
'words': words,
'from_lang': from_lang,
'to_lang': to_lang,
'natwords': natwords,
'conwords': conwords,
'natlang': natlang,
'conlang': conlang,
})
def listwords(request, from_lang, to_lang, initial):
def list_initial(request, from_lang, to_lang, initial):
"""
This will list all the words from the language `from_lang` beginning with
the letter `initial` and translated to the language `to_lang`. It is similar
to `index_lang` but restricts the amount of words displayed on a single
page.
View for https://dict.phundrak.fr/search/from_lang/to_lang/initial
"""
# initial_lang = Language.objects.get(code=from_lang)
# target_lang = Language.objects.get(code=to_lang)
# words = Word.objects.filter(language=initial_lang).filter(
# word__startswith(initial))
pass
......@@ -76,6 +74,8 @@ def details(request, from_lang, to_lang, word):
Displays the details about the word `word` from the language `from_lang` if
this word is from a conlang and will display its translations to the
language `to_lang`
View for https://dict.phundrak.fr/word/from_lang/to_lang/word
"""
from_lang = Language.objects.get(code=from_lang)
to_lang = Language.objects.get(code=to_lang)
......@@ -94,7 +94,52 @@ def guessword(request, from_lang, word):
"""
Is used to get five words from `from_lang` beginning with `word`. This will
be used for word suggestion when using the search bar.
View for https://dict.phundrak.fr/guess/from_lang/word
"""
pass
def user_add_word(request, language):
"""
Allows authorized users to add new words to a selected language
View for https://dict.phundrak.fr/addword/language/
"""
pass
def user_add_language(request):
"""
Allows authorized users to add new languages
View for https://dict.phundrak.fr/addlanguage/
"""
pass
def user_add_word_class(request):
"""
Allows authorized users to add new word classes
View for https://dict.phundrak.fr/addwclass
"""
pass
def user_add_gender(request):
"""
Allowsauthorized users to add new genders
View for https://dict.phundrak.fr/addgender
"""
pass
def user_edit_word(request, language, word):
"""
Allows authorized users to edit existing `word` in selected `language`
View for https://dict.phundrak.fr/edit/language/word
"""
# words = Word.object.filter(language=from_lang).filter(
# slug__stratswith(slugify(word)))[:5]
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment