geminispace.info

gemini search engine
git clone https://git.clttr.info/geminispace.info.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit beb4b4e038d43d2c859bc7f6d23bc468469c0122
parent e93be0dbd849ccbed4a5c4b811adf9ca27a2d3b3
Author: René Wagner <rwa@clttr.info>
Date:   Sat,  3 Jun 2023 14:12:17 +0200

fix search

Diffstat:
Mserve/views.py | 44+++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/serve/views.py b/serve/views.py @@ -205,27 +205,26 @@ def index(request): @app.route("/search(/\d+)?") def search(request): if request.query: - def perform_search(): - verbose = compute_verbose(request.path) - requested_page = compute_requested_results_page(request.path) - num_results, results = gus.search_index(request.query, requested_page) - #if num_results > 0: - num_pages = math.ceil(num_results / 10) - current_page = min(requested_page, num_pages) - if num_results == 0: - current_page = 0 - body = render_template( - "search.gmi", - query=request.query, - quoted_query=quote(request.query), - verbose=verbose, - num_results=num_results, - results=results, - current_page=current_page, - num_pages=num_pages, - index_modification_time=gus.statistics["index_modification_time"] - ) - #else: + verbose = compute_verbose(request.path) + requested_page = compute_requested_results_page(request.path) + num_results, results = gus.search_index(request.query, requested_page) + #if num_results > 0: + num_pages = math.ceil(num_results / 10) + current_page = min(requested_page, num_pages) + if num_results == 0: + current_page = 0 + body = render_template( + "search.gmi", + query=request.query, + quoted_query=quote(request.query), + verbose=verbose, + num_results=num_results, + results=results, + current_page=current_page, + num_pages=num_pages, + index_modification_time=gus.statistics["index_modification_time"] + ) + #else: # search_suggestions = gus.get_search_suggestions(request.query) # body = render_template( # "search_suggestions.gmi", @@ -233,9 +232,8 @@ def search(request): # search_suggestions=search_suggestions, # index_modification_time=gus.statistics["index_modification_time"] # ) - return body - return Response(Status.SUCCESS, "text/gemini", deferred_search()) + return Response(Status.SUCCESS, "text/gemini", body) else: return Response(Status.INPUT, "Search query")