add basic functionality
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -4,7 +4,9 @@ from pathlib import Path
|
||||
# Pip
|
||||
from flask import Flask
|
||||
|
||||
# Local
|
||||
from .homescreen import homescreen
|
||||
from .mainapp import mainapp
|
||||
|
||||
|
||||
def create_app(test_config=None):
|
||||
@@ -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
|
||||
|
||||
@@ -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("/<page>")
|
||||
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"
|
||||
)
|
||||
|
||||
25
src/anki_creator_flask/mainapp.py
Normal file
25
src/anki_creator_flask/mainapp.py
Normal 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())
|
||||
0
src/anki_creator_flask/static/assets/js/app.js
Normal file
0
src/anki_creator_flask/static/assets/js/app.js
Normal file
BIN
src/anki_creator_flask/static/favicon.ico
Normal file
BIN
src/anki_creator_flask/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
src/anki_creator_flask/static/favicon.ico.old
Normal file
BIN
src/anki_creator_flask/static/favicon.ico.old
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 189 KiB |
@@ -11,105 +11,120 @@
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="static/assets/css/main.css" />
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href="{{ url_for('static', filename='favicon.ico') }}"
|
||||
/>
|
||||
</head>
|
||||
|
||||
<body class="is-preload">
|
||||
<!-- Wrapper -->
|
||||
<div id="wrapper">
|
||||
<!-- Section -->
|
||||
<section>
|
||||
<section id="first" style="padding-top: 3em">
|
||||
<header>
|
||||
<h2>Get in touch</h2>
|
||||
<h2>Select the deck type</h2>
|
||||
</header>
|
||||
<div class="content">
|
||||
|
||||
<div id="text_area" class="content">
|
||||
<p>
|
||||
<strong>Auctor commodo</strong> interdum et malesuada fames ac ante
|
||||
ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet
|
||||
dolor mattis sagittis.
|
||||
<strong>Paste here the word list</strong>
|
||||
</p>
|
||||
<form>
|
||||
<form id="taxt_form" method="POST">
|
||||
<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">
|
||||
<textarea
|
||||
name="message"
|
||||
id="message"
|
||||
placeholder="Message"
|
||||
rows="7"
|
||||
></textarea>
|
||||
<textarea name="text" id="text" rows="15"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="actions">
|
||||
<li>
|
||||
<input
|
||||
id="process"
|
||||
type="submit"
|
||||
value="Send Message"
|
||||
value="Process"
|
||||
class="button primary"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<form action="/app">
|
||||
<ul class="items">
|
||||
<li>
|
||||
<h3>Email</h3>
|
||||
<a href="#">information@untitled.ext</a>
|
||||
<h3>Deck Type</h3>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="type1"
|
||||
name="deck_type"
|
||||
value="dictionary"
|
||||
checked
|
||||
/>
|
||||
<label for="type1">Dictionary Deck</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="type2"
|
||||
name="deck_type"
|
||||
value="phrases"
|
||||
/>
|
||||
<label for="type2">Phrases List</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="type3"
|
||||
name="deck_type"
|
||||
value="paragraph"
|
||||
/>
|
||||
<label for="type3">Paragraph Dictation</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Phone</h3>
|
||||
<a href="#">(000) 000-0000</a>
|
||||
<h3>Language</h3>
|
||||
<select id="language" name="language">
|
||||
<option value="en">English</option>
|
||||
<option value="es">Spanish</option>
|
||||
<option value="ru">Russian</option>
|
||||
<option value="fr">French</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Address</h3>
|
||||
<span>1234 Somewhere Road, Nashville, TN 00000</span>
|
||||
<h3>Output</h3>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="out1"
|
||||
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>
|
||||
<h3>Elsewhere</h3>
|
||||
<ul class="icons">
|
||||
<li>
|
||||
<a href="#" class="icon brands fa-twitter"
|
||||
><span class="label">Twitter</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="icon brands fa-facebook-f"
|
||||
><span class="label">Facebook</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="icon brands fa-instagram"
|
||||
><span class="label">Instagram</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="icon brands fa-linkedin-in"
|
||||
><span class="label">LinkedIn</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="icon brands fa-github"
|
||||
><span class="label">GitHub</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="icon brands fa-codepen"
|
||||
><span class="label">Codepen</span></a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<input
|
||||
id="settings_button"
|
||||
type="submit"
|
||||
value="Lock-in Settings"
|
||||
/>
|
||||
<br />
|
||||
<a href="/app">Reset Settings</a>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
@@ -127,5 +142,57 @@
|
||||
<script src="static/assets/js/breakpoints.min.js"></script>
|
||||
<script src="static/assets/js/util.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>
|
||||
</html>
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="static/assets/css/main.css" />
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href="{{ url_for('static', filename='favicon.ico') }}"
|
||||
/>
|
||||
</head>
|
||||
<body class="is-preload">
|
||||
<!-- Wrapper -->
|
||||
|
||||
Reference in New Issue
Block a user