hide snippets pass room list in search page
modified: app.py modified: templates/base.html modified: templates/search.html
This commit is contained in:
parent
926262cdaa
commit
db3c15ea0d
3 changed files with 12 additions and 4 deletions
5
app.py
5
app.py
|
|
@ -141,11 +141,15 @@ def chat(room_name):
|
|||
|
||||
@app.route("/search")
|
||||
def search_page():
|
||||
# Query all rooms so that newest is first.
|
||||
rooms = Room.query.order_by(Room.id.desc()).all()
|
||||
|
||||
keywords = request.args.get("keywords", "")
|
||||
username = request.args.get("username", "guest")
|
||||
if not keywords:
|
||||
return render_template(
|
||||
"search.html",
|
||||
rooms=rooms,
|
||||
keywords=keywords,
|
||||
results=[],
|
||||
username=username,
|
||||
|
|
@ -157,6 +161,7 @@ def search_page():
|
|||
|
||||
return render_template(
|
||||
"search.html",
|
||||
rooms=rooms,
|
||||
keywords=keywords,
|
||||
results=search_results,
|
||||
username=username,
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@
|
|||
<!-- Search form -->
|
||||
<div id="search-form" style="width: 90%;">
|
||||
<form action="/search" method="get">
|
||||
<input type="text" id="search-keywords" name="keywords" placeholder="Search for keywords..." style="width: 100%;" value="{{ keywords }}">
|
||||
<input type="text" id="search-keywords" name="keywords" placeholder="Search for keywords..." style="width: 100%; text-align: center;" value="{{ keywords }}">
|
||||
<input type="hidden" id="username" name="username" value="{{ username }}">
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@
|
|||
<style>
|
||||
/* Add styles for the search results */
|
||||
#search-results {
|
||||
margin-top: 20px;
|
||||
margin: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
.search-result {
|
||||
border: 1px solid #e1e1e1;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
@ -23,8 +25,9 @@
|
|||
{% for result in results %}
|
||||
<div class="search-result">
|
||||
<a href="/chat/{{ result.room_name }}?username={{ username }}">
|
||||
<b>{{ result.room_name }}</b> ({{ result.room_title or "No title" }})<br>
|
||||
<b>Snippets:</b> {{ result.snippets | join(' ... ') }}<br>
|
||||
<b>{{ result.room_name }}</b><br/>
|
||||
{{ result.room_title or "No title" }}</br>
|
||||
<!-- <b>Snippets:</b> {{ result.snippets | join(' ... ') }}<br> -->
|
||||
<b>Score:</b> {{ result.score }}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue