From b51d4ec041c59001f8365904d799b5188ec60c3c Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Sun, 28 Jun 2020 20:40:48 +0200 Subject: [PATCH] [fix] add aria labels to result links - #350 --- searx/templates/oscar/macros.html | 26 +++++++++---------- .../oscar/result_templates/code.html | 4 +-- .../oscar/result_templates/default.html | 10 +++---- .../oscar/result_templates/images.html | 4 +-- .../templates/oscar/result_templates/map.html | 8 +++--- .../oscar/result_templates/torrent.html | 8 +++--- .../oscar/result_templates/videos.html | 12 ++++----- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/searx/templates/oscar/macros.html b/searx/templates/oscar/macros.html index 809c9f595..58f966997 100644 --- a/searx/templates/oscar/macros.html +++ b/searx/templates/oscar/macros.html @@ -8,34 +8,34 @@ {{ favicon }} {%- endmacro %} -{%- macro result_link(url, title, classes='') -%} -{{ title }} +{%- macro result_link(url, title, classes='', id='') -%} +{{ title }} {%- endmacro -%} -{% macro result_header(result, favicons) -%} -

{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{% if result.url %}{{ result_link(result.url, result.title|safe) }}{% else %}{{ result.title|safe}}{% endif %}

+{% macro result_header(result, favicons, id) -%} +

{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{% if result.url %}{{ result_link(result.url, result.title|safe, id=id) }}{% else %}{{ result.title|safe}}{% endif %}

{%- endmacro %} -{% macro result_sub_header(result) -%} +{% macro result_sub_header(result, id) -%} {% if result.publishedDate %}{% endif %} - {% if result.magnetlink %} • {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink") }}{% endif %} - {% if result.torrentfile %} • {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile") }}{% endif %} + {% if result.magnetlink %} • {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink", id) }}{% endif %} + {% if result.torrentfile %} • {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile", id) }}{% endif %} {%- endmacro %} -{% macro result_footer(result) -%} +{% macro result_footer(result, id) -%}
{{- "" -}}
{%- for engine in result.engines -%} {{ engine }} {%- endfor -%} {%- if result.url -%} - {{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info") }} + {{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }} {%- endif -%} {%- if proxify -%} - {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }} + {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }} {%- endif -%}
{%- if result.pretty_url -%} @@ -44,16 +44,16 @@ {%- endmacro %} -{% macro result_footer_rtl(result) -%} +{% macro result_footer_rtl(result, id) -%}
{{- "" -}} {% for engine in result.engines -%} {{ engine }} {%- endfor %} {%- if result.url -%} - {{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info") }} + {{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }} {%- endif -%} {% if proxify -%} - {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }} + {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }} {%- endif %} {%- if result.pretty_url -%} diff --git a/searx/templates/oscar/result_templates/code.html b/searx/templates/oscar/result_templates/code.html index a1c18a6b7..c7d93e2b3 100644 --- a/searx/templates/oscar/result_templates/code.html +++ b/searx/templates/oscar/result_templates/code.html @@ -1,11 +1,11 @@ -{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %} +{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon with context%} {{ result_header(result, favicons) }} {{ result_sub_header(result) }} {% if result.content %}

{{ result.content|safe }}

{% endif %} -{% if result.repository %}

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

{% endif %} +{% if result.repository %}

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

{% endif %}
{{ result.codelines|code_highlighter(result.code_language)|safe }} diff --git a/searx/templates/oscar/result_templates/default.html b/searx/templates/oscar/result_templates/default.html index 57365f34e..bc71d190d 100644 --- a/searx/templates/oscar/result_templates/default.html +++ b/searx/templates/oscar/result_templates/default.html @@ -1,10 +1,10 @@ {% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon with context %} -{{- result_header(result, favicons) -}} -{{- result_sub_header(result) -}} +{{- result_header(result, favicons, loop.index) -}} +{{- result_sub_header(result, loop.index) -}} {%- if result.embedded -%} - + {%- endif -%} {%- if result.embedded -%} @@ -25,7 +25,7 @@ {%- endif -%} {%- if rtl -%} -{{ result_footer_rtl(result) }} +{{ result_footer_rtl(result, loop.index) }} {%- else -%} -{{ result_footer(result) }} +{{ result_footer(result, loop.index) }} {%- endif -%} diff --git a/searx/templates/oscar/result_templates/images.html b/searx/templates/oscar/result_templates/images.html index d0a3b7b83..96cdd53bb 100644 --- a/searx/templates/oscar/result_templates/images.html +++ b/searx/templates/oscar/result_templates/images.html @@ -1,6 +1,6 @@ -{%- from 'oscar/macros.html' import draw_favicon -%} +{%- from 'oscar/macros.html' import draw_favicon with context -%} -{{- "" -}} +{{- "" -}} {{ result.title|striptags }}{{- "" -}}