mirror of https://github.com/CIRCL/lookyloo
new: center tree on landing page
parent
861760203e
commit
f0c7e42bd9
|
@ -342,8 +342,8 @@ def send_mail(tree_uuid: str):
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tree/<string:tree_uuid>', methods=['GET'])
|
@app.route('/tree/<string:tree_uuid>', methods=['GET'])
|
||||||
@app.route('/tree/<string:tree_uuid>/<string:urlnode_uuid>', methods=['GET'])
|
@app.route('/tree/<string:tree_uuid>/<string:node_uuid>', methods=['GET'])
|
||||||
def tree(tree_uuid: str, urlnode_uuid: Optional[str]=None):
|
def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
if tree_uuid == 'False':
|
if tree_uuid == 'False':
|
||||||
flash("Unable to process your request. The domain may not exist, or splash isn't started", 'error')
|
flash("Unable to process your request. The domain may not exist, or splash isn't started", 'error')
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
@ -366,6 +366,22 @@ def tree(tree_uuid: str, urlnode_uuid: Optional[str]=None):
|
||||||
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
|
screenshot_size = lookyloo.get_screenshot(tree_uuid).getbuffer().nbytes
|
||||||
meta = lookyloo.get_meta(tree_uuid)
|
meta = lookyloo.get_meta(tree_uuid)
|
||||||
|
hostnode_to_highlight = None
|
||||||
|
if node_uuid:
|
||||||
|
try:
|
||||||
|
urlnode = ct.root_hartree.get_url_node_by_uuid(node_uuid)
|
||||||
|
if urlnode:
|
||||||
|
hostnode_to_highlight = urlnode.hostnode_uuid
|
||||||
|
except IndexError:
|
||||||
|
# node_uuid is not a urlnode, trying a hostnode
|
||||||
|
try:
|
||||||
|
hostnode = ct.root_hartree.get_host_node_by_uuid(node_uuid)
|
||||||
|
if hostnode:
|
||||||
|
hostnode_to_highlight = hostnode.uuid
|
||||||
|
except IndexError as e:
|
||||||
|
print(e)
|
||||||
|
pass
|
||||||
|
|
||||||
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,
|
||||||
|
@ -376,7 +392,7 @@ def tree(tree_uuid: str, urlnode_uuid: Optional[str]=None):
|
||||||
enable_context_by_users=enable_context_by_users,
|
enable_context_by_users=enable_context_by_users,
|
||||||
enable_categorization=enable_categorization,
|
enable_categorization=enable_categorization,
|
||||||
enable_bookmark=enable_bookmark,
|
enable_bookmark=enable_bookmark,
|
||||||
blur_screenshot=blur_screenshot, urlnode_uuid=urlnode_uuid,
|
blur_screenshot=blur_screenshot, urlnode_uuid=hostnode_to_highlight,
|
||||||
auto_trigger_modules=auto_trigger_modules,
|
auto_trigger_modules=auto_trigger_modules,
|
||||||
has_redirects=True if cache.redirects else False)
|
has_redirects=True if cache.redirects else False)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ let height = menuHeight * 2;
|
||||||
|
|
||||||
let node_width = 10;
|
let node_width = 10;
|
||||||
let node_height = 55;
|
let node_height = 55;
|
||||||
|
let center_node = null;
|
||||||
|
|
||||||
let main_svg = d3.select("body").append("svg")
|
let main_svg = d3.select("body").append("svg")
|
||||||
.attr("width", width + margin.right + margin.left)
|
.attr("width", width + margin.right + margin.left)
|
||||||
|
@ -478,6 +479,7 @@ function update(root, computed_node_width=0) {
|
||||||
|
|
||||||
const thumbnail_size = 64;
|
const thumbnail_size = 64;
|
||||||
if (d.data.contains_rendered_urlnode) {
|
if (d.data.contains_rendered_urlnode) {
|
||||||
|
center_node = d.data.uuid;
|
||||||
d3.select(this).append("svg").append('rect')
|
d3.select(this).append("svg").append('rect')
|
||||||
.attr('x', selected_node_bbox.width/3)
|
.attr('x', selected_node_bbox.width/3)
|
||||||
.attr('y', node_height - 3)
|
.attr('y', node_height - 3)
|
||||||
|
|
|
@ -66,14 +66,19 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% if urlnode_uuid %}
|
|
||||||
<script>
|
<script>
|
||||||
|
{% if urlnode_uuid %}
|
||||||
history.scrollRestoration = "manual";
|
history.scrollRestoration = "manual";
|
||||||
window.addEventListener('DOMContentLoaded', (event) => {
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
PermanentNodeHighlight('{{urlnode_uuid}}');
|
LocateNode('{{urlnode_uuid}}');
|
||||||
|
});
|
||||||
|
{% else %}
|
||||||
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
let element = document.getElementById(`node_${center_node}`);
|
||||||
|
element.scrollIntoView({behavior: "smooth", block: "center", inline: "center"});
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
{% endif%}
|
{% endif%}
|
||||||
|
</script>
|
||||||
|
|
||||||
{% if auto_trigger_modules %}
|
{% if auto_trigger_modules %}
|
||||||
<script>
|
<script>
|
||||||
|
|
Loading…
Reference in New Issue