geminispace.info

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

commit c0210d90cf3d599060d58e6972fb6272ea322237
parent 5d7627a3f26d428a28a997061f977657b8abc9c9
Author: Natalie Pendragon <natpen@natpen.net>
Date:   Wed, 16 Sep 2020 08:56:40 -0400

[serve] Add "jump to page" functionality to search

Diffstat:
Mserve/templates/fragments/pager.gmi | 3+++
Mserve/views.py | 15+++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/serve/templates/fragments/pager.gmi b/serve/templates/fragments/pager.gmi @@ -11,3 +11,6 @@ Page {{current_page}} of {{num_pages}} ({{num_results}} results) {% if current_page < num_pages %} => {{ search_path }}/{{ current_page + 1}}?{{ quoted_query }} Next Page {% endif %} +{% if num_pages > 1 %} +=> {{ search_path }}/jump/{{ quoted_query }} Jump to page... +{% endif %} diff --git a/serve/views.py b/serve/views.py @@ -193,6 +193,21 @@ def search(request): return Response(Status.INPUT, "Search query") +@app.route("/search/jump/(?P<query>.+)") +@app.route("/v/search/jump/(?P<query>.+)") +def search_jump(request, query): + if request.query: + if request.query.isdigit(): + jump_page = request.query + else: + jump_page = 1 + verbose_segment = "/v" if request.path.startswith("/v") else "" + jump_url = f"{verbose_segment}/search/{jump_page}?{query}" + return Response(Status.REDIRECT_TEMPORARY, jump_url) + else: + return Response(Status.INPUT, "Jump to page") + + @app.route("/backlinks") def backlinks(request): if request.query: