diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100755 index 0000000..55f96d6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.formatting.provider": "none" +} \ No newline at end of file diff --git a/DOCKERFILE b/DOCKERFILE new file mode 100755 index 0000000..a27e2d6 --- /dev/null +++ b/DOCKERFILE @@ -0,0 +1,17 @@ +FROM python:3.11.3-alpine +WORKDIR /code + +RUN apk --update --upgrade add --no-cache gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev + +RUN python -m pip install --upgrade pip +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + + +#set Enviroment Variables used in FLASK +ENV FLASK_APP=app +ENV FLASK_RUN_HOST=0.0.0.0 +ENV FLASK_RUN_PORT=8080 +EXPOSE 8080 + +CMD [ "flask", "run" ] diff --git a/app.py b/app.py new file mode 100755 index 0000000..f22bc31 --- /dev/null +++ b/app.py @@ -0,0 +1,36 @@ +from flask import Flask, render_template, request, redirect, url_for, make_response +from os import makedirs, path +import functions + +app = Flask(__name__) + + +@app.route("/") +def index(): + return render_template("index.html") + + +@app.route("/upload", methods=["POST"]) +def upload_file(): + uploaded_file = request.files["file"] + text = request.form["text"] + makedirs("uploads", exist_ok=True) + + if uploaded_file.filename != "": + filepath = path.join("uploads", uploaded_file.filename) + uploaded_file.save(filepath) + response_text = functions.convert(filepath) + # response = make_response(response_text, 200) + # response.mimetype = "text/plain" + else: + response_text = functions.convert_text(text) + # response = make_response(response_text, 200) + # response.mimetype = "text/plain" + # return response #redirect(url_for('index')) + return render_template("index.html", text=response_text) + + +if __name__ == "__main__": + app.jinja_env.auto_reload = True + app.config["TEMPLATES_AUTO_RELOAD"] = True + app.run(host="0.0.0.0", port=8000) diff --git a/dockerfile.tar.gz b/dockerfile.tar.gz new file mode 100755 index 0000000..7d13010 Binary files /dev/null and b/dockerfile.tar.gz differ diff --git a/functions.py b/functions.py new file mode 100755 index 0000000..79760b3 --- /dev/null +++ b/functions.py @@ -0,0 +1,78 @@ +import pdfplumber +import re + +import codecs + + +def convert(file_path=False): + if not file_path: + import tkinter as tk + from tkinter import filedialog + + root = tk.Tk() + root.withdraw() + file_path = filedialog.askopenfilename( + filetypes=[("PDFs", ".pdf")], title="Datei zum konvertieren auswählen!" + ) + + conv_string = [] + + # open PDF + with pdfplumber.open(file_path) as pdf: + for page in pdf.pages: + crop = page.crop((60, 80, page.width, page.height)) + # first_page = pdf.pages[0] + # first_page = first_page.crop((60, 80, first_page.width, first_page.height)) + text = crop.extract_text(layout=True) + no_trail = re.sub("\ +\\n", "\n", text) # cleared trailing spaces + no_wrong_nl = re.sub( + "\\n\ +([A-Za-z0-9])", r" \1", no_trail + ) # clear wrong newlins + lines = re.split("\n", no_wrong_nl) # split into lines + + test = 1 + changed_lines = [] + for line in lines: + line, num = re.subn("(:)(.+)", rf"\1 {{{{c{test}::\2}}}}", line) + if num > 0: + test += 1 + changed_lines.append(line) + new_str = "\n".join(changed_lines).strip() + conv_string.append(new_str) + + conv_string = "#################### neue Seite ####################\n".join( + conv_string + ) + + file_path = file_path.replace(".pdf", ".txt") + text_file = codecs.open(file_path, "w", "utf-8") + text_file.write(conv_string) + text_file.close() + + print(f"Alles fertig, die Datei befindet sich unter {file_path}") + if not __name__ == "__main__": + return conv_string + + +def convert_text(text): + text = str(text) + if "\r\n" in text: + text = text.replace("\r\n", "\n") + + no_wrong_nl = re.sub("\\n\ +([A-Za-z0-9])", r" \1", text) # clear wrong newlins + lines = re.split("\n", no_wrong_nl) # split into lines + + test = 1 + changed_lines = [] + for line in lines: + line, num = re.subn("(:)(.+)", rf"\1 {{{{c{test}::\2}}}}", line) + if num > 0: + test += 1 + changed_lines.append(line) + new_str = "\n".join(changed_lines).strip() + if not __name__ == "__main__": + return new_str + + +if __name__ == "__main__": + convert() diff --git a/pdfs/Vestibularreflexe, Nystagmus.pdf b/pdfs/Vestibularreflexe, Nystagmus.pdf new file mode 100755 index 0000000..45ad332 Binary files /dev/null and b/pdfs/Vestibularreflexe, Nystagmus.pdf differ diff --git a/pdfs/Vestibularreflexe, Nystagmus.txt b/pdfs/Vestibularreflexe, Nystagmus.txt new file mode 100755 index 0000000..8ef2f82 --- /dev/null +++ b/pdfs/Vestibularreflexe, Nystagmus.txt @@ -0,0 +1,37 @@ +Vestibulospinale Reflexe +• Aufteilung: + ◦statische Reflexe + ‣ Def: {{c1:: durch bestimmte Körperhaltung ausgelöst, für Aufrechterhaltung des Gleichgewichts in Stand und Gang, Unterteilt in Steh- und Stellreflexe}} + ◦statokinetische Reflexe + ‣ Def: {{c2:: ausgelöst durch Bewegeung, Für Gleichgewicht beim Laufen, Springen}} +Vestibulookulärer Reflex -> siehe Hirnstammreflexe +• Def: {{c3:: Augenbewegung gegen Kopfbewegung zur Fixierung des Gegenstands bej Kopfbewegung}} +• Funktion: {{c4:: Blickstabilisierung, Fixierung Bild auf Netzhaut}} + + +Nystagmus: +• pathologische Arten: {{c5:: Spontannystagmus}} + ◦Unterteilung + ‣ Ausfallnystagmus + • Def: {{c6:: Zerstören der Vestibularbahn}} + • Richtung: {{c7:: von kranker Seite weg}} + ‣ Reiznystagmus + • Def: {{c8:: Reizung des Vestibularapparats}} + • Richtung: {{c9:: zu kranker Seite hin}} +• physiologische Arten + ◦vestibulärer Nystagmus + ‣ rotatorischef Nystagmus + • Ursache: {{c10:: Fixierung eines Punkts bei Rotation des Probanden}} + • Richtung: {{c11:: in Rotationsrichtung}} + ‣ postrotatorischer Nystagmus + • Ursache: {{c12:: Stopp einer Rotation}} + • Richtung: {{c13:: gegen Rotation}} + ‣ kalorischer Nystagmus + • Auslösung: {{c14:: Spülung des Gehörgangs mit kaltem oder warmem Wasser}} + • Vorgang: {{c15:: Reizung Bogengang durch Spülung, Bewgeung Endolymphe durch Temperatur}} + • Richtung: {{c16:: Warmspülung zeigt der Nystagmus zum gespülten Ohr hin, bei Kaltspülung vom gespülten Ohr weg}} + ◦optokinetischer Nystagmus = Eisenbahnnystagmus + ‣ Vorgang: + • Augen fixieren Punkt, versuchen diesen so lange wie möglich im Blickfeld zu behalten -> Augenauslenkbewegung + • Rückstellbewegung falls Bulbus maximal ausgelenkt + ‣ Richtung: {{c17:: gegen Bewegung der Umwelt}} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100755 index 0000000..5aefcd6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +pdfplumber diff --git a/static/script.js b/static/script.js new file mode 100755 index 0000000..10f397b --- /dev/null +++ b/static/script.js @@ -0,0 +1,24 @@ +document.getElementById("myfile").addEventListener("change", (event) => { + btn = event.target; + filename = btn.files[0].name; + btn.parentNode.children[1].innerHTML = filename +}) +try { + document.getElementById("copy-btn").addEventListener("click", copy_text); +} catch (e) { + if (e instanceof TypeError) + e = 0; + else alert(e); +} + +function copy_text(){ + const copyText = document.getElementById("myInput").textContent.trim(); + const textArea = document.createElement('textarea'); + textArea.textContent = copyText; + document.body.append(textArea); + textArea.select(); + document.execCommand("copy"); + textArea.style.display = "none"; + + // console.log("Hello World!"); +} diff --git a/static/style.css b/static/style.css new file mode 100755 index 0000000..3722962 --- /dev/null +++ b/static/style.css @@ -0,0 +1,42 @@ +*{ + font-family: sans-serif; +} + +main{ + display: flex; + width: 90vw; + height: 50vh; + margin: 0 5vw; + gap: 2rem; +} + + +main div{ + width: 50%; +} + +textarea{ + width: 90%; + height: 20vh; + margin: 20px 0; + min-height: fit-content; +} + +/* button{ + border: 1px solid black; + padding: 5px; + border-radius: 2.5px; +} */ + +input[type="file"] { + display: none; +} +.custom-file-upload, button { + border: 1px solid #313131; + background-color: lightgray; + display: inline-block; + padding: 6px 12px; + cursor: pointer; + font-size: 1rem; + border-radius: .2rem; +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100755 index 0000000..fb7eaa9 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,32 @@ + + + + Upload Text + + + +
+
+

