diff --git a/website/web/__init__.py b/website/web/__init__.py index 2e8ceca2..c80b0fcc 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -753,20 +753,17 @@ def get_ressource(tree_uuid: str, node_uuid: str): as_attachment=True, attachment_filename='file.zip') -@app.route('/tree//url//ressource_preview', methods=['POST', 'GET']) -def get_ressource_preview(tree_uuid: str, node_uuid: str): - if request.method == 'POST': - h_request = request.form.get('ressource_hash') - else: - h_request = None - ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_request) +@app.route('/tree//url//ressource_preview', methods=['GET']) +@app.route('/tree//url//ressource_preview/', methods=['GET']) +def get_ressource_preview(tree_uuid: str, node_uuid: str, h_ressource: Optional[str]=None): + ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_ressource) if not ressource: - return None + return Response('No preview available.', mimetype='text/text') filename, r, mimetype = ressource if mimetype.startswith('image'): return send_file(r, mimetype=mimetype, as_attachment=True, attachment_filename=filename) - return None + return Response('No preview available.', mimetype='text/text') @app.route('/tree//url//hashes', methods=['GET']) diff --git a/website/web/templates/hostname_popup.html b/website/web/templates/hostname_popup.html index c45dd1d3..0b2393e0 100644 --- a/website/web/templates/hostname_popup.html +++ b/website/web/templates/hostname_popup.html @@ -218,14 +218,18 @@
{% for hash, details in url['embedded_ressources'].items() %} +
{% if details['known_content'] %} {{ known_content_details(details['known_content']) }} {% endif %} {{ ressource_legitimacy_details(details['legitimacy'], details['body_size']) }} +
- This file {% if details['type'] %}({{ details['type'] }}){% endif %} can be found {{ details['hash_freq'] }} times + This file {% if details['type'] %}({{ details['type'] }}){% endif %} can be found {{ details['hash_freq'] }} times across all the captures on this lookyloo instance, in {{ details['hash_domains_freq'] }} unique domains. - {{ get_ressource_button(tree_uuid, url['url_object'].uuid, hash, 'Download the embedded ressource') }} + {{ get_ressource_button(tree_uuid, url['url_object'].uuid, hash, + 'Download the embedded ressource', + details['type'] and details['type'].startswith('image')) }}
{% if enable_context_by_users %} {{ context_form(tree_uuid, url['url_object'].uuid, hostnode_uuid, hash, 'hostnode_popup') }} diff --git a/website/web/templates/macros.html b/website/web/templates/macros.html index f0af7bb4..192ab2c1 100644 --- a/website/web/templates/macros.html +++ b/website/web/templates/macros.html @@ -119,9 +119,14 @@
{% endmacro %} -{% macro get_ressource_button(capture_uuid, urlnode_uuid, hash, text) %} +{% macro get_ressource_button(capture_uuid, urlnode_uuid, hash, text, can_preview=False) %}
- +
{% endmacro %}