From 8f1925ce05b3c8ef6cd77350b43145a25f46be54 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Tue, 9 Apr 2019 21:16:12 +0200 Subject: [PATCH] search_results: various fixes to the DOM Avoid repeated style attributes, instead use nth-child CSS selectors and classes where appropriate. Also, get rid of the useless
around column headings. They don't seem to do anything useful and are just more stuff for the browser's layout engine to juggle around. We can also use Jinja2 to remove some of the unnecessary whitespace around table headings, which makes things like copy-pasting in Firefox act less weird. This includes some other whitespace fixes too. --- nyaa/static/css/main.css | 18 +++++++ nyaa/templates/search_results.html | 86 +++++++++++++++--------------- 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/nyaa/static/css/main.css b/nyaa/static/css/main.css index c86333a..f314f6e 100644 --- a/nyaa/static/css/main.css +++ b/nyaa/static/css/main.css @@ -36,6 +36,11 @@ table.torrent-list thead th a { filter: alpha(opacity=1); } +.category-icon { + width: 80px; + height: 28px; +} + table.torrent-list thead th.sorting:after, table.torrent-list thead th.sorting_asc:after, table.torrent-list thead th.sorting_desc:after { @@ -88,6 +93,19 @@ table.torrent-list tbody .comments i { padding-right: 2px; } +table.torrent-list td:first-child { + padding: 0 4px; +} +table.torrent-list td:nth-child(4) { + white-space: nowrap; +} +table.torrent-list td:nth-child(6) { + color: green; +} +table.torrent-list td:nth-child(7) { + color: red; +} + #torrent-description img { max-width: 100%; } diff --git a/nyaa/templates/search_results.html b/nyaa/templates/search_results.html index 4e41eb4..25b7142 100644 --- a/nyaa/templates/search_results.html +++ b/nyaa/templates/search_results.html @@ -1,11 +1,11 @@ {% macro render_column_header(header_class, 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([header_class, sort_key and "sorting" + class_suffix, center_text and "text-center"]) %} - - {% if sort_key %} + + {%- if sort_key -%} - {% endif %} - {{ caller() }} + {%- endif -%} + {{- caller() -}} {% endmacro %} @@ -22,35 +22,35 @@ - {% call render_column_header("hdr-category", "width:80px;", center_text=True) %} -
Category
- {% endcall %} - {% call render_column_header("hdr-name", "width:auto;") %} -
Name
- {% endcall %} - {% call render_column_header("hdr-comments", "width:50px;", center_text=True, sort_key="comments", header_title="Comments") %} + {%+ call render_column_header("hdr-category", "width:80px;", center_text=True) -%} + Category + {%- endcall %} + {%+ call render_column_header("hdr-name", "width:auto;") -%} + Name + {%- endcall %} + {%+ call render_column_header("hdr-comments", "width:50px;", center_text=True, sort_key="comments", header_title="Comments") -%} - {% endcall %} - {% call render_column_header("hdr-link", "width:70px;", center_text=True) %} -
Link
- {% endcall %} - {% call render_column_header("hdr-size", "width:100px;", center_text=True, sort_key="size") %} -
Size
- {% endcall %} - {% call render_column_header("hdr-date", "width:140px;", center_text=True, sort_key="id", header_title="In UTC") %} -
Date
- {% endcall %} + {%- endcall %} + {%+ call render_column_header("hdr-link", "width:70px;", center_text=True) -%} + Link + {%- endcall %} + {%+ call render_column_header("hdr-size", "width:100px;", center_text=True, sort_key="size") -%} + Size + {%- endcall %} + {%+ call render_column_header("hdr-date", "width:140px;", center_text=True, sort_key="id", header_title="In UTC") -%} + Date + {%- endcall %} {% if config.ENABLE_SHOW_STATS %} - {% call render_column_header("hdr-seeders", "width:50px;", center_text=True, sort_key="seeders", header_title="Seeders") %} + {%+ call render_column_header("hdr-seeders", "width:50px;", center_text=True, sort_key="seeders", header_title="Seeders") -%} - {% endcall %} - {% call render_column_header("hdr-leechers", "width:50px;", center_text=True, sort_key="leechers", header_title="Leechers") %} + {%- endcall %} + {%+ call render_column_header("hdr-leechers", "width:50px;", center_text=True, sort_key="leechers", header_title="Leechers") -%} - {% endcall %} - {% call render_column_header("hdr-downloads", "width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") %} + {%- endcall %} + {%+ call render_column_header("hdr-downloads", "width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") -%} - {% endcall %} + {%- endcall %} {% endif %} @@ -60,14 +60,14 @@ {% for torrent in torrents %} {% set cat_id = use_elastic and ((torrent.main_category_id|string) + '_' + (torrent.sub_category_id|string)) or torrent.sub_category.id_as_string %} - - - + + {% else %} - - + + {% endif %} {% endif %}
- {% if use_elastic %} - - {% else %} - - {% endif %} - {{ category_name(cat_id) }} - + + {% if use_elastic %} + + {% else %} + + {% endif %} + {{ category_name(cat_id) }} + {% set torrent_id = torrent.meta.id if use_elastic else torrent.id %} @@ -78,13 +78,15 @@ {% endif %} {% if use_elastic %} - {%if "highlight" in torrent.meta %}{{ torrent.meta.highlight.display_name[0] | safe }}{% else %}{{torrent.display_name}}{%endif%} + {%if "highlight" in torrent.meta %}{{ torrent.meta.highlight.display_name[0] | safe }}{% else %}{{torrent.display_name}}{% endif %} {% else %} {{ torrent.display_name | escape }} {% endif %} - {% if torrent.has_torrent %}{% endif %} + + {% if torrent.has_torrent %} + + {% endif %} {% if use_elastic %} {% else %} @@ -100,12 +102,12 @@ {% if config.ENABLE_SHOW_STATS %} {% if use_elastic %} - {{ torrent.seed_count }}{{ torrent.leech_count }}{{ torrent.seed_count }}{{ torrent.leech_count }} {{ torrent.download_count }}{{ torrent.stats.seed_count }}{{ torrent.stats.leech_count }}{{ torrent.stats.seed_count }}{{ torrent.stats.leech_count }} {{ torrent.stats.download_count }}