add basic functionality
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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"
|
||||||
|
)
|
||||||
|
|||||||
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="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>
|
||||||
|
<form action="/app">
|
||||||
<ul class="items">
|
<ul class="items">
|
||||||
<li>
|
<li>
|
||||||
<h3>Email</h3>
|
<h3>Deck Type</h3>
|
||||||
<a href="#">information@untitled.ext</a>
|
<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>
|
||||||
<li>
|
<li>
|
||||||
<h3>Phone</h3>
|
<h3>Language</h3>
|
||||||
<a href="#">(000) 000-0000</a>
|
<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>
|
||||||
<li>
|
<li>
|
||||||
<h3>Address</h3>
|
<h3>Output</h3>
|
||||||
<span>1234 Somewhere Road, Nashville, TN 00000</span>
|
<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>
|
||||||
<li>
|
<li>
|
||||||
<h3>Elsewhere</h3>
|
<input
|
||||||
<ul class="icons">
|
id="settings_button"
|
||||||
<li>
|
type="submit"
|
||||||
<a href="#" class="icon brands fa-twitter"
|
value="Lock-in Settings"
|
||||||
><span class="label">Twitter</span></a
|
/>
|
||||||
>
|
<br />
|
||||||
</li>
|
<a href="/app">Reset Settings</a>
|
||||||
<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>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</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>
|
||||||
|
|||||||
@@ -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 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user