fix search

merge-requests/3/head
bug_creator 3 years ago
parent 066ea6b6d3
commit 15c7617a7d

@ -253,9 +253,13 @@ def query(content):
flash("Search content cannot be empty.") flash("Search content cannot be empty.")
return render_template('querypost.html') return render_template('querypost.html')
search_result = "%" + inf + "%" search_result = "%" + inf + "%"
result = Post.query.filter(or_(Post.title.like(search_result), Post.body.like(search_result))) print(search_result)
# result = Post.query.filter(or_(Post.title.like(search_result), Post.body.like(search_result)))
result = Post.query.filter(Post.body.like(search_result))
for item in result: for item in result:
item.important = 0 item.important = 0
if(item.title is None):
item.title=""
sentence = item.title + item.body sentence = item.title + item.body
counts = 0 counts = 0
list1 = sentence.split(" ") list1 = sentence.split(" ")

@ -69,14 +69,16 @@
<div class="tab-pane active" id="panel-1"> <div class="tab-pane active" id="panel-1">
<ul class="posts list-unstyled"> <ul class="posts list-unstyled">
{% for post in combination %} {% for post in combination %}
{% include 'Posts/_postsInQuery.html' %} {# {% include 'Posts/_postsInQuery.html' %}#}
{% include 'Posts/_posts.html' %}
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
<div class="tab-pane" id="panel-2"> <div class="tab-pane" id="panel-2">
<ul class="posts list-unstyled"> <ul class="posts list-unstyled">
{% for post in newest %} {% for post in newest %}
{% include 'Posts/_postsInQuery.html' %} {# {% include 'Posts/_postsInQuery.html' %}#}
{% include 'Posts/_posts.html' %}
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
@ -84,7 +86,8 @@
<div class="tab-pane" id="panel-3"> <div class="tab-pane" id="panel-3">
<ul class="posts list-unstyled"> <ul class="posts list-unstyled">
{% for post in hottest %} {% for post in hottest %}
{% include 'Posts/_postsInQuery.html' %} {# {% include 'Posts/_postsInQuery.html' %}#}
{% include 'Posts/_posts.html' %}
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
@ -92,7 +95,8 @@
<div class="tab-pane" id="panel-4"> <div class="tab-pane" id="panel-4">
<ul class="posts list-unstyled"> <ul class="posts list-unstyled">
{% for post in relevance %} {% for post in relevance %}
{% include 'Posts/_postsInQuery.html' %} {# {% include 'Posts/_postsInQuery.html' %}#}
{% include 'Posts/_posts.html' %}
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>

Binary file not shown.
Loading…
Cancel
Save