summaryrefslogtreecommitdiff
path: root/searx/templates/simple/result_templates/file.html
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2025-10-13 09:28:42 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-10-20 10:18:33 +0200
commit937165853185ca16b0da6f72bc42bd1487ea0dcb (patch)
tree70da1dce7cb51d0f59cd36392103e8f33318f379 /searx/templates/simple/result_templates/file.html
parentee6d4f322f4bda18759ffb99380a06923424695b (diff)
[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 <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/templates/simple/result_templates/file.html')
-rw-r--r--searx/templates/simple/result_templates/file.html74
1 files changed, 74 insertions, 0 deletions
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 %}
+ <p class="abstract">{{ result.abstract|safe }}</p>
+{% endif -%}
+
+{%- if result.content %}
+ <p class="content">{{ result.content|safe }}</p>
+{% endif -%}
+
+<div class="attributes">
+ {% if result.author %}
+ <div>
+ <span>{{ _("Author") }}:</span>
+ <span>{{ result.author }}</span>
+ </div>
+ {% endif %}
+ {% if result.filename %}
+ <div>
+ <span>{{ _("Filename") }}:</span>
+ <span>{{ result.filename }}</span>
+ </div>
+ {% endif %}
+ {% if result.size %}
+ <div>
+ <span>{{ _("Filesize") }}:</span>
+ <span>{{ result.size }}</span>
+ </div>
+ {% endif %}
+ {% if result.time %}
+ <div>
+ <span>{{ _("Date") }}:</span>
+ <span>{{ result.time }}</span>
+ </div>
+ {% endif %}
+ {% if result.mimetype %}
+ <div>
+ <span>{{ _("Type") }}:</span>
+ <span>{{ result.mimetype }}</span>
+ </div>
+ {% endif %}
+</div>
+
+{% if result.embedded %}
+ {% if result.mtype in ("audio", "video") %}
+ <p class="altlink">
+ <a class="btn-collapse collapsed media-loader disabled_if_nojs"
+ data-target="#result-media-{{ index }}"
+ data-btn-text-collapsed="{{ _("show media") }}"
+ data-btn-text-not-collapsed="{{ _("hide media") }}"
+ >
+ {{ _("show media") }}
+ </a>
+ </p>
+ <div id="result-media-{{ index }}" class="embedded-{{ result.mtype }} invisible">
+ <{{ result.mtype }} controls preload="metadata" {% if result.thumbnail %}poster="{{ result.thumbnail }}" {% endif %}>
+ <source src="{{result.embedded}}" type="{{ result.mtype }}/{{ result.subtype }}">
+ </{{ result.mtype }}>
+ </div>
+ {% else %}
+ <p class="altlink">
+ <a href="{{result.embedded }}" target="_blank" rel="noopener noreferrer" download>
+ {{ _("Download") }}
+ </a>
+ </p>
+ {% endif %}
+{% endif %}
+
+{{ result_sub_footer(result) }}
+{{ result_footer(result) }}