From 6d49c8f08cc49a0cb8ea69e26ddd696937edfce7 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Fri, 15 Jun 2018 01:16:34 -0500 Subject: [PATCH] Improved result templates. --- searx/static/themes/eelo/css/eelo.css | 53 +++++++++++++++++- searx/static/themes/eelo/css/eelo.min.css | Bin 14394 -> 15242 bytes searx/static/themes/eelo/less/eelo/code.less | 11 ++++ searx/static/themes/eelo/less/eelo/defs.less | 1 + searx/static/themes/eelo/less/eelo/eelo.less | 3 +- .../static/themes/eelo/less/eelo/results.less | 50 ++++++++++++++++- searx/templates/eelo/about.html | 4 +- searx/templates/eelo/categories.html | 2 +- searx/templates/eelo/infobox.html | 8 +-- .../templates/eelo/result_templates/code.html | 20 +++---- .../eelo/result_templates/default.html | 30 ++-------- .../eelo/result_templates/torrent.html | 5 +- .../eelo/result_templates/videos.html | 36 ++++-------- searx/templates/eelo/results.html | 9 ++- searx/templates/eelo/stats.html | 2 +- searx/webapp.py | 13 ++++- 16 files changed, 167 insertions(+), 80 deletions(-) create mode 100644 searx/static/themes/eelo/less/eelo/code.less diff --git a/searx/static/themes/eelo/css/eelo.css b/searx/static/themes/eelo/css/eelo.css index 3f6df2bf6..e0377eeca 100644 --- a/searx/static/themes/eelo/css/eelo.css +++ b/searx/static/themes/eelo/css/eelo.css @@ -657,13 +657,34 @@ nav #eelo_links > * { margin-top: 8px; margin-bottom: 6px; } -.result .result-content p { +.result .result-content p, +.result .result-content pre { margin-top: 8px; margin-bottom: 8px; } .result.result-torrent .extra-info > :not(:last-child) { margin-right: 16px; } +.result.result-videos { + position: relative; +} +.result.result-videos .result-content { + display: flex; + margin: 0px; +} +.result.result-videos .result-content .result_header { + margin-top: 0; +} +.result.result-videos .result-content > .thumbnail { + flex: 1; +} +.result.result-videos .result-content > :not(.thumbnail) { + flex: 3; + padding-left: 16px; +} +.result.result-videos .result-content .thumbnail > img { + width: 100%; +} .result .external-link { font-size: 14px; color: #39a441; @@ -671,8 +692,18 @@ nav #eelo_links > * { .result .extra-info { color: rgba(0, 0, 0, 0.4); } +.result .code-block { + background-color: rgba(0, 0, 0, 0.03); + padding: 0 16px; + border-radius: 8px; + border: 1px solid rgba(0, 0, 0, 0.2); +} +.result .code-block pre { + white-space: pre-wrap; +} .result.result-default, -.result.result-torrent { +.result.result-torrent, +.result.result-videos { margin-bottom: 32px; } .result.result-images { @@ -751,6 +782,18 @@ nav #eelo_links > * { width: 100%; margin-top: 16px; } +.infobox table tr { + vertical-align: baseline; +} +.infobox table tr td { + padding: 0; + padding-bottom: 8px; +} +.infobox table tr > .label { + text-align: right; + color: rgba(0, 0, 0, 0.4); + padding-right: 16px; +} #image_result_mini_gallery_header { display: flex; align-items: center; @@ -845,3 +888,9 @@ nav #eelo_links > * { margin-bottom: 8px; } } +.highlight .lineno, +.highlighttable .lineno { + margin-right: 16px; + color: rgba(0, 0, 0, 0.4); + display: none; +} diff --git a/searx/static/themes/eelo/css/eelo.min.css b/searx/static/themes/eelo/css/eelo.min.css index 7811576050f650fd92cfbb01099b2a6817f49710..00670167f6e7abd593dc16745fd424887be2e88d 100644 GIT binary patch delta 718 zcmdm0&{e)cNrzEq@&#>i7KMVM)XC4aNd5M`h)oD4Y6;_7CnQdp4mtUfR(5wm3ZERhTn39s2m#&+WnpR?EXjb4@L7agK z2(#=mbJMHKGgC@3tPBkdR3~@or1C20CFiH4>L%snCudhrp1~z6WMHfbv&_ms!O*Or zVzRuvl&fJug+g(DPG*WiQF>CMhJg+U>KSRmT!Cy5D1xfXGcrq3b&CrUlT)nMV*EcJSsd1?7c`4tK!iAg!B3MEC=WvN9anaPPcx`{cN z>3LR3iN&conR%(T7%CM?QmUbWWMu&Jfo@WMNlAXLl|?}XrVcy3oW!Kmoa&O)iV}$N z>{dmY=@})~lOM8+Ox`amx_O&n3!AN8MrL|O4oE^l4`g> :not(:last-child) { margin-right: @spacing_large; } } + &.result-videos { + position: relative; + .result-content { + display: flex; + margin: 0px; + + .result_header { margin-top: 0; } + + & > .thumbnail { flex: 1; } + & > :not(.thumbnail) { + flex: 3; + padding-left: @spacing_large; + } + .thumbnail > img { width: 100%; } + } + } .external-link { font-size: @fontsize_small; @@ -44,9 +60,21 @@ .extra-info { color: @text-muted-color; } + + + .code-block { + background-color: @dim-color-superlighter; + padding: 0 @spacing_large; + border-radius: @corner-radius; + border: 1px solid @dim-color-light; + + pre { + white-space: pre-wrap; + } + } } -.result.result-default, .result.result-torrent { +.result.result-default, .result.result-torrent, .result.result-videos { margin-bottom: @spacing_xx-large; } .result.result-images { @@ -142,6 +170,24 @@ .footer { } + + table tr { + vertical-align: baseline; + + td { + padding: 0; + padding-bottom: @spacing_medium; + } + + & > .label { + text-align: right; + color: @text-muted-color; + padding-right: @spacing_large; + } + & > .value { + + } + } } #image_result_mini_gallery_header { diff --git a/searx/templates/eelo/about.html b/searx/templates/eelo/about.html index b8012e128..159fffcc7 100644 --- a/searx/templates/eelo/about.html +++ b/searx/templates/eelo/about.html @@ -1,5 +1,7 @@ {% extends "eelo/base.html" %} {% block title %}{{ _('about') }} - {% endblock %} {% block content %} -{% include '__common__/about.html' %} +
+ {% include '__common__/about.html' %} +
{% endblock %} diff --git a/searx/templates/eelo/categories.html b/searx/templates/eelo/categories.html index 28ca885ec..2c6f20d53 100644 --- a/searx/templates/eelo/categories.html +++ b/searx/templates/eelo/categories.html @@ -18,7 +18,7 @@
{% for category in categories %} - {% if not (category in ["general", "images"] or category in selected_categories) %} + {% if not (category in ["general", "images", "map"] or category in selected_categories) %} {{ category_widget(category) }} {% endif %} {% endfor %} diff --git a/searx/templates/eelo/infobox.html b/searx/templates/eelo/infobox.html index 9b6a2b042..4e84ea7cf 100644 --- a/searx/templates/eelo/infobox.html +++ b/searx/templates/eelo/infobox.html @@ -21,14 +21,14 @@
{% if infobox.attributes %} - +
{% for attribute in infobox.attributes %} - + {% if attribute.image %} - + {% else %} - + {% endif %} {% endfor %} diff --git a/searx/templates/eelo/result_templates/code.html b/searx/templates/eelo/result_templates/code.html index 0c04c65bf..b9659ca2c 100644 --- a/searx/templates/eelo/result_templates/code.html +++ b/searx/templates/eelo/result_templates/code.html @@ -1,18 +1,16 @@ {% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %} {{ result_header(result, favicons) }} -{{ result_sub_header(result) }} +{% call result_sub_header(result) %} + {% if result.repository %}{{ result.repository }}{% endif %} +{% endcall %} -{% if result.content %}

