<commit_before>{% macro get_attachment_icon(attachment) -%}
    {%- if attachment.type.name == 'link' -%}
        icon-link
    {%- else -%}
        {{ icon_from_mimetype(attachment.file.content_type, 'icon-file-empty2') }}
    {%- endif -%}
{%- endmacro %}

{% macro _attachment_row(attachment) %}
    <tr>
        <td>
            <a href="{{ attachment.download_url }}" target="_blank" class="{{ get_attachment_icon(attachment) }}">
                {{ attachment.title }}
            </a>
        </td>
        <td class="actions">
            <a class="icon-edit js-dialog-action"
               data-href="{{ url_for('.modify_attachment', attachment) }}"
               data-title="{% trans name=attachment.title %}Edit attachment {{ name }}{% endtrans %}"></a>
            <a href="#" class="icon-remove js-delete"
               data-method="DELETE"
               data-href="{{ url_for('.delete_attachment', attachment) }}"
               data-title="{% trans name=attachment.title %}Remove {{ name }}?{% endtrans %}"
               data-confirm="{% trans name=attachment.title -%}
                   Are you sure you want to remove &quot;{{ name }}&quot;?<br>
                   This will remove the attachment permanantly.
                   {%- endtrans %}">
            </a>
        </td>
        <td class="date">{{ attachment.modified_dt|format_datetime('short') }}</td>
    </tr>
{% endmacro %}

{% macro _folder_row(folder) -%}
    <tr class="expandable {%- if not folder.attachments %} collapsed{% endif %}">
        <td>
            <span> {{ folder.title }}</span>
        </td>
        <td class="actions">
            <a class="icon-edit js-dialog-action"
                       data-href="{{ url_for('.edit_folder', folder) }}"
                       data-title="{% trans name=folder.title %}Edit folder: {{ name }}{% endtrans %}"></a>
            <a href="#" class="icon-remove js-delete"
               data-method="DELETE"
               data-href="{{ url_for('.delete_folder', folder) }}"
               data-title="{% trans name=folder.title %}Remove {{ name }}?{% endtrans %}"
               data-confirm="{% trans name=folder.title -%}
                   Are you sure you want to remove &quot;{{ name }}&quot;?<br>
                   This will remove the folder and its contents permanantly.
               {%- endtrans %}">
            </a>
        </td>
        <td></td>
    </tr>
    <tr class="sub-tree">
        <td colspan="3">
            {# Div to have a smooth slide up and down of the sub-tree #}
            <div {%- if not folder.attachments %} style="display: none;"{% endif %}>
                <table class="tree">
                {{- _render_tree(folder.attachments, false) -}}
                </table>
            </div>
        </td>
    </tr>
{%- endmacro %}

{% macro _render_tree(nodes, is_folder) -%}
    {%- for sub_node in nodes -%}
        {% if is_folder %}
            {{ _folder_row(sub_node) }}
        {% else %}
            {{ _attachment_row(sub_node) }}
        {% endif %}
    {%- else -%}
        <tr class="empty">
            <td colspan="3"> {% trans %}empty folder{% endtrans %}</td>
        </tr>
    {%- endfor -%}
{%- endmacro %}

{% macro render_attachments(attachments, linked_object) -%}
    {%- if attachments -%}
        <table class="tree">
            {%- if attachments.folders -%}
                {{ _render_tree(attachments.folders, true) }}
            {%- endif -%}
            {%- if attachments.files -%}
                {{ _render_tree(attachments.files, false) }}
            {%- endif -%}
        </table>
    {%- else -%}<commit_msg>Show top-level files before folders<commit_after>{% macro get_attachment_icon(attachment) -%}
    {%- if attachment.type.name == 'link' -%}
        icon-link
    {%- else -%}
        {{ icon_from_mimetype(attachment.file.content_type, 'icon-file-empty2') }}
    {%- endif -%}
{%- endmacro %}

{% macro _attachment_row(attachment) %}
    <tr>
        <td>
            <a href="{{ attachment.download_url }}" target="_blank" class="{{ get_attachment_icon(attachment) }}">
                {{ attachment.title }}
            </a>
        </td>
        <td class="actions">
            <a class="icon-edit js-dialog-action"
               data-href="{{ url_for('.modify_attachment', attachment) }}"
               data-title="{% trans name=attachment.title %}Edit attachment {{ name }}{% endtrans %}"></a>
            <a href="#" class="icon-remove js-delete"
               data-method="DELETE"
               data-href="{{ url_for('.delete_attachment', attachment) }}"
               data-title="{% trans name=attachment.title %}Remove {{ name }}?{% endtrans %}"
               data-confirm="{% trans name=attachment.title -%}
                   Are you sure you want to remove &quot;{{ name }}&quot;?<br>
                   This will remove the attachment permanantly.
                   {%- endtrans %}">
            </a>
        </td>
        <td class="date">{{ attachment.modified_dt|format_datetime('short') }}</td>
    </tr>
{% endmacro %}

{% macro _folder_row(folder) -%}
    <tr class="expandable {%- if not folder.attachments %} collapsed{% endif %}">
        <td>
            <span> {{ folder.title }}</span>
        </td>
        <td class="actions">
            <a class="icon-edit js-dialog-action"
                       data-href="{{ url_for('.edit_folder', folder) }}"
                       data-title="{% trans name=folder.title %}Edit folder: {{ name }}{% endtrans %}"></a>
            <a href="#" class="icon-remove js-delete"
               data-method="DELETE"
               data-href="{{ url_for('.delete_folder', folder) }}"
               data-title="{% trans name=folder.title %}Remove {{ name }}?{% endtrans %}"
               data-confirm="{% trans name=folder.title -%}
                   Are you sure you want to remove &quot;{{ name }}&quot;?<br>
                   This will remove the folder and its contents permanantly.
               {%- endtrans %}">
            </a>
        </td>
        <td></td>
    </tr>
    <tr class="sub-tree">
        <td colspan="3">
            {# Div to have a smooth slide up and down of the sub-tree #}
            <div {%- if not folder.attachments %} style="display: none;"{% endif %}>
                <table class="tree">
                {{- _render_tree(folder.attachments, false) -}}
                </table>
            </div>
        </td>
    </tr>
{%- endmacro %}

{% macro _render_tree(nodes, is_folder) -%}
    {%- for sub_node in nodes -%}
        {% if is_folder %}
            {{ _folder_row(sub_node) }}
        {% else %}
            {{ _attachment_row(sub_node) }}
        {% endif %}
    {%- else -%}
        <tr class="empty">
            <td colspan="3"> {% trans %}empty folder{% endtrans %}</td>
        </tr>
    {%- endfor -%}
{%- endmacro %}

{% macro render_attachments(attachments, linked_object) -%}
    {%- if attachments -%}
        <table class="tree">
            {%- if attachments.files -%}
                {{ _render_tree(attachments.files, false) }}
            {%- endif -%}
            {%- if attachments.folders -%}
                {{ _render_tree(attachments.folders, true) }}
            {%- endif -%}
        </table>
    {%- else -%}
{'fraction_non_alphanumeric': 0.1765758326451968, 'fraction_numerical': 0.0008257638315441783, 'mean_word_length': 1.7971516551193225, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6716047', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2079, 'n_words': 466}