From b7a3739239df2fb1573a8677eaef9b7104c4ad0a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 6 Aug 2020 20:21:33 -0700 Subject: add debug mode flag (to control json tag/link) --- fatcat_scholar/search.py | 1 + fatcat_scholar/templates/search.html | 5 ++++- fatcat_scholar/templates/search_macros.html | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index 6f11f30..1e0e705 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -29,6 +29,7 @@ class FulltextQuery(BaseModel): filter_availability: Optional[str] = None sort_order: Optional[str] = None collapse_key: Optional[str] = None + debug: Optional[bool] = False time_options: Any = { "label": gettext("Release Date"), "slug": "filter_time", diff --git a/fatcat_scholar/templates/search.html b/fatcat_scholar/templates/search.html index b4e6098..3faf499 100644 --- a/fatcat_scholar/templates/search.html +++ b/fatcat_scholar/templates/search.html @@ -17,6 +17,9 @@ {{ search_macros.query_hidden(query.type_options, query.filter_type) }} {{ search_macros.query_hidden(query.availability_options, query.filter_availability) }} {{ search_macros.query_hidden(query.sort_options, query.sort_order) }} + {% if query.debug %} + + {% endif %}
{{ _("Filters") }} @@ -87,7 +90,7 @@ {# search results (rendered via macro) #} {% for paper in hits.results %} - {{ search_macros.fulltext_search_result_row(paper, locale=locale) }} + {{ search_macros.fulltext_search_result_row(paper, locale=locale, debug_mode=query.debug) }} {% endfor %} {% if hits.count_found > hits.limit %} diff --git a/fatcat_scholar/templates/search_macros.html b/fatcat_scholar/templates/search_macros.html index 1f5f8f3..05fbbdc 100644 --- a/fatcat_scholar/templates/search_macros.html +++ b/fatcat_scholar/templates/search_macros.html @@ -24,7 +24,7 @@ {% endif %} {% endmacro %} -{% macro fulltext_search_result_row(paper, locale=None) -%} +{% macro fulltext_search_result_row(paper, locale=None, debug_mode=False) -%}
{# ### TITLE ROW #} @@ -149,9 +149,11 @@ {# colors to use: olive, brown, grey, pink, red, etc #} {# TODO: remove doc for ES 7.x-style lack of type #} {# TODO: only show 'json' link if from cluster? #} - - json - + {% if debug_mode %} + + json + + {% endif %} {% for tag in paper.tags|sort %} {{ tag_label(tag) }} -- cgit v1.2.3