File Upload Example

+
+ + +
+ +
+
+ {% if text %} + + {% endif %} +
+ + + diff --git a/uploads/Kanu-B-22.pdf b/uploads/Kanu-B-22.pdf new file mode 100755 index 0000000..4cf1265 Binary files /dev/null and b/uploads/Kanu-B-22.pdf differ diff --git a/uploads/Programmentwurf_Vorlage_Bescheibung_3IT22-1.pdf b/uploads/Programmentwurf_Vorlage_Bescheibung_3IT22-1.pdf new file mode 100755 index 0000000..03cc16c Binary files /dev/null and b/uploads/Programmentwurf_Vorlage_Bescheibung_3IT22-1.pdf differ diff --git a/uploads/Programmentwurf_Vorlage_Bescheibung_3IT22-1.txt b/uploads/Programmentwurf_Vorlage_Bescheibung_3IT22-1.txt new file mode 100755 index 0000000..51062c9 --- /dev/null +++ b/uploads/Programmentwurf_Vorlage_Bescheibung_3IT22-1.txt @@ -0,0 +1,49 @@ +Aufgabenvorschlag OOP + Namen und Seminargruppe(n) der Studierenden: + + + + + + + Projekttitel + + Beschreibung des Programmvorschlags (inkl. Programmiersprache) + + + + + + + + Skizzen + + (als Bild einfügen und separat per E-Mail einreichen) + + + + + + + + + + Mindestumfang + + + + + + + + Mögliche Erweiterungen + + + + + + + + + __________________________ __________ __________ __________ Ort, Datum Unterschriften + _________ _________ \ No newline at end of file diff --git a/uploads/Vestibularreflexe, Nystagmus.pdf b/uploads/Vestibularreflexe, Nystagmus.pdf new file mode 100755 index 0000000..45ad332 Binary files /dev/null and b/uploads/Vestibularreflexe, Nystagmus.pdf differ diff --git a/uploads/Vestibularreflexe, Nystagmus.txt b/uploads/Vestibularreflexe, Nystagmus.txt new file mode 100755 index 0000000..8ef2f82 --- /dev/null +++ b/uploads/Vestibularreflexe, Nystagmus.txt @@ -0,0 +1,37 @@ +Vestibulospinale Reflexe +• Aufteilung: + ◦statische Reflexe + ‣ Def: {{c1:: durch bestimmte Körperhaltung ausgelöst, für Aufrechterhaltung des Gleichgewichts in Stand und Gang, Unterteilt in Steh- und Stellreflexe}} + ◦statokinetische Reflexe + ‣ Def: {{c2:: ausgelöst durch Bewegeung, Für Gleichgewicht beim Laufen, Springen}} +Vestibulookulärer Reflex -> siehe Hirnstammreflexe +• Def: {{c3:: Augenbewegung gegen Kopfbewegung zur Fixierung des Gegenstands bej Kopfbewegung}} +• Funktion: {{c4:: Blickstabilisierung, Fixierung Bild auf Netzhaut}} + + +Nystagmus: +• pathologische Arten: {{c5:: Spontannystagmus}} + ◦Unterteilung + ‣ Ausfallnystagmus + • Def: {{c6:: Zerstören der Vestibularbahn}} + • Richtung: {{c7:: von kranker Seite weg}} + ‣ Reiznystagmus + • Def: {{c8:: Reizung des Vestibularapparats}} + • Richtung: {{c9:: zu kranker Seite hin}} +• physiologische Arten + ◦vestibulärer Nystagmus + ‣ rotatorischef Nystagmus + • Ursache: {{c10:: Fixierung eines Punkts bei Rotation des Probanden}} + • Richtung: {{c11:: in Rotationsrichtung}} + ‣ postrotatorischer Nystagmus + • Ursache: {{c12:: Stopp einer Rotation}} + • Richtung: {{c13:: gegen Rotation}} + ‣ kalorischer Nystagmus + • Auslösung: {{c14:: Spülung des Gehörgangs mit kaltem oder warmem Wasser}} + • Vorgang: {{c15:: Reizung Bogengang durch Spülung, Bewgeung Endolymphe durch Temperatur}} + • Richtung: {{c16:: Warmspülung zeigt der Nystagmus zum gespülten Ohr hin, bei Kaltspülung vom gespülten Ohr weg}} + ◦optokinetischer Nystagmus = Eisenbahnnystagmus + ‣ Vorgang: + • Augen fixieren Punkt, versuchen diesen so lange wie möglich im Blickfeld zu behalten -> Augenauslenkbewegung + • Rückstellbewegung falls Bulbus maximal ausgelenkt + ‣ Richtung: {{c17:: gegen Bewegung der Umwelt}} \ No newline at end of file