Aevann 2024-10-21 15:45:10 +03:00
parent 6747e9dc89
commit 1fc84cb411
2 changed files with 7 additions and 3 deletions

View File

@ -53,12 +53,16 @@ def searchparse(text):
def searchposts(v):
query = request.values.get("q", '').strip()
criteria = searchparse(query)
if 'post' in criteria:
return redirect(request.full_path.replace('/search/posts', '/search/comments'))
page = get_page()
sort = request.values.get("sort", "new").lower()
t = request.values.get('t', 'all').lower()
criteria = searchparse(query)
posts = g.db.query(Post).options(load_only(Post.id)) \
.join(Post.author) \

View File

@ -183,7 +183,7 @@
{% if not request.path.startswith('/search/') %}
<div class="flex-grow-1 d-fl {% if not v %}pad{% endif %}">
<form class="form-inline search d-mob-none flex-nowrap mx-0 mx-lg-auto mb-0" {% if err or v and v.is_underage %}style="margin-right:40rem!important"{% endif %} action="/search/{% if p or request.path.endswith('/comments') %}comments{% else %}posts{% endif %}" method="get">
<form class="form-inline search d-mob-none flex-nowrap mx-0 mx-lg-auto mb-0" {% if err or v and v.is_underage %}style="margin-right:40rem!important"{% endif %} action="/search/posts" method="get">
<input autocomplete="off" class="form-control w-100" type="search" placeholder="{{search_placeholder}}" name="q" value="{{request.values.get('q', '')}}">
<span class="input-group-append">
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem">
@ -420,7 +420,7 @@
<ul style="overflow:auto" class="navbar-nav ml-auto d-flex d-md-none mt-3">
<li class="nav-item pb-3">
<form id="searchform" class="form-inline search flex-nowrap mx-1 mx-lg-auto mb-0" action="/search/{% if p or request.path.endswith('/comments') %}comments{% else %}posts{% endif %}" method="get">
<form id="searchform" class="form-inline search flex-nowrap mx-1 mx-lg-auto mb-0" action="/search/posts" method="get">
<input autocomplete="off" class="form-control form-control-sm w-100" type="search" placeholder="{{search_placeholder}}" name="q">
<span class="input-group-append">
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem">