diff --git a/README.md b/README.md index 4074b15..12a4d12 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ As I've started learning Latin from Lingua Latina Per Se Illustrata I've encourt ```text2pensum.py``` takes text file as an input and generates HTML form from it. Marking is as follows: - all vowel-dash-vowel combinations (```i-i```) are transformed into a long vowel marked with macron (```ī```) - - underscore-string-underscore combinations (```_us_```) are transformed intorequiered html text input field with string between underscores as a value of ```data-expected``` atribute (``````). + - underscore-string-underscore combinations (```_us_```) are transformed into requiered html text input field with string between underscores as a value of ```data-expected``` atribute (``````). # TODO - [x] text to html parser to swiftly migrate the cloze Pensa @@ -18,4 +18,4 @@ As I've started learning Latin from Lingua Latina Per Se Illustrata I've encourt # Development -To run the app on your own machine run ```pipenv install``` to install requested packages based on the Pipfile and then run ```pipenv shell 'gunicorn --chdir app --bind 0.0.0.0:5000 app:app'```. \ No newline at end of file +To run the app on your own machine run ```pipenv install``` to install requested packages based on the Pipfile and then run ```pipenv shell 'gunicorn --bind 0.0.0.0:5000 app:app'``` or ```flask run```. \ No newline at end of file diff --git a/app/routes.py b/app/routes.py index 3c5866c..eef0cb2 100644 --- a/app/routes.py +++ b/app/routes.py @@ -38,8 +38,8 @@ def pensum(pensum_id): 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/') +@app.route('/llpsi/exercitium/') 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()) + return render_template('Exercitium_cloze.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 index b816118..cbc1ac5 100644 --- a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1 +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1 @@ -3,3 +3,8 @@ Italia in Eurōpā _est_. Gallia in Eurōpā _est_. Italia et Gallia in Eurōpā _sunt_. Arabia in Eurōpā nōn _est_. +Arabia in Asiā _est_. +Syria quoque in Asiā _est_. +Syria et Arabia in Asiā _sunt_. +Histānia in Asiā nōn _est_. +Hispānia et Gallia et Italia in Eurōpā _sunt_. \ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1.html b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1.html new file mode 100644 index 0000000..cb8c08f --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_1.html @@ -0,0 +1,12 @@ +volabula: est, sunt +
    +
  1. Italia in Eurōpā .
  2. +
  3. Gallia in Eurōpā .
  4. +
  5. Italia et Gallia in Eurōpā .
  6. +
  7. Arabia in Eurōpā nōn .
  8. +
  9. Arabia in Asiā .
  10. +
  11. Syria quoque in Asiā .
  12. +
  13. Syria et Arabia in Asiā .
  14. +
  15. Histānia in Asiā nōn .
  16. +
  17. Hispānia et Gallia et Italia in Eurōpā .
  18. +
\ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_10 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_10 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_11 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_11 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_12 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_12 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_13 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_13 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_2 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_2 new file mode 100644 index 0000000..365190d --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_2 @@ -0,0 +1,8 @@ +et|fluvius|in|-ne|nōn|quoque|sed|ubi +Italia _in_ Eurōpā est; Gracia _quoque_ in Eurōpā est. +Italia _et_ Gracia in Eurōpā sunt. +Est_ne_ Arabia in Eurōpā? Arabia in Eurōpā _nōn_ est. +_Ubi_ est Arabia? In Asiā est Arabia. +Arabia nōn est in Eurōpā, _sed_ in Asiā. +Germānia _nōn_ in Asiā, _sed_ in Eurōpā est. +Rhēnus est in Germānia. Rhēnus _fluvius_ est. \ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_2.html b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_2.html new file mode 100644 index 0000000..42234a2 --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_2.html @@ -0,0 +1,10 @@ +volabula: et, fluvius, in, -ne, nōn, quoque, sed, ubi +
    +
  1. Italia Eurōpā est; Gracia in Eurōpā est.
  2. +
  3. Italia Gracia in Eurōpā sunt.
  4. +
  5. Est Arabia in Eurōpā? Arabia in Eurōpā est.
  6. +
  7. est Arabia? In Asiā est Arabia.
  8. +
  9. Arabia nōn est in Eurōpā, in Asiā.
  10. +
  11. Germānia in Asiā, in Eurōpā est.
  12. +
  13. Rhēnus est in Germānia. Rhēnus est.
  14. +
\ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_3 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_3 new file mode 100644 index 0000000..32d9677 --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_3 @@ -0,0 +1,2 @@ +Under +Construction \ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_4 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_4 new file mode 100644 index 0000000..d3184bb --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_4 @@ -0,0 +1,2 @@ +-us|-ī|-a|-ae|-um|-a +Corsica īnsul_a_ est. Corsica et Sardinia īnsul_ae_ sunt. \ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_4.html b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_4.html new file mode 100644 index 0000000..cbcb5be --- /dev/null +++ b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_4.html @@ -0,0 +1,4 @@ +volabula: -us, -ī, -a, -ae, -um, -a +
    +
  1. Corsica īnsul est. Corsica et Sardinia īnsul sunt.
  2. +
\ No newline at end of file diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_5 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_5 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_6 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_6 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_7 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_7 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_8 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_8 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_9 b/app/templates/Exercitia/01_Imperium_Romanum_Exercitium_9 new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/Exercitium_cloze.html b/app/templates/Exercitium_cloze.html new file mode 100644 index 0000000..178435f --- /dev/null +++ b/app/templates/Exercitium_cloze.html @@ -0,0 +1,109 @@ + + + + + {{pensum_title}} + + + + + +
+

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

+

{{exercitium_title}}

+ +
+
+

{{exercitium_content|safe}}

+
+ +
+ + + \ No newline at end of file diff --git a/text2exercitium.py b/text2exercitium.py deleted file mode 100644 index 27037f7..0000000 --- a/text2exercitium.py +++ /dev/null @@ -1,31 +0,0 @@ -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 diff --git a/text2exercitium_cloze.py b/text2exercitium_cloze.py new file mode 100644 index 0000000..57aa201 --- /dev/null +++ b/text2exercitium_cloze.py @@ -0,0 +1,40 @@ +import sys +import re + +for filename in sys.argv[1:]: + with open(filename, 'r') as infile: + content = infile.readlines() + + + to_use = content.pop(0).replace('|',', ') + html_header = 'volabula: ' + ''.join(to_use) + '
' + # Replace _string_ with html + html_span_head = '' + html_input_head = '' + html_span_tail = '' + for i in range(len(content)): + content[i] = 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[i].rstrip('\n')) + # Replace vowel-dash-vowel with vowels with macrons + content[i] = content[i].replace('A-A', 'Ā') + content[i] = content[i].replace('a-a', 'ā') + content[i] = content[i].replace('E-E', 'Ē') + content[i] = content[i].replace('e-e', 'ē') + content[i] = content[i].replace('I-I', 'Ī') + content[i] = content[i].replace('i-i', 'ī') + content[i] = content[i].replace('O-O', 'Ō') + content[i] = content[i].replace('o-o', 'ō') + content[i] = content[i].replace('U-U', 'Ū') + content[i] = content[i].replace('u-u', 'ū') + + html_list_header = '
    \n' + html_list_element_header = '
  1. ' + html_list_element_trailer = '
  2. \n' + html_list_trailer = '
' + + with open(filename + '.html', 'w') as outfile: + outfile.write(html_header) + outfile.write(html_list_header) + for line in content: + outfile.write(html_list_element_header + line.rstrip('\n') + html_list_element_trailer) + outfile.write(html_list_trailer) \ No newline at end of file diff --git a/text2pensum.py b/text2pensum_cloze.py similarity index 100% rename from text2pensum.py rename to text2pensum_cloze.py