Currently moving from Gitlab to Gitea at https://labs.phundrak.com. Some features may not work anymore on this Gitlab instance.

rebooted project

parent ba7e091f
"""
Django settings for languephundrakfr project.
Django settings for conlangdict project.
Generated by 'django-admin startproject' using Django 2.1.2.
Generated by 'django-admin startproject' using Django 2.1.3.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
......@@ -20,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '#oc=#[email protected]%svwxw^r9j%[email protected]_ea1lc&(@x(q9$ddape-_kgsa0m'
SECRET_KEY = 'udbex%6hseo5tys7ovemjy&[email protected]*qc9=2gqufh$md%#(ofx*'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
......@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'dictionary.apps.DictionaryConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......@@ -49,7 +50,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'languephundrakfr.urls'
ROOT_URLCONF = 'conlangdict.urls'
TEMPLATES = [
{
......@@ -67,7 +68,7 @@ TEMPLATES = [
},
]
WSGI_APPLICATION = 'languephundrakfr.wsgi.application'
WSGI_APPLICATION = 'conlangdict.wsgi.application'
# Database
......
"""languephundrakfr URL Configuration
"""conlangdict URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
......@@ -15,9 +15,7 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import include
urlpatterns = [
path('admin/', admin.site.urls),
path('dictionary', include('dict.urls')),
]
"""
WSGI config for languephundrakfr project.
WSGI config for conlangdict project.
It exposes the WSGI callable as a module-level variable named ``application``.
......@@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'languephundrakfr.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conlangdict.settings')
application = get_wsgi_application()
from django.contrib import admin
# Register your models here.
This diff is collapsed.
from django.conf.urls import url
from . import views
app_name = 'dict'
urlpatterns = [
# /dict/from=FRA/to=HJA/a
url(r'^from=(?P<sourcelang>[a-zA-Z]+)/(?P<destlang>[a-zA-Z]+)/(?P<initial>[a-zA-Z])/*$',
views.listwords,
name='listwords'),
# /dict/lang=HJA/tay => renvoie cinq mots commençant par `tay`
url(r'^from=(?P<sourcelang>[a-zA-Z]+)/(?P<word>\w)/*$',
views.guess,
name='guess'),
# /dict/from=FRA/to=HJA/jour => renvoie le sommaire de la traduction de
# `jour`
url(
r'^from=<sourcelang>\w/to=<destlang>\w/<word>\w/*$',
views.translate,
name='translate',
),
# /dict/from=HJA/details=bém
url(
r'^lang=(?P<language>[a-zA-Z)+]/details=(?P<word>\w)/*$',
views.details,
name='details',
),
]
from django.shortcuts import render
from .models import Word
from django.utils import slugify
from django.shortcuts import render, get_object_or_404
def listwords(request, sourcelang, destlang, initial):
all_words = Word.objects.filter(
name__startswith=initial, language=sourcelang)
return render(request, 'dict/index.html', {'all_words': all_words})
def guess(request, sourcelang, word):
all_words = Word.objects.filter(name__startswith=word, language=sourcelang)
return render(request, 'dict/index.html', {'all_words': all_words})
def translate(request, sourcelang, destlang, word):
detailed_word = get_object_or_404(Word, slug=slugify(word), language=sourcelang)
translations = get_object_or_404(Word, slug=slugify(word), language)
return render(request, 'dict/detailed.html', {'detailed_word': detailed_word})
from django.contrib import admin
from .models import Language, Gender, Word, Wordclass
admin.site.register(Language)
admin.site.register(Gender)
admin.site.register(Word)
admin.site.register(Wordclass)
from django.apps import AppConfig
class DictConfig(AppConfig):
name = 'dict'
class DictionaryConfig(AppConfig):
name = 'dictionary'
# Generated by Django 2.1.3 on 2018-12-05 11:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Gender',
fields=[
('code', models.CharField(max_length=4, primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
],
options={
'ordering': ('name',),
},
),
migrations.CreateModel(
name='Language',
fields=[
('code', models.CharField(max_length=4, primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
],
options={
'ordering': ('code',),
},
),
migrations.CreateModel(
name='Word',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('word', models.CharField(max_length=128)),
('slug', models.CharField(max_length=128)),
('details', models.CharField(blank=True, max_length=8192)),
('etymology', models.CharField(blank=True, max_length=8192)),
('gender', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='dictionary.Gender')),
('language', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dictionary.Language')),
('roots', models.ManyToManyField(related_name='_word_roots_+', to='dictionary.Word')),
('translation', models.ManyToManyField(related_name='_word_translation_+', to='dictionary.Word')),
],
options={
'ordering': ('word',),
},
),
migrations.CreateModel(
name='Wordclass',
fields=[
('code', models.CharField(max_length=4, primary_key=True, serialize=False)),
('name', models.CharField(max_length=64)),
],
options={
'ordering': ('code',),
},
),
migrations.AddField(
model_name='word',
name='wordclass',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='dictionary.Wordclass'),
),
]
......@@ -4,7 +4,7 @@ bilingual dictionary capable of translating back and forth between natlangs
and the conlangs of https://langue.phundrak.fr
"""
from django.db import models
from django.utils import slugify
from django.utils.text import slugify
class Language(models.Model):
......@@ -56,16 +56,15 @@ class Word(models.Model):
its \"etymology\" (no more than 5000 chars) and a list of words that can be
its etymological \"roots\"
"""
word = models.CharField(max_length=124)
slug = models.CharField(max_length=124)
word = models.CharField(max_length=128)
slug = models.CharField(max_length=128)
language = models.ForeignKey(Language, on_delete=models.CASCADE)
translation = models.ManyToManyField("self", blank=True)
gender = models.ForeignKey(Gender, on_delete=models.SET_NULL)
wordclass = models.ForeignKey(Wordclass, on_delete=models.SET_NULL)
translation = models.ManyToManyField("self")
gender = models.ForeignKey(Gender, on_delete=models.SET_NULL, null=True)
wordclass = models.ForeignKey(Wordclass, on_delete=models.SET_NULL, null=True)
details = models.CharField(max_length=8192, blank=True)
etymology = models.CharField(max_length=8192, blank=True)
roots = models.ManyToManyField(
"self", on_delete=models.SET_NULL, blank=True)
roots = models.ManyToManyField("self")
def __str__(self):
return self.word
......
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'dictionary/style.css' %}" type="text/css" media="screen" />
{% block addhead %}{% endblock %}
</head>
<body>
{% if error_message %}
<p><strong>{{ error_message }}</strong></p>
{% endif %}
{% block body %}
{% endblock %}
</body>
</html>
{% extends 'dictionary/base.html' %}
{% load staticfiles %}
<!--
`word` is the main word of the page, Word
`translations` are all the words that translate `word` to other languages, Word[]
`from_lang` is the original language, Language
`to_lang` is the target language, Language
-->
{% block title %}{{ word.word }} - {{ from_lang.name }}{% endblock %}
{% block addhead %}
<link rel="stylesheet" href="{% static 'dictionary/details.css' %}" type="text/css" media="screen" />
{% endblock %}
{% block body %}
<word>{{ word.word }}</word>
<fromlang>Language: {{ from_lang.name }}</fromlang>
<gender>Gender: {{ word.gender }}</gender>
<wordclass>Word class:{{ word.class }} ({{ word.class.code }})</wordclass>
{% if translations %}
<listtrans>
<p>Translations of {{ word.word }} in {{ to_lang.name }}:</p>
<ul>
{% for translation in translations %}
<li>{{ translation.word }}</li>
<!--TODO: link to the word's page-->
{% endfor %}
</ul>
</listtrans>
{% endif %}
<transdetails>{{ word.details }}</transdetails>
{% if word.etymology %}
<etymology>
{% if word.roots.all %}
<roots>
<p>Etymological roots:</p>
<ul>
{% for root in word.roots.all %}
<li>{{ root.word }}</li>
<!--TODO: Link to the word's page-->
{% endfor %}
</ul>
</roots>
{% endif %}
</etymology>
{% endif %}
{% endblock %}
from django.urls import path
from django.conf.urls import url
from . import views
app_name = 'dictionary'
urlpatterns = [
# choix du langage traduit et du langage de traduction
# /dictionary/
url(r'^$', views.index, name='index'),
# renvoie la liste des lettres initiales des mots de `from_lang` enregistrés
# et prépare le renvoi vers la liste des mots commençant par cette initiale
# traduits vers `to_lang`
# /dictionary/from=<from_lang>/to=<to_lang>/
# /dictionary/from=HJLP/to=FRA/
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/$',
views.indexlang,
name='listinitials'),
# renvoie la liste des mots de `from_lang` et leur traduction abrégée en
# `to_lang` commençant par la lettre `initial`
# /dictionary/from=<from_lang>/to=<to_lang>/init=<initial>
# /dictionary/from=HJLP/to=FRA/a
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/init=(?P<initial>\S)/$',
views.listwords,
name='listwords'),
# renvoie le détail de la traduction de `word` en `from_lang` vers
# `to_lang`
# /dictionary/from=<from_lang>/to=<to_lang>/word=<word>/
# /dictionary/from=HJLP/to=FRA/hj-lp/
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/(?P<word>[^\/]+)/$',
views.details,
name='details'),
# renvoie cinq mots de `from_lang` commençant par `word`
# /dictionary/from=<from_lang>/guess/<word>/
# /dictionary/from=HJLP/guess/hj/
url(r'^from=(?P<from_lang>[:alpha:]+)/guess/(?P<word>[^\/]+)/$',
views.guessword,
name='guessword'),
]
from django.shortcuts import render
from django.utils.text import slugify
from .models import Language, Gender, Wordclass, Word
def index(request):
pass
def indexlang(request, from_lang, to_lang):
pass
def listwords(request, 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))
def details(request, from_lang, to_lang, word):
word = Word.objects.filter(language=from_lang).get(slug=slugify(word))
translations = word.translations.filter(language=to_lang)
def guessword(request, from_lang, word):
words = Word.object.filter(language=from_lang).filter(
slug__stratswith(slugify(word)))[:5]
......@@ -3,7 +3,7 @@ import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'languephundrakfr.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conlangdict.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
......
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