diff --git a/app/main.py b/app/main.py index be59a31..d099b92 100644 --- a/app/main.py +++ b/app/main.py @@ -1,23 +1 @@ from app import app - -# from flask import render_template -# from flask_sqlalchemy import SQLAlchemy -# from sqlalchemy import func -# from flask_wtf import FlaskForm -# from wtforms import Form, RadioField, SubmitField, HiddenField - -# db = SQLAlchemy(app) - -# class Word(db.Model): -# id = db.Column(db.Integer, primary_key=True) -# dictionarium = db.Column(db.String, unique=True, nullable=False) -# coniugatio = db.Column(db.Integer, unique=False, nullable=False) - -# def __repr__(self): -# return '%r; %d conjugation' % (self.dictionarium, self.coniugatio) - -# class ConjugatioAnswer(FlaskForm): -# radio = RadioField('', choices=[(1, 'Prima'), (2, 'Secunda'), (3, 'Tertia'), (4, 'Quarta')]) -# word = HiddenField() -# submit = SubmitField('Check') -# next_word = SubmitField('Next word') \ No newline at end of file diff --git a/app/routes.py b/app/routes.py index e386f02..406cf08 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,39 +1,33 @@ from app import app -from flask import render_template +from flask import render_template, jsonify import os +capitula = [ + {'title': '01 Imperium Romanum'}, + {'title': '02 Familia Romana'}, + {'title': '03 Puer Improbus'}, + {'title': '04 Dominus et Servi'}, + {'title': '05 Villa et Hortus'}, + {'title': '06 Via Latina'}, + {'title': '07 Puella et Rosa'}, + {'title': '08 Taberna Romana'}, + {'title': '09 Pastor et Oves'}, + {'title': '10 Bestiae et Homines'} +] + +for capitulum in capitula: + capitulum['filename'] = capitulum['title'].replace(' ', '_') + +print(capitula) + @app.route('/') @app.route('/index') -def index(): - return "Hello, World!" - -@app.route('/latin') -def latin(): - return render_template('latin.html') - -@app.route('/latin/llpsi') +@app.route('/llpsi') def llpsi(): - return render_template('LLPSI/LLPSI.html') + return render_template('index.html', capitula=capitula) -@app.route('/latin/llpsi/') +@app.route('/llpsi/') def pensum(pensum_id): filename = 'templates/Pensa/' + pensum_id + '.html' with open(filename, 'r') as file: - return render_template('LLPSI/Pensum_cloze.html', pensum_title=pensum_id.replace('_', ' '), pensum_content=file.read()) - -@app.route('/latin/coniugationes') -def coniugationes(): - return render_template('coniugationes.html') - -@app.route('/latin/coniugationes/quod', methods=["GET", "POST"]) -def coniugationes_test(): - form = ConjugatioAnswer() - if form.validate_on_submit(): - word = Word.query.filter_by(dictionarium=form.word.data).first() - if not form.next_word.data: - if int(form.radio.data) == word.coniugatio: - return render_template('coniugationes.html', dictionarium = word.dictionarium, form = form, success = True) - return render_template('coniugationes.html', dictionarium = word.dictionarium, form = form, fail = True) - word = Word.query.order_by(func.random()).first() - form.word.data = word.dictionarium - return render_template('coniugationes.html', dictionarium = word.dictionarium, form = form) + return render_template('Pensum_cloze.html', pensum_title=pensum_id.replace('_', ' '), pensum_content=file.read()) diff --git a/app/templates/LLPSI/LLPSI.html b/app/templates/LLPSI/LLPSI.html deleted file mode 100644 index abb6cda..0000000 --- a/app/templates/LLPSI/LLPSI.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - Lingua Latina Per Se Illustrata - - - -

Lingua Latina Per Se Illustrata

- - - \ No newline at end of file diff --git a/app/templates/LLPSI/Pensum_cloze.html b/app/templates/Pensum_cloze.html similarity index 97% rename from app/templates/LLPSI/Pensum_cloze.html rename to app/templates/Pensum_cloze.html index 1cab665..f41ef05 100644 --- a/app/templates/LLPSI/Pensum_cloze.html +++ b/app/templates/Pensum_cloze.html @@ -61,7 +61,6 @@ Array.from(form.elements).forEach((input) => { if (input.type=="text" && document.getElementById('vowel_length').checked == false) { is_macron_ok = (input.value == input_to_nomacron(input.dataset.expected)); - console.log(input_to_nomacron(input.dataset.expected)); is_double_ok = false; } else { is_double_ok = (input_to_macron(input.value) == input.dataset.expected); diff --git a/app/templates/coniugationes.html b/app/templates/coniugationes.html deleted file mode 100644 index b0192f5..0000000 --- a/app/templates/coniugationes.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Lingua Latina – Quattuor coniugationes verborum - - -

Quod coniugatio?

-
-

{{dictionarium}}

- - - {{form.word}} - {{form.csrf_token}} - {% for subfield in form.radio %} - - {{ subfield }} - {{ subfield.label }} - - {% endfor %} - {{form.submit}} - - {%if success %} -
Correct!
- {{form.next_word}} - {%endif%} - {% if fail %} -
Wrong!
- {% endif %} - - - \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..ee7ce22 --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,21 @@ + + + + + Lingua Latina Per Se Illustrata + + + +

Lingua Latina Per Se Illustrata

+
    + {% for capitulum in capitula %} +
  • {{capitulum.title}} + +
  • + {% endfor %} +
+ + \ No newline at end of file diff --git a/app/templates/latin.html b/app/templates/latin.html deleted file mode 100644 index 2a64b3f..0000000 --- a/app/templates/latin.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Lingua Latina - - - Lingua Latina Per Se Illustrata
- Coniugationes - - \ No newline at end of file