Introduced text2pensum.py, html templates for pensa, .env to initialize environmental variables while using pipenv and many more
This commit is contained in:
parent
8318b82952
commit
3c9a67d41b
4
.env
Normal file
4
.env
Normal file
@ -0,0 +1,4 @@
|
||||
FLASK_APP=main.py
|
||||
FLASK_ENV=development
|
||||
FLASK_RUN_PORT=8080
|
||||
FLASK_RUN_HOST=0.0.0.0
|
20
README.md
20
README.md
@ -1,6 +1,24 @@
|
||||
# About
|
||||
|
||||
As I've started learning Latin from Lingua Latina Per Se Illustrata I've encourtered the urge for Duolingo-like interface allowing me to :
|
||||
1. check given words in the wiktionairy, so I could see IPA, meaning, declinations etc. next to the text,
|
||||
2. perform the Pensa so that I could see the mistakes I've made.
|
||||
|
||||
# Parsers
|
||||
## Text to Pensum
|
||||
|
||||
```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 (```<input type="text" data-expected="us" required>```).
|
||||
|
||||
# TODO
|
||||
- [ ] text to html parser to swiftly migrate the cloze Pensa
|
||||
- [ ] dictionairy interface
|
||||
- [ ]
|
||||
|
||||
# Development
|
||||
|
||||
To run the app:
|
||||
To run the app on your own machine:
|
||||
1. ```pipenv shell```
|
||||
2. ```export FLASK_APP=main.py```
|
||||
3. ```export FLASK_ENV=development```
|
||||
|
@ -1,5 +1,6 @@
|
||||
from app import app
|
||||
from flask import render_template
|
||||
import os
|
||||
|
||||
@app.route('/')
|
||||
@app.route('/index')
|
||||
@ -12,7 +13,13 @@ def latin():
|
||||
|
||||
@app.route('/latin/llpsi')
|
||||
def llpsi():
|
||||
return render_template('LLPSI/01_Imperium_Romanum/Pensum_A.html')
|
||||
return render_template('LLPSI/LLPSI.html')
|
||||
|
||||
@app.route('/latin/llpsi/<path:pensum_id>')
|
||||
def pensum(pensum_id):
|
||||
filename = 'templates/Pensa/' + pensum_id + '.html'
|
||||
with open(filename, 'r') as file:
|
||||
return render_template('LLPSI/Pensum_cloze.html', pensum_content=file.read())
|
||||
|
||||
@app.route('/latin/coniugationes')
|
||||
def coniugationes():
|
||||
|
11
app/templates/LLPSI/LLPSI.html
Normal file
11
app/templates/LLPSI/LLPSI.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="la">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Lingua Latina Per Se Illustrata</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Lingua Latina Per Se Illustrata</h1><br>
|
||||
<a href="/latin/llpsi/01_Imperium_Romanum_Pensum_A">Pensum A</a>
|
||||
</body>
|
||||
</html>
|
@ -25,7 +25,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<form class="Pensum_A" onsubmit="return validate();">
|
||||
Nilus fluvi<input type="text" id=1 data-expected="us" size=2 required> est.<br>
|
||||
{{pensum_content|safe}}
|
||||
<br>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</body>
|
1
app/templates/Pensa/01_Imperium_Romanum_Pensum_A
Normal file
1
app/templates/Pensa/01_Imperium_Romanum_Pensum_A
Normal file
@ -0,0 +1 @@
|
||||
Ni-ilus fluvi_us_ est. Ni-ilus et Rhe-enus fluvi_i-i_ _sunt_, Cre-eta i-insul_a_ _est_. Cre-eta et Rhodus i-insul_ae_ sunt. Brundisium oppid_um_ _est_. Brundisium et Tu-usculum oppid_a_ sunt.
|
1
app/templates/Pensa/01_Imperium_Romanum_Pensum_A.html
Normal file
1
app/templates/Pensa/01_Imperium_Romanum_Pensum_A.html
Normal file
@ -0,0 +1 @@
|
||||
Nīlus fluvi<input type="text" size="1" data-expected="us" required/> est. Nīlus et Rhēnus fluvi<input type="text" size="1" data-expected="ī" required/> <input type="text" size="1" data-expected="sunt" required/>, Crēta īnsul<input type="text" size="1" data-expected="a" required/> <input type="text" size="1" data-expected="est" required/>. Crēta et Rhodus īnsul<input type="text" size="1" data-expected="ae" required/> sunt. Brundisium oppid<input type="text" size="1" data-expected="um" required/> <input type="text" size="1" data-expected="est" required/>. Brundisium et Tūsculum oppid<input type="text" size="1" data-expected="a" required/> sunt.
|
25
text2pensum.py
Executable file
25
text2pensum.py
Executable file
@ -0,0 +1,25 @@
|
||||
import sys
|
||||
import re
|
||||
|
||||
with open(sys.argv[1], 'r') as infile:
|
||||
content = infile.read()
|
||||
|
||||
# Replace _string_ with html
|
||||
html_head = '<input type="text" size="1" data-expected="'
|
||||
html_tail = '" required/>'
|
||||
content = re.sub(r'_([a-zA-Z\-]+)_', html_head+r'\1'+html_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(sys.argv[1] + '.html', 'w+') as outfile:
|
||||
outfile.write(content)
|
Loading…
Reference in New Issue
Block a user