add basic functionality

This commit is contained in:
Wolfang Torres
2026-06-06 22:12:47 +08:00
parent 64380d2942
commit 345c1a8065
9 changed files with 189 additions and 90 deletions

View File

@@ -94,7 +94,7 @@ exclude = '''
''' '''
[tool.isort] [tool.isort]
src_paths = ["gtomachine", "test"] src_paths = ["src", "test"]
skip_glob = [".git", "__pycache__", ".vscode", "*venv", "build", "dist", "old", "*.egg-info"] skip_glob = [".git", "__pycache__", ".vscode", "*venv", "build", "dist", "old", "*.egg-info"]
line_length = 88 line_length = 88
multi_line_output = 3 multi_line_output = 3
@@ -107,12 +107,11 @@ case_sensitive = true
length_sort = false length_sort = false
balanced_wrapping = true balanced_wrapping = true
atomic = true atomic = true
known_gto = ["gtomachine", "gtodata", "gtotools"]
import_heading_stdlib = "Standard Library" import_heading_stdlib = "Standard Library"
import_heading_thirdparty = "Pip" import_heading_thirdparty = "Pip"
import_heading_gto = "GTO" import_heading_firstparty = "First Party"
import_heading_localfolder = "Local" import_heading_localfolder = "Local"
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "GTO", "FIRSTPARTY", "LOCALFOLDER"] sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
[tool.pylint.messages_control] [tool.pylint.messages_control]
disable = "C0330, C0326" disable = "C0330, C0326"

View File

@@ -4,7 +4,9 @@ from pathlib import Path
# Pip # Pip
from flask import Flask from flask import Flask
# Local
from .homescreen import homescreen from .homescreen import homescreen
from .mainapp import mainapp
def create_app(test_config=None): def create_app(test_config=None):
@@ -28,7 +30,7 @@ def create_app(test_config=None):
# load the test config if passed in # load the test config if passed in
app.config.from_mapping(test_config) app.config.from_mapping(test_config)
for blueprint in (homescreen,): for blueprint in (homescreen, mainapp):
app.register_blueprint(blueprint) app.register_blueprint(blueprint)
return app return app

View File

@@ -1,14 +1,16 @@
# Pip # Pip
from flask import Blueprint, abort, render_template from flask import Blueprint, current_app, render_template, send_from_directory
from jinja2 import TemplateNotFound
homescreen = Blueprint("homescreen", __name__, template_folder="templates") homescreen = Blueprint("homescreen", __name__, template_folder="templates")
@homescreen.route("/", defaults={"page": "index"}) @homescreen.route("/")
@homescreen.route("/<page>") def show():
def show(page): return render_template(f"index.html")
try:
return render_template(f"{page}.html")
except TemplateNotFound: @homescreen.route("/favicon.ico")
abort(404) def favicon():
return send_from_directory(
current_app.static_folder, "favicon.ico", mimetype="image/vnd.microsoft.icon"
)

View File

@@ -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())

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@@ -11,105 +11,120 @@
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="keywords" content="" /> <meta name="keywords" content="" />
<link rel="stylesheet" href="static/assets/css/main.css" /> <link rel="stylesheet" href="static/assets/css/main.css" />
<link
rel="shortcut icon"
href="{{ url_for('static', filename='favicon.ico') }}"
/>
</head> </head>
<body class="is-preload"> <body class="is-preload">
<!-- Wrapper --> <!-- Wrapper -->
<div id="wrapper"> <div id="wrapper">
<!-- Section --> <!-- Section -->
<section> <section id="first" style="padding-top: 3em">
<header> <header>
<h2>Get in touch</h2> <h2>Select the deck type</h2>
</header> </header>
<div class="content">
<div id="text_area" class="content">
<p> <p>
<strong>Auctor commodo</strong> interdum et malesuada fames ac ante <strong>Paste here the word list</strong>
ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet
dolor mattis sagittis.
</p> </p>
<form> <form id="taxt_form" method="POST">
<div class="fields"> <div class="fields">
<div class="field half">
<input type="text" name="name" id="name" placeholder="Name" />
</div>
<div class="field half">
<input
type="email"
name="email"
id="email"
placeholder="Email"
/>
</div>
<div class="field"> <div class="field">
<textarea <textarea name="text" id="text" rows="15"></textarea>
name="message"
id="message"
placeholder="Message"
rows="7"
></textarea>
</div> </div>
</div> </div>
<ul class="actions"> <ul class="actions">
<li> <li>
<input <input
id="process"
type="submit" type="submit"
value="Send Message" value="Process"
class="button primary" class="button primary"
/> />
</li> </li>
</ul> </ul>
</form> </form>
</div> </div>
<footer> <footer>
<ul class="items"> <form action="/app">
<li> <ul class="items">
<h3>Email</h3> <li>
<a href="#">information@untitled.ext</a> <h3>Deck Type</h3>
</li> <div>
<li> <input
<h3>Phone</h3> type="radio"
<a href="#">(000) 000-0000</a> id="type1"
</li> name="deck_type"
<li> value="dictionary"
<h3>Address</h3> checked
<span>1234 Somewhere Road, Nashville, TN 00000</span> />
</li> <label for="type1">Dictionary Deck</label>
<li> </div>
<h3>Elsewhere</h3> <div>
<ul class="icons"> <input
<li> type="radio"
<a href="#" class="icon brands fa-twitter" id="type2"
><span class="label">Twitter</span></a name="deck_type"
> value="phrases"
</li> />
<li> <label for="type2">Phrases List</label>
<a href="#" class="icon brands fa-facebook-f" </div>
><span class="label">Facebook</span></a <div>
> <input
</li> type="radio"
<li> id="type3"
<a href="#" class="icon brands fa-instagram" name="deck_type"
><span class="label">Instagram</span></a value="paragraph"
> />
</li> <label for="type3">Paragraph Dictation</label>
<li> </div>
<a href="#" class="icon brands fa-linkedin-in" </li>
><span class="label">LinkedIn</span></a <li>
> <h3>Language</h3>
</li> <select id="language" name="language">
<li> <option value="en">English</option>
<a href="#" class="icon brands fa-github" <option value="es">Spanish</option>
><span class="label">GitHub</span></a <option value="ru">Russian</option>
> <option value="fr">French</option>
</li> </select>
<li> </li>
<a href="#" class="icon brands fa-codepen" <li>
><span class="label">Codepen</span></a <h3>Output</h3>
> <div>
</li> <input
</ul> type="radio"
</li> id="out1"
</ul> name="output_type"
value="anki"
checked
/>
<label for="out1">Anki Deck</label>
</div>
<div>
<input
type="radio"
id="out2"
name="output_type"
value="quiz"
/>
<label for="out2">Quizlet deck</label>
</div>
</li>
<li>
<input
id="settings_button"
type="submit"
value="Lock-in Settings"
/>
<br />
<a href="/app">Reset Settings</a>
</li>
</ul>
</form>
</footer> </footer>
</section> </section>
@@ -127,5 +142,57 @@
<script src="static/assets/js/breakpoints.min.js"></script> <script src="static/assets/js/breakpoints.min.js"></script>
<script src="static/assets/js/util.js"></script> <script src="static/assets/js/util.js"></script>
<script src="static/assets/js/main.js"></script> <script src="static/assets/js/main.js"></script>
<script src="static/assets/js/app.js"></script>
<script>
const serverData = {{ data | tojson }};
if (serverData.state === "new") {
$("#text_area").hide();
$("#text").prop('disabled', true);
$("#process").prop('disabled', true);
}
if (serverData.state === "complete") {
// Set values to inputs
if (serverData.deck_type === "dictionary") {
$('#type1').prop('checked', true);
}
if (serverData.deck_type === "phrases") {
$('#type2').prop('checked', true);
}
if (serverData.deck_type === "paragraph") {
$('#type3').prop('checked', true);
}
$('#language').val(serverData.language);
if (serverData.output_type === "anki") {
$('#out1').prop('checked', true);
}
if (serverData.output_type === "quiz") {
$('#out2').prop('checked', true);
}
// Disable inputs
$('#type1').prop('disabled', true);
$('#type2').prop('disabled', true);
$('#type3').prop('disabled', true);
$('#language').prop('disabled', true);
$('#out1').prop('disabled', true);
$('#out2').prop('disabled', true);
$("#settings_button").prop('disabled', true);
}
$('#taxt_form').addEventListener('submit', function(e) {
// Get current URL query parameters
const currentParams = new URLSearchParams(window.location.search);
// Loop through current parameters and append them to the form
currentParams.forEach((value, key) => {
// Check if the input already exists to prevent duplicates
if (!this.querySelector(`input[name="${key}"]`)) {
const hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = key;
hiddenInput.value = value;
this.appendChild(hiddenInput);
}
});
});
</script>
</body> </body>
</html> </html>

View File

@@ -11,6 +11,10 @@
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="keywords" content="" /> <meta name="keywords" content="" />
<link rel="stylesheet" href="static/assets/css/main.css" /> <link rel="stylesheet" href="static/assets/css/main.css" />
<link
rel="shortcut icon"
href="{{ url_for('static', filename='favicon.ico') }}"
/>
</head> </head>
<body class="is-preload"> <body class="is-preload">
<!-- Wrapper --> <!-- Wrapper -->