Expand search to handle results, search submission
This commit is contained in:
parent
7b0cc42775
commit
45c263602b
@ -1,7 +1,16 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template, request
|
||||||
|
|
||||||
blueprint = Blueprint("search", __name__, url_prefix="/search")
|
blueprint = Blueprint("search", __name__, url_prefix="/search")
|
||||||
|
|
||||||
|
def search_results(args: dict):
|
||||||
|
class renderable:
|
||||||
|
def render(self):
|
||||||
|
return "ok"
|
||||||
|
results = [renderable(), renderable()] # Do something with args
|
||||||
|
return render_template("search/search_results.html", results=results, value=args["keywords"])
|
||||||
|
|
||||||
@blueprint.route("/")
|
@blueprint.route("/")
|
||||||
def search_page():
|
def search_page():
|
||||||
|
if request.args:
|
||||||
|
return search_results(request.args)
|
||||||
return render_template("search/search.html")
|
return render_template("search/search.html")
|
||||||
|
@ -5,5 +5,14 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<input type="text" id="search_bar" placeholder="{{ localize("search_placeholder") }}">
|
<form method="get">
|
||||||
|
<label for="search_bar">Search</label>
|
||||||
|
<input type="text" id="search_bar" name="keywords" placeholder="{{ localize("search_placeholder") }}" value="{{value}}">
|
||||||
|
<label for="include_kanji">Include kanji</label>
|
||||||
|
<input type="checkbox" id="include_kanji" checked>
|
||||||
|
<label for="include_kanji">Include kotoba</label>
|
||||||
|
<input type="checkbox" id="include_kanji" checked>
|
||||||
|
</form>
|
||||||
|
{% block results %}
|
||||||
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
11
kanken_online/templates/search/search_results.html
Normal file
11
kanken_online/templates/search/search_results.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{% extends 'search/search.html' %}
|
||||||
|
|
||||||
|
{% block results %}
|
||||||
|
|
||||||
|
{% for result in results %}
|
||||||
|
<div class="result">
|
||||||
|
{{result.render()}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock%}
|
Loading…
Reference in New Issue
Block a user