<commit_before>{#=== OPTIONS ========================================================================================================#}

{% set option = {
    extensions:  field.extensions|default([]),
    label:       field.label|default(''),
    handler:     field.upload|default('')
}%}

{#=== INIT ===========================================================================================================#}

{% set items = stackitems(7, 'other,document') %}

{% set attr_fileupload = {
    accept:    option.extensions|join('|'),
    data_url:  url('upload',{'handler':option.handler}),
    id:        'fileupload-'~key,
    name:      'fileupload-'~key~'[]',
    type:      'file',
}%}

{#=== BLOCKS =========================================================================================================#}

{% import _self as block %}

{# Modal "select from server" #}
{% macro serverselect(key) %}
    <div class="modal fade" id="selectModal-{{ key }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content"></div>
        </div>
    </div>
{% endmacro %}

{#=== FIELDSET =======================================================================================================#}

<fieldset class="filelist">

    <div class="filelistholder dropzone" id="filelist-{{ key }}">

        <div class="col-sm-12">
            <label class="control-label">{{ macro.infopop(labelkey, 'info.upload.filelist') }}</label>
        </div>

        <div class="col-sm-9">
            <div class="list"></div>
        </div>

        <div class="buttons col-sm-3">
            <div class="btn-group" style="margin: 0 0 6px;">
                <span class="btn btn-info fileinput-button">
                    <i class="fa fa-upload"></i> <span>{{ __('Upload file') }}</span>
                    <input{{ macro.attr(attr_fileupload) }}>
                </span>
            </div>

            <div class="btn-group" style="margin: 0 0 6px;">
                <a data-target="#selectModal-{{ key }}" href="{{ paths.async }}browse/files?key={{ key }}" class="btn btn-tertiary fileinput-select" data-toggle="modal">
                    <i class="fa fa-download"></i> {{ __('Select from server') }}
                </a>
            </div>

            {% if items %}
                <div class="btn-group" style="margin: 0 0 6px;">
                    <a class="btn btn-tertiary dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-paperclip"></i> {{ __('Select from stack') }}
                        <span class="caret"></span>
                    </a>

                    <ul class="dropdown-menu" id="stack-{{ key }}">
                        {% for item in items %}
                            <li>
                                <a href="#" data-action="stack.selectFromPulldown('{{ key }}', '{{ item.filepath }}');">{{ item.basename }} <small>({{ item.filesize }})</small></a>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            {% endif %}

        </div>

        <textarea name="{{ key }}" id="{{ key }}" class="hide">{% if ctx_content.get(key) is defined %}{{ ctx_content.get(key) }}{% endif %}</textarea>

    </div>

    {{ block.serverselect(key) }}

</fieldset>

{#=== SCRIPT =========================================================================================================#}

<script type="text/javascript">
    $(function() {
        if(typeof filelist == "undefined") {
            filelist = [];
        }
        filelist['{{ key }}'] = new FilelistHolder({id: '{{ key }}'});
    });
</script>
<commit_msg>Manually applying fix by @rarila.<commit_after>{#=== OPTIONS ========================================================================================================#}

{% set option = {
    extensions:  field.extensions|default([]),
    label:       field.label|default(''),
    handler:     field.upload|default('')
}%}

{#=== INIT ===========================================================================================================#}

{% set items = stackitems(7, 'other,document') %}

{% set attr_fileupload = {
    accept:    option.extensions|join('|'),
    data_url:  url('upload',{'handler':option.handler}),
    id:        'fileupload-'~key,
    name:      'fileupload-'~key~'[]',
    type:      'file',
}%}

{#=== BLOCKS =========================================================================================================#}

{% import _self as block %}

{# Modal "select from server" #}
{% macro serverselect(key) %}
    <div class="modal fade" id="selectModal-{{ key }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content"></div>
        </div>
    </div>
{% endmacro %}

{#=== FIELDSET =======================================================================================================#}

<fieldset class="filelist">

    <div class="filelistholder dropzone" id="filelist-{{ key }}">

        <div class="col-sm-12">
            <label class="control-label">{{ macro.infopop(labelkey, 'info.upload.filelist') }}</label>
        </div>

        <div class="col-sm-9">
            <div class="list"></div>
        </div>

        <div class="buttons col-sm-3">
            <div class="btn-group" style="margin: 0 0 6px;">
                <span class="btn btn-info fileinput-button">
                    <i class="fa fa-upload"></i> <span>{{ __('Upload file') }}</span>
                    <input{{ macro.attr(attr_fileupload) }}>
                </span>
            </div>

            <div class="btn-group" style="margin: 0 0 6px;">
                <a data-target="#selectModal-{{ key }}" href="{{ paths.async }}browse/files?key={{ key }}" class="btn btn-tertiary fileinput-select" data-toggle="modal">
                    <i class="fa fa-download"></i> {{ __('Select from server') }}
                </a>
            </div>

            {% if items %}
                <div class="btn-group" style="margin: 0 0 6px;">
                    <a class="btn btn-tertiary dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-paperclip"></i> {{ __('Select from stack') }}
                        <span class="caret"></span>
                    </a>

                    <ul class="dropdown-menu" id="stack-{{ key }}">
                        {% for item in items %}
                            <li>
                                <a href="#" data-action="stack.selectFromPulldown('{{ key }}', '{{ item.filepath }}');">{{ item.basename }} <small>({{ item.filesize }})</small></a>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            {% endif %}

        </div>

        <textarea name="{{ key }}" id="{{ key }}" class="hide">{% if ctx_content.get(key) is defined %}{{ ctx_content.get(key)|json_encode() }}{% endif %}</textarea>

    </div>

    {{ block.serverselect(key) }}

</fieldset>

{#=== SCRIPT =========================================================================================================#}

<script type="text/javascript">
    $(function() {
        if(typeof filelist == "undefined") {
            filelist = [];
        }
        filelist['{{ key }}'] = new FilelistHolder({id: '{{ key }}'});
    });
</script>

{'fraction_non_alphanumeric': 0.312099358974359, 'fraction_numerical': 0.004006410256410256, 'mean_word_length': 2.397912885662432, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5443112', 'n_tokens_mistral': 2166, 'n_tokens_neox': 1951, 'n_words': 404}