From d810763107733cec017b8688c0350dff527f2ed1 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Mon, 22 Dec 2014 16:07:02 +0100 Subject: [PATCH] [enh] remove repeating codeparts inside the oscar template --- searx/static/oscar/css/oscar.min.css | Bin 3387 -> 3411 bytes searx/static/oscar/less/oscar/results.less | 5 ++++ searx/templates/oscar/macros.html | 25 ++++++++++++++++++ .../oscar/result_templates/code.html | 13 +++------ .../oscar/result_templates/default.html | 13 +++------ .../oscar/result_templates/images.html | 4 ++- .../templates/oscar/result_templates/map.html | 14 +++------- .../oscar/result_templates/torrent.html | 13 +++------ .../oscar/result_templates/videos.html | 13 +++------ 9 files changed, 53 insertions(+), 47 deletions(-) diff --git a/searx/static/oscar/css/oscar.min.css b/searx/static/oscar/css/oscar.min.css index 28f66e3d35d1f10b889eeeed6dafec986f92e421..970850a4a87c18d1c576152530c6cb7bd79200b2 100644 GIT binary patch delta 24 fcmdljby;e|aVGAf)Z)^d65Ztdl+?|;m>RhNemDuJ delta 12 TcmcaCwOeY#ai-1pnM$|-CN>35 diff --git a/searx/static/oscar/less/oscar/results.less b/searx/static/oscar/less/oscar/results.less index 08500b3ff..cea8f3b41 100644 --- a/searx/static/oscar/less/oscar/results.less +++ b/searx/static/oscar/less/oscar/results.less @@ -55,6 +55,11 @@ clear: both; } +// code formating of results +.result-code { + clear: both; +} + // suggestion .suggestion_item { margin: 2px 5px; diff --git a/searx/templates/oscar/macros.html b/searx/templates/oscar/macros.html index f61de2015..1dc696341 100644 --- a/searx/templates/oscar/macros.html +++ b/searx/templates/oscar/macros.html @@ -1,3 +1,28 @@ + {% macro icon(action) -%} {%- endmacro %} + + + +{% macro draw_favicon(favicon) -%} + {{ favicon }} +{%- endmacro %} + + +{% macro result_header(result) -%} +

{% if result.favicon %}{{ draw_favicon(result.favicon) }} {% endif %}{{ result.title|safe }}

+{%- endmacro %} + + +{% macro result_sub_header(result) -%} + {% if result.publishedDate %}{% endif %} + {{ icon('link') }} {{ _('cached') }} +{%- endmacro %} + + +{% macro result_footer(result) -%} +
+ {{ result.engine }} +

{{ result.pretty_url }}

+{%- endmacro %} diff --git a/searx/templates/oscar/result_templates/code.html b/searx/templates/oscar/result_templates/code.html index d9079a464..236834d0a 100644 --- a/searx/templates/oscar/result_templates/code.html +++ b/searx/templates/oscar/result_templates/code.html @@ -1,9 +1,7 @@ -{% from 'oscar/macros.html' import icon %} +{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, icon %} -

{% if result['favicon'] %}{{ result['favicon'] }} {% endif %}{{ result.title|safe }}

- -{% if result.publishedDate %}{% endif %} -{{ icon('link') }} {{ _('cached') }} +{{ result_header(result) }} +{{ result_sub_header(result) }} {% if result.content %}

{{ result.content|safe }}

{% endif %} @@ -11,7 +9,4 @@ {{ result.codelines|code_highlighter(result.code_language)|safe }} -
- -{{ result.engine }} -

{{ result.pretty_url }}

+{{ result_footer(result) }} diff --git a/searx/templates/oscar/result_templates/default.html b/searx/templates/oscar/result_templates/default.html index 0f090d862..bc967f01e 100644 --- a/searx/templates/oscar/result_templates/default.html +++ b/searx/templates/oscar/result_templates/default.html @@ -1,13 +1,8 @@ -{% from 'oscar/macros.html' import icon %} +{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer %} -

{% if result['favicon'] %}{{ result['favicon'] }} {% endif %}{{ result.title|safe }}

- -{% if result.publishedDate %}{% endif %} -{{ icon('link') }} {{ _('cached') }} +{{ result_header(result) }} +{{ result_sub_header(result) }} {% if result.content %}

{{ result.content|safe }}

{% endif %} -
- -{{ result.engine }} -

{{ result.pretty_url }}

+{{ result_footer(result) }} diff --git a/searx/templates/oscar/result_templates/images.html b/searx/templates/oscar/result_templates/images.html index 7689f9f58..69c2e6fff 100644 --- a/searx/templates/oscar/result_templates/images.html +++ b/searx/templates/oscar/result_templates/images.html @@ -1,3 +1,5 @@ +{% from 'oscar/macros.html' import draw_favicon %} + {{ result.title|striptags }} @@ -7,7 +9,7 @@