chg: Better handling of big screenshots

pull/156/head
Raphaël Vinot 2021-01-18 14:19:19 +01:00
parent f9d8081efa
commit 1da32c404e
2 changed files with 4 additions and 2 deletions

View File

@ -364,12 +364,14 @@ def tree(tree_uuid: str, urlnode_uuid: Optional[str]=None):
ct = lookyloo.get_crawled_tree(tree_uuid) ct = lookyloo.get_crawled_tree(tree_uuid)
ct = lookyloo.context.contextualize_tree(ct) ct = lookyloo.context.contextualize_tree(ct)
b64_thumbnail = lookyloo.get_screenshot_thumbnail(tree_uuid, for_datauri=True) b64_thumbnail = lookyloo.get_screenshot_thumbnail(tree_uuid, for_datauri=True)
screenshot_size = lookyloo.get_screenshot(tree_uuid).getbuffer().nbytes
meta = lookyloo.get_meta(tree_uuid) meta = lookyloo.get_meta(tree_uuid)
return render_template('tree.html', tree_json=ct.to_json(), return render_template('tree.html', tree_json=ct.to_json(),
start_time=ct.start_time.isoformat(), start_time=ct.start_time.isoformat(),
user_agent=ct.user_agent, root_url=ct.root_url, user_agent=ct.user_agent, root_url=ct.root_url,
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain, tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
screenshot_thumbnail=b64_thumbnail, page_title=cache.title, screenshot_thumbnail=b64_thumbnail, page_title=cache.title,
screenshot_size=screenshot_size,
meta=meta, enable_mail_notification=enable_mail_notification, meta=meta, enable_mail_notification=enable_mail_notification,
enable_context_by_users=enable_context_by_users, enable_context_by_users=enable_context_by_users,
enable_categorization=enable_categorization, enable_categorization=enable_categorization,

View File

@ -321,8 +321,8 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<center> <center>
{% if screenshot_thumbnail == '' %} {% if screenshot_size > 10 * 1024 * 1024 %}
Image too big to display in the browser, <a href="{{ url_for('image', tree_uuid=tree_uuid) }}" role="button">click here to download it</a>. Image too big ({{ sizeof_fmt(screenshot_size) }}) to display in the browser, <a href="{{ url_for('image', tree_uuid=tree_uuid) }}" role="button">click here to download it</a>.
{% else %} {% else %}
{% if blur_screenshot %} {% if blur_screenshot %}
<button type="button" class="btn btn-info" onclick="$('#screenshot').removeClass('blur')"> Unblur screenshot</button> <button type="button" class="btn btn-info" onclick="$('#screenshot').removeClass('blur')"> Unblur screenshot</button>