diff --git a/pyproject.toml b/pyproject.toml index 8fe5294..4e29119 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ exclude = ''' ''' [tool.isort] -src_paths = ["gtomachine", "test"] +src_paths = ["src", "test"] skip_glob = [".git", "__pycache__", ".vscode", "*venv", "build", "dist", "old", "*.egg-info"] line_length = 88 multi_line_output = 3 @@ -107,12 +107,11 @@ case_sensitive = true length_sort = false balanced_wrapping = true atomic = true -known_gto = ["gtomachine", "gtodata", "gtotools"] import_heading_stdlib = "Standard Library" import_heading_thirdparty = "Pip" -import_heading_gto = "GTO" +import_heading_firstparty = "First Party" import_heading_localfolder = "Local" -sections = ["FUTURE", "STDLIB", "THIRDPARTY", "GTO", "FIRSTPARTY", "LOCALFOLDER"] +sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] [tool.pylint.messages_control] disable = "C0330, C0326" diff --git a/src/anki_creator_flask/__init__.py b/src/anki_creator_flask/__init__.py index 18f955f..7e8ed97 100644 --- a/src/anki_creator_flask/__init__.py +++ b/src/anki_creator_flask/__init__.py @@ -4,17 +4,19 @@ from pathlib import Path # Pip from flask import Flask +# Local from .homescreen import homescreen +from .mainapp import mainapp def create_app(test_config=None): # create and configure the app app = Flask(__name__, instance_relative_config=True) - + # ensure the instance folder exists instance_path = Path(app.instance_path) instance_path.mkdir(parents=True, exist_ok=True) - + # configs app.config.from_mapping( SECRET_KEY="dev", @@ -28,7 +30,7 @@ def create_app(test_config=None): # load the test config if passed in app.config.from_mapping(test_config) - for blueprint in (homescreen,): + for blueprint in (homescreen, mainapp): app.register_blueprint(blueprint) return app diff --git a/src/anki_creator_flask/homescreen.py b/src/anki_creator_flask/homescreen.py index 1f74986..2ba4d8a 100644 --- a/src/anki_creator_flask/homescreen.py +++ b/src/anki_creator_flask/homescreen.py @@ -1,14 +1,16 @@ # Pip -from flask import Blueprint, abort, render_template -from jinja2 import TemplateNotFound +from flask import Blueprint, current_app, render_template, send_from_directory homescreen = Blueprint("homescreen", __name__, template_folder="templates") -@homescreen.route("/", defaults={"page": "index"}) -@homescreen.route("/") -def show(page): - try: - return render_template(f"{page}.html") - except TemplateNotFound: - abort(404) +@homescreen.route("/") +def show(): + return render_template(f"index.html") + + +@homescreen.route("/favicon.ico") +def favicon(): + return send_from_directory( + current_app.static_folder, "favicon.ico", mimetype="image/vnd.microsoft.icon" + ) diff --git a/src/anki_creator_flask/mainapp.py b/src/anki_creator_flask/mainapp.py new file mode 100644 index 0000000..b6878a8 --- /dev/null +++ b/src/anki_creator_flask/mainapp.py @@ -0,0 +1,25 @@ +# Pip +from flask import Blueprint, render_template, request + +mainapp = Blueprint("mainapp", __name__, template_folder="templates", url_prefix="/app", static_folder="static") + + +@mainapp.route("/", methods=["GET", "POST"]) +def show(): + if request.method == "GET": + args = request.args.to_dict() + deck_type = args.get("deck_type", "") + language = args.get("language", "") + output_type = args.get("output_type", "") + if not deck_type or not language or not output_type: + state = "new" + else: + print() + print(deck_type, language, output_type) + print() + state = "complete" + elif request.method == "POST": + state = "ready" + form = request.form.to_dict() + + return render_template(f"app.html", data=locals()) diff --git a/src/anki_creator_flask/static/assets/js/app.js b/src/anki_creator_flask/static/assets/js/app.js new file mode 100644 index 0000000..e69de29 diff --git a/src/anki_creator_flask/static/favicon.ico b/src/anki_creator_flask/static/favicon.ico new file mode 100644 index 0000000..52a3452 Binary files /dev/null and b/src/anki_creator_flask/static/favicon.ico differ diff --git a/src/anki_creator_flask/static/favicon.ico.old b/src/anki_creator_flask/static/favicon.ico.old new file mode 100644 index 0000000..fae865b Binary files /dev/null and b/src/anki_creator_flask/static/favicon.ico.old differ diff --git a/src/anki_creator_flask/templates/app.html b/src/anki_creator_flask/templates/app.html index 00c5be1..f449c87 100644 --- a/src/anki_creator_flask/templates/app.html +++ b/src/anki_creator_flask/templates/app.html @@ -11,105 +11,120 @@ +
-
+
-

Get in touch

+

Select the deck type

-
+ +

- Auctor commodo interdum et malesuada fames ac ante - ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet - dolor mattis sagittis. + Paste here the word list

-
+
-
- -
-
- -
- +
+
@@ -127,5 +142,57 @@ + + diff --git a/src/anki_creator_flask/templates/index.html b/src/anki_creator_flask/templates/index.html index 74f13c4..db4e05f 100644 --- a/src/anki_creator_flask/templates/index.html +++ b/src/anki_creator_flask/templates/index.html @@ -11,6 +11,10 @@ +