{{ result.content|safe }}

{% endif %} +
+ {% if result.content %}{{ result.content|safe }}{% endif %} -{% if result.repository %}

{{ icon('file') }} {{ result.repository }}

{% endif %} - -
-{{ result.codelines|code_highlighter(result.code_language)|safe }} +
+ {{ result.codelines|code_highlighter(result.code_language)|safe }} +
-{% if rtl %} -{{ result_footer_rtl(result) }} -{% else %} -{{ result_footer(result) }} -{% endif %} +{{ result_footer(result) }} \ No newline at end of file diff --git a/searx/templates/eelo/result_templates/default.html b/searx/templates/eelo/result_templates/default.html index a783a0cc7..d6a4f9729 100644 --- a/searx/templates/eelo/result_templates/default.html +++ b/searx/templates/eelo/result_templates/default.html @@ -1,31 +1,13 @@ {% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon with context %} {{ result_header(result, favicons) }} -{{ result_sub_header(result) }} +{% call result_sub_header(result) %} +{% endcall %} -{% if result.embedded %} - -{% endif %} - -{% if result.embedded %} -
- {{ result.embedded|safe }} -
-{% endif %} - -{% if result.img_src %} -
-
-{{ result.title|striptags }} -{% if result.content %}

{{ result.content|safe }}

