diff --git a/nyaa/routes.py b/nyaa/routes.py index dc99677..3325a43 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -49,6 +49,11 @@ def modify_query(**new_values): return '{}?{}'.format(flask.request.path, url_encode(args)) +@app.template_global() +def filter_truthy(input_list): + ''' Jinja2 can't into list comprehension so this is for + the search_results.html template ''' + return [item for item in input_list if item] def search(term='', user=None, sort='id', order='desc', category='0_0', filter='0', page=1, rss=False, admin=False): sort_keys = { diff --git a/nyaa/templates/search_results.html b/nyaa/templates/search_results.html index e061ba2..0ee2392 100644 --- a/nyaa/templates/search_results.html +++ b/nyaa/templates/search_results.html @@ -1,32 +1,43 @@ +{% macro render_column_header(header_style, center_text=False, sort_key=None, header_title=None) %} +{% set class_suffix = (search.sort == sort_key) and ("_" + search.order) or "" %} +{% set th_classes = filter_truthy([sort_key and "sorting" + class_suffix, center_text and "text-center"]) %} +