Compare commits
No commits in common. "3133fc1de2ba259f32bf6ce89ebe94b70c2c238e" and "5a1cae3143395a5d3384d0c6a735bcdc63c38025" have entirely different histories.
3133fc1de2
...
5a1cae3143
@ -43,60 +43,41 @@ def create_app(test_config=None):
|
|||||||
|
|
||||||
def update_settings(form, files):
|
def update_settings(form, files):
|
||||||
db = get_database()
|
db = get_database()
|
||||||
# Set values in the database
|
|
||||||
settings = db.execute("SELECT * FROM user_settings WHERE user_id = ?",
|
if "user_id" in session:
|
||||||
(session["user_id"],)
|
# Set values in the database
|
||||||
).fetchone()
|
settings = db.execute("SELECT * FROM user_settings WHERE user_id = ?",
|
||||||
if settings:
|
(session["user_id"],)
|
||||||
db.execute("UPDATE user_settings SET lang = ?, theme = ? WHERE user_id = ?",
|
).fetchone()
|
||||||
(form["language"], form["theme"], session["user_id"]))
|
if settings:
|
||||||
else:
|
db.execute("UPDATE user_settings SET lang = ?, theme = ? WHERE user_id = ?",
|
||||||
db.execute("INSERT INTO user_settings (user_id, lang, theme) VALUES (?, ?, ?)",
|
(form["language"], form["theme"], session["user_id"]))
|
||||||
(session["user_id"], form["language"], form["theme"]))
|
else:
|
||||||
|
db.execute("INSERT INTO user_settings (user_id, lang, theme) VALUES (?, ?, ?)",
|
||||||
|
(session["user_id"], form["language"], form["theme"]))
|
||||||
|
|
||||||
|
if "pfp" in files and files["pfp"].filename != "":
|
||||||
|
stored_filename = str(uuid.uuid4())
|
||||||
|
pfp = files["pfp"]
|
||||||
|
pfp.save(os.path.join(app.config["PFP_STORE"], stored_filename))
|
||||||
|
|
||||||
|
db.execute("UPDATE user_settings SET pfp_filename = ?", (stored_filename,))
|
||||||
|
|
||||||
|
db.commit()
|
||||||
|
|
||||||
if "pfp" in files and files["pfp"].filename != "":
|
|
||||||
stored_filename = str(uuid.uuid4())
|
|
||||||
pfp = files["pfp"]
|
|
||||||
pfp.save(os.path.join(app.config["PFP_STORE"], stored_filename))
|
|
||||||
|
|
||||||
# Remove old PFP
|
|
||||||
if settings and settings["pfp_filename"]:
|
|
||||||
os.remove(os.path.join(app.config["PFP_STORE"], settings["pfp_filename"]))
|
|
||||||
|
|
||||||
db.execute("UPDATE user_settings SET pfp_filename = ?", (stored_filename,))
|
|
||||||
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
update_logged_out_settings(form)
|
|
||||||
|
|
||||||
return redirect("/options")
|
|
||||||
|
|
||||||
def update_logged_out_settings(form):
|
|
||||||
# Set values directly in the session
|
# Set values directly in the session
|
||||||
session["language"] = form["language"]
|
session["language"] = form["language"]
|
||||||
session["theme"] = form["theme"]
|
session["theme"] = form["theme"]
|
||||||
return redirect("/public_options")
|
|
||||||
|
return redirect("/options")
|
||||||
|
|
||||||
@app.route("/options", methods=["GET", "POST"])
|
@app.route("/options", methods=["GET", "POST"])
|
||||||
def options():
|
def options():
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
if "user_id" in session:
|
return render_template("options.html")
|
||||||
return render_template("options.html")
|
|
||||||
else:
|
|
||||||
return redirect("/public_options")
|
|
||||||
else:
|
else:
|
||||||
return update_settings(request.form, request.files)
|
return update_settings(request.form, request.files)
|
||||||
|
|
||||||
@app.route("/public_options", methods=["GET", "POST"])
|
|
||||||
def public_options():
|
|
||||||
if request.method == "GET":
|
|
||||||
if "user_id" in session:
|
|
||||||
return redirect("/public_options")
|
|
||||||
else:
|
|
||||||
return render_template("logged_out_options.html")
|
|
||||||
else:
|
|
||||||
return update_logged_out_settings(request.form)
|
|
||||||
|
|
||||||
@app.get("/user/<int:user_id>")
|
@app.get("/user/<int:user_id>")
|
||||||
def user_page(user_id: int):
|
def user_page(user_id: int):
|
||||||
db = get_database()
|
db = get_database()
|
||||||
|
@ -123,9 +123,6 @@ class Kanji(Base):
|
|||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def render(self):
|
|
||||||
return self.character
|
|
||||||
|
|
||||||
@blueprint.route("/id/<int:kanji_id>")
|
@blueprint.route("/id/<int:kanji_id>")
|
||||||
def kanji_by_id(kanji_id: int):
|
def kanji_by_id(kanji_id: int):
|
||||||
session = get_jiten_db()
|
session = get_jiten_db()
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
from flask import Blueprint, render_template, request
|
from flask import Blueprint, render_template, request
|
||||||
from sqlalchemy import select
|
|
||||||
|
|
||||||
from kanken_online.api import Goon, Kanji, Kanon, Kanyoon, Kun, Soon, Toon
|
|
||||||
from kanken_online.database import get_jiten_db
|
|
||||||
|
|
||||||
blueprint = Blueprint("search", __name__, url_prefix="/search")
|
blueprint = Blueprint("search", __name__, url_prefix="/search")
|
||||||
|
|
||||||
@ -11,58 +7,6 @@ def search_results(args: dict):
|
|||||||
def render(self):
|
def render(self):
|
||||||
return "ok"
|
return "ok"
|
||||||
results = [renderable(), renderable()] # Do something with args
|
results = [renderable(), renderable()] # Do something with args
|
||||||
|
|
||||||
jiten = get_jiten_db()
|
|
||||||
|
|
||||||
query = select(Kanji).where(
|
|
||||||
Kanji.character == args["keywords"]
|
|
||||||
).where(
|
|
||||||
Kanji.stroke_count.between((args["stroke_min"] or 0), (args["stroke_max"] or 100))
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["radical"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.radical == args["radical"]
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["kanon"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.kanon.any(Kanon.reading.in_([args["kanon"]]))
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["goon"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.goon.any(Goon.reading.in_([args["goon"]]))
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["soon"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.soon.any(Soon.reading.in_([args["soon"]]))
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["toon"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.toon.any(Toon.reading.in_([args["toon"]]))
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["kanyoon"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.kanyoon.any(Kanyoon.reading.in_([args["kanyoon"]]))
|
|
||||||
)
|
|
||||||
|
|
||||||
if args["kun"]:
|
|
||||||
query = query.where(
|
|
||||||
Kanji.kun.any(Kun.reading.in_([args["kun"]]))
|
|
||||||
)
|
|
||||||
|
|
||||||
# if args["onkun"]:
|
|
||||||
# query = query.where(
|
|
||||||
# Kanji.kun.any(Kun.reading.in_([args["kun"]]))
|
|
||||||
# )
|
|
||||||
|
|
||||||
results = [row[0] for row in jiten.execute(query).all()]
|
|
||||||
# print(list(map(Kanji.to_json, results)))
|
|
||||||
|
|
||||||
return render_template("search/search_results.html", results=results, value=args["keywords"])
|
return render_template("search/search_results.html", results=results, value=args["keywords"])
|
||||||
|
|
||||||
@blueprint.route("/")
|
@blueprint.route("/")
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
body {
|
body {
|
||||||
background: black;
|
background: green;
|
||||||
color: aliceblue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
@ -44,6 +44,5 @@
|
|||||||
"success_new_post": "Successfully created new post",
|
"success_new_post": "Successfully created new post",
|
||||||
"user_introduction": "User",
|
"user_introduction": "User",
|
||||||
"pfp": "Profile picture",
|
"pfp": "Profile picture",
|
||||||
"level_1_exam": "Level 1 exam",
|
"level_1_exam": "Level 1 exam"
|
||||||
"exam": "Exam"
|
|
||||||
}
|
}
|
@ -44,6 +44,5 @@
|
|||||||
"success_new_post": "無事に新しい投稿を作りました",
|
"success_new_post": "無事に新しい投稿を作りました",
|
||||||
"user_introduction": "利用者の",
|
"user_introduction": "利用者の",
|
||||||
"pfp": "利用者アイコン",
|
"pfp": "利用者アイコン",
|
||||||
"level_1_exam": "一級試験",
|
"level_1_exam": "一級試験"
|
||||||
"exam": "試験"
|
|
||||||
}
|
}
|
@ -28,7 +28,6 @@
|
|||||||
<li><a href="{{ url_for('about_page') }}">{{ localize("about") }}</a></li>
|
<li><a href="{{ url_for('about_page') }}">{{ localize("about") }}</a></li>
|
||||||
<li><a href="{{ url_for('indices.indices_page') }}">{{ localize("indices") }}</a></li>
|
<li><a href="{{ url_for('indices.indices_page') }}">{{ localize("indices") }}</a></li>
|
||||||
<li><a href="{{ url_for('search.search_page') }}">{{ localize("search") }}</a></li>
|
<li><a href="{{ url_for('search.search_page') }}">{{ localize("search") }}</a></li>
|
||||||
<li><a href="{{ url_for('exam') }}">{{ localize("exam") }}</a></li>
|
|
||||||
<li><a href="{{ url_for('forum.index') }}">{{ localize("forum") }}</a></li>
|
<li><a href="{{ url_for('forum.index') }}">{{ localize("forum") }}</a></li>
|
||||||
<li><a href="{{ url_for('data_page') }}">{{ localize("data") }}</a></li>
|
<li><a href="{{ url_for('data_page') }}">{{ localize("data") }}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div lang="ja">
|
|
||||||
<h1>日本漢字能力検定試験問題</h1>
|
<h1>日本漢字能力検定試験問題</h1>
|
||||||
<div id="q1">
|
<div id="q1">
|
||||||
<h2>(一)</h2>
|
<h2>(一)</h2>
|
||||||
@ -58,141 +57,4 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="q3">
|
|
||||||
<h2>(三)</h2>
|
|
||||||
<p>次の1~5の意味を的確に表す語を、左の「」から選び、<b>漢字</b>で記せ。</p>
|
|
||||||
<ol id="q3-definitions">
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
<div id="q3-word-box">
|
|
||||||
<ul id="q3-words">
|
|
||||||
{% for i in range(8) %}
|
|
||||||
<li class="wordbox-word">Definition</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q4">
|
|
||||||
<h2>(四)</h2>
|
|
||||||
<p>次の<span class="mondai">問1</span>と<span class="mondai">問2</span>の四字熟語について答えよ。</p>
|
|
||||||
<div id="q4-mon-ichi">
|
|
||||||
<p><span class="mondai">問1</span> 次の四字熟語の(1~10)に入る適切な語を左の「」から選び<b>漢字二字</b>で記せ。</p>
|
|
||||||
<div id="q4-mon-ichi-questions">
|
|
||||||
<ol id="q4-mon-ichi-top">
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>bottom two characters</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
<ol id="q4-mon-ichi-bottom" start="6">
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>top two characters</li> <!--Q: Will this work with just CSS, or will it need extra HTML formatting...? -->
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
<div id="q4-mon-ichi-wordbox">
|
|
||||||
<ul id="q4-mon-ichi-words">
|
|
||||||
{% for i in range(10) %}
|
|
||||||
<li class="wordbox-word">Definition</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="q4-mon-ni">
|
|
||||||
<p>次の1~5の<b>解説・意味</b>にあてはまる四字熟語を後の「」から選び、その<b>傍線部分だけの読み</b>を<b>ひらがな</b>で記せ。</p>
|
|
||||||
<ol id="q4-mon-ni-questions">
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
<div id="q4-mon-ni-wordbox">
|
|
||||||
<ul id="q4-mon-ni-words">
|
|
||||||
{% for i in range(8) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q5">
|
|
||||||
<h2>(五)</h2>
|
|
||||||
<p>次の<b>熟字訓・当て字</b>の読みを記せ。</p>
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q6">
|
|
||||||
<h2>(六)</h2>
|
|
||||||
<p>次の<b>熟語</b>の<b>読み</b>(<b>音読み</b>)とその<b>語義</b>にふさわしい<b>訓読み</b>を(送りがなに注意して)<b>ひらがな</b>で記せ。</p>
|
|
||||||
<div id="q6-example">
|
|
||||||
<p>〈例〉健勝……勝れる→けんしょう・すぐ</p>
|
|
||||||
</div>
|
|
||||||
<div id="q6-questions">
|
|
||||||
<ol class="katakana-list">
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>
|
|
||||||
<ol start="{{2*i + 1}}">
|
|
||||||
<li>On</li>
|
|
||||||
……
|
|
||||||
<li>Kun</li>
|
|
||||||
</ol>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q7">
|
|
||||||
<h2>(七)</h2>
|
|
||||||
<p>次の1~5の<b>対義語</b>、6~10の<b>類義語</b>を後の「」の中から選び、<b>漢字</b>で記せ。「」の中の語は一度だけ使うこと。</p>
|
|
||||||
<div id="q7-antonyms">
|
|
||||||
<span><b>対義語</b></span>
|
|
||||||
<ol>
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<div id="q7-synonyms">
|
|
||||||
<span><b>対義語</b></span>
|
|
||||||
<ol start="6">
|
|
||||||
{% for i in range(5) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q7-wordbox">
|
|
||||||
<ul>
|
|
||||||
{% for i in range(10) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q8">
|
|
||||||
<h2>(八)</h2>
|
|
||||||
<p>次の故事・成語・諺の<b>カタカナ</b>の部分を<b>漢字</b>で記せ。</p>
|
|
||||||
<ol>
|
|
||||||
{% for i in range(10) %}
|
|
||||||
<li>Test</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="q9">
|
|
||||||
<h2>(九)</h2>
|
|
||||||
<p>文章の中の傍線(1~10)の<b>カタカナ</b>を<b>漢字</b>に直し、波線(ア~コ)の<b>漢字</b>の読みを<b>ひらがな</b>で記せ。</p>
|
|
||||||
<ol id="q9-texts">
|
|
||||||
{% for text in range(3) %}
|
|
||||||
<li>The quick brown fox jumps over the lazy dog.</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,25 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block header %}
|
|
||||||
<h1>{% block title %}{{ localize("options") }}{% endblock %}</h1>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<form method="post" enctype=multipart/form-data>
|
|
||||||
<label for="language-select">{{ localize("language") }}</label>
|
|
||||||
<select name="language" id="language-select">
|
|
||||||
<option value="ja">日本語</option>
|
|
||||||
<option value="en">English</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<label for="theme-select">{{ localize("theme") }}</label>
|
|
||||||
<select name="theme" id="theme-select">
|
|
||||||
<option value="dark">{{ localize("dark_theme") }}</option>
|
|
||||||
<option value="light">{{ localize("light_theme") }}</option>
|
|
||||||
</select>
|
|
||||||
{% block logged_in_options %}{% endblock %}
|
|
||||||
<hr>
|
|
||||||
<button type="submit">Okay</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -1,10 +1,27 @@
|
|||||||
{% extends 'logged_out_options.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<h1>{% block title %}{{ localize("options") }}{% endblock %}</h1>
|
<h1>{% block title %}{{ localize("options") }}{% endblock %}</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block logged_in_options %}
|
{% block content %}
|
||||||
|
<form method="post" enctype=multipart/form-data>
|
||||||
|
<label for="language-select">{{ localize("language") }}</label>
|
||||||
|
<select name="language" id="language-select">
|
||||||
|
<option value="ja">日本語</option>
|
||||||
|
<option value="en">English</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="theme-select">{{ localize("theme") }}</label>
|
||||||
|
<select name="theme" id="theme-select">
|
||||||
|
<option value="dark">{{ localize("dark_theme") }}</option>
|
||||||
|
<option value="light">{{ localize("light_theme") }}</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
<label for="pfp">{{ localize("pfp") }}</label>
|
<label for="pfp">{{ localize("pfp") }}</label>
|
||||||
<input type="file" id="pfp" name="pfp">
|
<input type="file" id="pfp" name="pfp">
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<button type="submit">Okay</button>
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="search_method_includes">Includes</label>
|
<label for="search_method_includes">Includes</label>
|
||||||
<input type="radio" id="search_method_includes" name="search_method" value="includes" checked>
|
<input type="radio" id="search_method_includes" name="search_method" value="includes">
|
||||||
<label for="search_method_includes">Matches</label>
|
<label for="search_method_includes">Matches</label>
|
||||||
<input type="radio" id="search_method_matches" name="search_method" value="matches">
|
<input type="radio" id="search_method_matches" name="search_method" value="matches">
|
||||||
<label for="search_method_includes">Starts with</label>
|
<label for="search_method_includes">Starts with</label>
|
||||||
@ -40,7 +40,6 @@
|
|||||||
<option value="include">include</option>
|
<option value="include">include</option>
|
||||||
<option value="exclude">exclude</option>
|
<option value="exclude">exclude</option>
|
||||||
</select>
|
</select>
|
||||||
<button type="submit">Submit</button>
|
|
||||||
</form>
|
</form>
|
||||||
{% block results %}
|
{% block results %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user