chg: More macros

pull/78/head
Raphaël Vinot 2020-07-15 18:04:34 +02:00
parent 419fe7408b
commit c7db7829a7
4 changed files with 12 additions and 13 deletions

View File

@ -759,12 +759,6 @@ class Lookyloo():
'url_object': url
}
# If the url path is too long, we want to limit it to 60 chars
if len(to_append['url_path']) > 50:
to_append['url_path_short'] = to_append['url_path'][:60] + ' [...]'
else:
to_append['url_path_short'] = to_append['url_path']
if not url.empty_response:
# Index lookup
# %%% Full body %%%

View File

@ -3,6 +3,7 @@
{% from "macros.html" import indexed_hash %}
{% from "macros.html" import indexed_cookies %}
{% from "macros.html" import popup_icons %}
{% from "macros.html" import shorten_string %}
{% block title %}Details for {{ hostname }} {% endblock %}
@ -77,7 +78,7 @@
</svg>
{%endif%}
{# URL #}
... /{{ url['url_path_short'] }}
... /{{ shorten_string(url['url_path'], 50)}}
</div>
<ul class="list-group">
<li class="list-group-item">

View File

@ -103,3 +103,11 @@ The same file was seen in <b>{{ total_captures }}</b> other captures.
{% endfor %}
</div>
{% endmacro %}
{% macro shorten_string(string, cut_length) %}
{% if string|length > cut_length %}
{{ string[:cut_length] }} [...]
{% else %}
{{ string }}
{%endif%}
{% endmacro %}

View File

@ -1,6 +1,7 @@
{% extends "main.html" %}
{% from 'bootstrap/utils.html' import render_messages %}
{% from "macros.html" import shorten_string %}
{% block title %}Tree{% endblock %}
@ -143,12 +144,7 @@
</center>
</div>
<hr/>
<b>Root URL</b>:
{% if root_url|length > 150 %}
{{ root_url[:150] }} [...]
{% else %}
{{ root_url}}
{% endif %}
<b>Root URL</b>: {{ shorten_string(root_url, 150) }}
<br>
<b>Start time</b>: {{ start_time }}<br>
<b>User Agent</b>: {{ user_agent }}<br>