Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
chore: Refactored result.html to conditionally display tabs and headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dikayx committed Aug 8, 2024
1 parent 0c1bfb7 commit 39ecdbf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ The result section displays the structured information extracted from the email
- **Content**: A chronological course of the email content (= messages).
- **Attachments**: A list of attachments included in the email.

The tabs are only shown, if the corresponding information is available in the email data. For example, if the email does not contain any attachments, the "Attachments" tab will not be displayed.

You can download the attachments directly from the application by clicking on the download button next to the attachment name. However, not all attachments can be downloaded directly from the application. In such cases, just the name of the attachment will be displayed.

## Limitations
Expand Down
46 changes: 34 additions & 12 deletions mapy/templates/result.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- templates/result_display.html -->
<div class="card p-3">
<div class="row pt-3">
<div class="col-md-6">
Expand Down Expand Up @@ -107,6 +106,7 @@ <h2>Geolocation Map</h2>
</div>
{% endif %}

{% if security_headers %}
<div class="card mt-3">
<div class="card-header">
<h3 class="card-title">Security Headers</h3>
Expand All @@ -122,40 +122,64 @@ <h3 class="card-title">Security Headers</h3>
</table>
</div>
</div>
{% endif %}

{# Filter X-Headers #}
{% set x_headers = [] %}

{% for k, v in headers.items() %}
{% if k.startswith('X-') %}
{% set _ = x_headers.append((k, v)) %}
{% endif %}
{% endfor %}

{# Conditionally Display X-Headers Card #}
{% if x_headers %}
<div class="card mt-3">
<div class="card-header">
<h3 class="card-title">X-Headers</h3>
</div>
<div class="table-responsive">
<table class="table table-bordered">
{% for k, v in headers.items() %} {% if k.startswith('X-') %}
{% for k, v in x_headers %}
<tr>
<th>{{ k }}</th>
<td>{{ v }}</td>
</tr>
{% endif %} {% endfor %}
{% endfor %}
</table>
</div>
</div>
{% endif %}

{# Filter 'Other' Headers #}
{% set excluded_headers = ['Received', 'Subject', 'From', 'To', 'Message-ID', 'CC', 'Date'] %}
{% set other_headers = [] %}

{% for k, v in headers.items() %}
{% if k not in excluded_headers and k not in security_headers and not k.startswith('X-') %}
{% set _ = other_headers.append((k, v)) %}
{% endif %}
{% endfor %}

{# Conditionally Display 'Other' Headers Card #}
{% if other_headers %}
<div class="card mt-3">
<div class="card-header">
<h3 class="card-title">Other headers</h3>
<h3 class="card-title">Other Headers</h3>
</div>
<div class="table-responsive">
<table class="table table-bordered">
{% for k, v in headers.items() %} {% if k not in ['Received',
'Subject', 'From', 'To', 'Message-ID', 'CC', 'Date'] and k not in
security_headers and not k.startswith('X-') %}
{% for k, v in other_headers %}
<tr>
<th>{{ k }}</th>
<td>{{ v }}</td>
</tr>
{% endif %} {% endfor %}
{% endfor %}
</table>
</div>
</div>
{% endif %}

{% if messages %}
<div class="card mt-3">
Expand Down Expand Up @@ -202,14 +226,12 @@ <h5 class="card-title">Attachments</h5>
href="{{ attachment.download_url }}"
download="{{ attachment.filename }}"
>
{{ attachment.filename }} (Size: {{ attachment.length }}
bytes)
{{ attachment.filename }} (Size: {{ attachment.length }} bytes)
</a>
</li>
{% else %}
<li>
{{ attachment.filename }} (Size: {{ attachment.length }}
bytes)
{{ attachment.filename }} (Size: {{ attachment.length }} bytes)
<span
title="Size 0 means the file could not be extracted (e.g. password protected, encrypted, etc.)"
style="border-bottom: 1px dotted; cursor: help"
Expand Down

0 comments on commit 39ecdbf

Please sign in to comment.