{% endif %} -
+
+ + {% if result.content %}{{ result.content|safe }}{% endif %} +
-{% else %} -{% if result.content %}

{{ result.content|safe }}

{% endif %} -{% endif %} -{% if rtl %} -{{ result_footer_rtl(result) }} -{% else %} {{ result_footer(result) }} -{% endif %} diff --git a/searx/templates/eelo/result_templates/torrent.html b/searx/templates/eelo/result_templates/torrent.html index 07f76913d..90265d3f2 100644 --- a/searx/templates/eelo/result_templates/torrent.html +++ b/searx/templates/eelo/result_templates/torrent.html @@ -38,8 +38,5 @@

{% if result.content %}{{ result.content|safe }}{% endif %}

-{% if rtl %} -{{ result_footer_rtl(result) }} -{% else %} + {{ result_footer(result) }} -{% endif %} diff --git a/searx/templates/eelo/result_templates/videos.html b/searx/templates/eelo/result_templates/videos.html index 4fe7ce60f..724accc2c 100644 --- a/searx/templates/eelo/result_templates/videos.html +++ b/searx/templates/eelo/result_templates/videos.html @@ -1,27 +1,13 @@ {% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %} -{{ result_header(result, favicons) }} -{{ result_sub_header(result) }} - -{% if result.embedded %} - -{% endif %} - -{% if result.embedded %} -
- {{ result.embedded|safe }} -
-{% endif %} - -
-
- {{ result.title|striptags }} {{ result.engine }} - {% if result.content %}

{{ result.content|safe }}

{% endif %} -
-
- -{% if rtl %} -{{ result_footer_rtl(result) }} -{% else %} -{{ result_footer(result) }} -{% endif %} +
+ + {{ result.title|striptags }} {{ result.engine }} + + + {{ result_header(result, favicons) }} + {% call result_sub_header(result) -%} + {{result.engine}} + {%- endcall %} + +
\ No newline at end of file diff --git a/searx/templates/eelo/results.html b/searx/templates/eelo/results.html index d1a89bd73..34712fe86 100644 --- a/searx/templates/eelo/results.html +++ b/searx/templates/eelo/results.html @@ -40,9 +40,11 @@ {% else %} - {% macro put_results(results_slice) -%} + {% macro put_results(results_slice, no_image=False) -%} {%- for result in results_slice %} {% set template = result.template|replace('.html', '') if result['template'] else None %} + {% if no_image and template == "images" and not image_gallery %} + {% else %}
{% if template in ["torrent"] %} {{template}} @@ -55,12 +57,13 @@ {% include 'eelo/result_templates/default.html' %} {% endif %}
+ {% endif %} {%- endfor %} {%- endmacro %} diff --git a/searx/templates/eelo/stats.html b/searx/templates/eelo/stats.html index dc904d6c3..1291474de 100644 --- a/searx/templates/eelo/stats.html +++ b/searx/templates/eelo/stats.html @@ -1,7 +1,7 @@ {% extends "eelo/base.html" %} {% block title %}{{ _('stats') }} - {% endblock %} {% block content %} -
+

{{ _('Engine stats') }}

{% for stat_name,stat_category in stats %} diff --git a/searx/webapp.py b/searx/webapp.py index 8f984c9ee..ced662965 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -480,7 +480,18 @@ def index(): # search searchData = None try: + # we dont want users to select multiple categories, this simplifies the experience. + if request.form.get("categories"): + request.form["categories"] = "general" + if request.form.get("category"): + for k, v in request.form.items(): + if k.startswith("category_"): + request.form.pop(k, None) + request.form["category_images"] = u"off" + request.form["category_" + request.form['category']] = u"On" + searchData = search(request) + except Exception as e: # log exception logger.exception('search error') @@ -491,7 +502,7 @@ def index(): else: return index_error(), 500 - # serarch 5 images and 5 videos + # serrch 5 images and 5 videos images = [] videos = [] if searchData.categories == ['general'] and searchData.pageno == 1: -- GitLab
{{ attribute.label }}{{ attribute.label }}{{ attribute.image.alt }}{{ attribute.image.alt }}{{ attribute.value }}{{ attribute.value }}