From 6c0adcb74586d3448bab787895a6860b77993dd6 Mon Sep 17 00:00:00 2001 From: sergiusz Date: Thu, 7 Jan 2021 17:19:52 +0100 Subject: [PATCH] Introduced Exercitia --- app/routes.py | 12 +- .../01_Imperium_Romanum_Exercitium_1 | 5 + app/templates/Exercitium_choice.html | 109 ++++++++++++++++++ app/templates/index.html | 7 +- text2exercitium.py | 31 +++++ 5 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1 create mode 100644 app/templates/Exercitium_choice.html create mode 100644 text2exercitium.py diff --git a/app/routes.py b/app/routes.py index 49799b8..e5aa711 100644 --- a/app/routes.py +++ b/app/routes.py @@ -3,7 +3,9 @@ from flask import render_template, jsonify import os capitula = [ - {'title': '01 Imperium Romanum'}, + {'title': '01 Imperium Romanum', + 'pensa': ['A', 'B'], + 'exercitia': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]}, {'title': '02 Familia Romana'}, {'title': '03 Puer Improbus'}, {'title': '04 Dominus et Servi'}, @@ -24,8 +26,14 @@ for capitulum in capitula: def llpsi(): return render_template('index.html', capitula=capitula) -@app.route('/llpsi/') +@app.route('/llpsi/pensum/') def pensum(pensum_id): filename = app.root_path + '/templates/Pensa/' + pensum_id + '.html' with open(filename, 'r') as file: return render_template('Pensum_cloze.html', pensum_title=pensum_id.replace('_', ' '), pensum_content=file.read()) + +@app.route('/llpsi/pensum/') +def exercitium(exercitium_id): + filename = app.root_path + '/templates/Exercitia/' + exercitium_id + '.html' + with open(filename, 'r') as file: + return render_template('Exercitium_choice.html', exercitium_title=exercitium_id.replace('_', ' '), exercitium_content=file.read()) diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1 new file mode 100644 index 0000000..b816118 --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1 @@ -0,0 +1,5 @@ +est|sunt +Italia in Eurōpā _est_. +Gallia in Eurōpā _est_. +Italia et Gallia in Eurōpā _sunt_. +Arabia in Eurōpā nōn _est_. diff --git a/app/templates/Exercitium_choice.html b/app/templates/Exercitium_choice.html new file mode 100644 index 0000000..c8f651e --- /dev/null +++ b/app/templates/Exercitium_choice.html @@ -0,0 +1,109 @@ + + + + + {{pensum_title}} + + + + + +
+

Lingua Latīna Per Sē Illūstrāta

+

{{pensum_title}}

+ +
+
+

{{pensum_content|safe}}

+
+ +
+ + + \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index 89eb0b0..95c038f 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -11,8 +11,11 @@
{% for capitulum in capitula %}
{{capitulum.title}} -
Pensum A
-
Pensum B
+
Pensum A
+
Pensum B
+ {% for exercitium in capitulum.exercitia %} +
Exercitium {{exercitium}}
+ {% endfor %} {% endfor %}
diff --git a/text2exercitium.py b/text2exercitium.py new file mode 100644 index 0000000..27037f7 --- /dev/null +++ b/text2exercitium.py @@ -0,0 +1,31 @@ +import sys +import re + +for filename in sys.argv[1:]: + with open(filename, 'r') as infile: + content = infile.readlines() + + + to_use = content.pop(0).split('|') + html_header = 'To use: ' + to_use.str() + '
' + # Replace _string_ with html + html_span_head = '' + html_input_head = '' + html_span_tail = '' + content = re.sub(r'(\s|\"|)([a-zA-Z\-\ÿ]+|)_([āēīōūa-zA-Z\-]+)_(\.|\,|)', r'\1' + html_span_head + r'\2' + html_input_head + r'\3' + html_input_tail + r'\4' + html_span_tail, content) + + # Replace vowel-dash-vowel with vowels with macrons + content = content.replace('A-A', 'Ā') + content = content.replace('a-a', 'ā') + content = content.replace('E-E', 'Ē') + content = content.replace('e-e', 'ē') + content = content.replace('I-I', 'Ī') + content = content.replace('i-i', 'ī') + content = content.replace('O-O', 'Ō') + content = content.replace('o-o', 'ō') + content = content.replace('U-U', 'Ū') + content = content.replace('u-u', 'ū') + + with open(filename + '.html', 'w') as outfile: + outfile.write(content) \ No newline at end of file