From 937165853185ca16b0da6f72bc42bd1487ea0dcb Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 13 Oct 2025 09:28:42 +0200 Subject: [mod] typification of SearXNG: add new result type File This PR adds a new result type: File Python class: searx/result_types/file.py Jinja template: searx/templates/simple/result_templates/file.html CSS (less) client/simple/src/less/result_types/file.less Class 'File' (singular) replaces template 'files.html' (plural). The renaming was carried out because there is only one file (singular) in a result. Not to be confused with the category 'files' where in multiple results can exist. As mentioned in issue [1], the class '.category-files' was removed from the CSS and the stylesheet was adopted in result_types/file.less (there based on the templates and no longer based on the category). [1] https://github.com/searxng/searxng/issues/5198 Signed-off-by: Markus Heiser --- .../templates/simple/result_templates/default.html | 2 +- searx/templates/simple/result_templates/file.html | 74 ++++++++++++++++++++++ searx/templates/simple/result_templates/files.html | 45 ------------- 3 files changed, 75 insertions(+), 46 deletions(-) create mode 100644 searx/templates/simple/result_templates/file.html delete mode 100644 searx/templates/simple/result_templates/files.html (limited to 'searx/templates') diff --git a/searx/templates/simple/result_templates/default.html b/searx/templates/simple/result_templates/default.html index 8a6329248..dcf6ad142 100644 --- a/searx/templates/simple/result_templates/default.html +++ b/searx/templates/simple/result_templates/default.html @@ -3,7 +3,7 @@ {{ result_header(result, favicons, image_proxify) -}} {{- result_sub_header(result) -}} {% if result.iframe_src -%} - + {%- endif %} {%- if result.content %}

diff --git a/searx/templates/simple/result_templates/file.html b/searx/templates/simple/result_templates/file.html new file mode 100644 index 000000000..c2ec66ede --- /dev/null +++ b/searx/templates/simple/result_templates/file.html @@ -0,0 +1,74 @@ +{% from "simple/macros.html" import result_header, result_sub_header, result_sub_footer, result_footer, result_link with context %} +{% from "simple/icons.html" import icon_small %} + +{{ result_header(result, favicons, image_proxify) }} +{{ result_sub_header(result) }} + +{% if result.abstract %} +

{{ result.abstract|safe }}

+{% endif -%} + +{%- if result.content %} +

{{ result.content|safe }}

+{% endif -%} + +
+ {% if result.author %} +
+ {{ _("Author") }}: + {{ result.author }} +
+ {% endif %} + {% if result.filename %} +
+ {{ _("Filename") }}: + {{ result.filename }} +
+ {% endif %} + {% if result.size %} +
+ {{ _("Filesize") }}: + {{ result.size }} +
+ {% endif %} + {% if result.time %} +
+ {{ _("Date") }}: + {{ result.time }} +
+ {% endif %} + {% if result.mimetype %} +
+ {{ _("Type") }}: + {{ result.mimetype }} +
+ {% endif %} +
+ +{% if result.embedded %} + {% if result.mtype in ("audio", "video") %} + + + {% else %} + + {% endif %} +{% endif %} + +{{ result_sub_footer(result) }} +{{ result_footer(result) }} diff --git a/searx/templates/simple/result_templates/files.html b/searx/templates/simple/result_templates/files.html deleted file mode 100644 index 13a425f31..000000000 --- a/searx/templates/simple/result_templates/files.html +++ /dev/null @@ -1,45 +0,0 @@ -{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_link with context %} -{% from 'simple/icons.html' import icon_small %} - -{{- result_header(result, favicons, image_proxify) -}} -{{- result_sub_header(result) -}} - -{%- if result.embedded -%} - -{%- endif -%} - -{%- if result.embedded -%} - -{%- endif -%} - -{%- if result.abstract %}

{{ result.abstract|safe }}

{% endif -%} - -{%- if result.img_src -%} -
-
-{{ result.title|striptags }} -{%- if result.content %}

{{ result.content|safe }}

{% endif -%} -
-
-{%- else -%} -{%- if result.content %}

{{ result.content|safe }}

{% endif -%} -{%- endif -%} - - -{%- if result.author %}{% endif -%} - -{%- if result.filename %}{% endif -%} - -{%- if result.size %}{%- endif -%} - -{%- if result.time %}{% endif -%} - -{%- if result.mtype %}{% endif -%} - - -{{ result_footer(result) }} -- cgit v1.2.3