RSS Git Download  Clone
Raw Blame History
{% extends 'layout-page.twig' %}

{% set page = 'files' %}

{% block title %}P3X GitList{% endblock %}


{% block content %}

    {% embed 'breadcrumb.twig' with {breadcrumbs: breadcrumbs } %}
        {% block left %}
            <div class="p3x-gitlist-button">
                <button type="button" class="btn btn-sm btn-info" id="p3x-gitlist-tree-new-file">
                    <i class="far fa-file-alt"></i> New file or directory
                </button>

                {% embed 'modal/modal-commit.twig' with {type: 'new', title: 'New file', bodyTitle: 'Are you sure to add a new file or directory?<br/><strong>If you add a slash to the end of the "filename", you create a directory, otherwise you create a file. <br/>Please, make sure you use a relative path.</strong><br/><br/><span style="text-decoration: underline;">Note:</span> The filename is not created on the current tree browser you are, but that actual root of the repo.', wrapForm: true } %}
                    {% block form %}

                        <div class="input-group">
                                            <span class="input-group-addon"
                                                  id="p3x-gitlist-modal-{{ type }}-filename-aria"><i
                                                    class="far fa-file-alt"></i></span>
                            <input required type="text" class="form-control" placeholder="New filename or directory"
                                   aria-describedby="p3x-gitlist-modal-{{ type }}-filename-aria"
                                   id="p3x-gitlist-modal-{{ type }}-filename" minlength="1" maxlength="128"
                                   value="">
                        </div>
                        <br/>
                    {% endblock %}
                    {% block buttons %}


                        <button id="p3x-gitlist-modal-new-filename-confirm" type="submit" class="btn btn-info">
                            <span class="far fa-file-alt"></span>
                            New file or directory
                        </button>
                    {% endblock %}
                {% endembed %}


                <button type="button" class="btn btn-sm btn-info" id="p3x-gitlist-tree-new-binary">
                    <i class="far fa-file"></i> Upload file and/or override/binary
                </button>

                {% embed 'modal/modal-commit.twig' with {enctype: 'multipart/form-data', type: 'new-binary', title: 'New binary', bodyTitle: 'Are you sure to add a new binary file?', wrapForm: true } %}
                    {% block form %}
                        <div class="input-group">

                            <input required type="file" class="form-control-file" placeholder="New binary filename"
                                   aria-describedby="p3x-gitlist-modal-{{ type }}-filename-binary-upload-aria"
                                   id="p3x-gitlist-modal-{{ type }}-filename-binary-upload">
                        </div>
                        <div class="checkbox">
                            <label><input id="p3x-gitlist-modal-{{ type }}-filename-binary-override" type="checkbox"
                                          value="1">Allow override existing</label>
                        </div>

                        <div class="input-group">
                                            <span class="input-group-addon"
                                                  id="p3x-gitlist-modal-{{ type }}-filename-binary-aria"><i
                                                    class="far fa-file"></i></span>
                            <input required type="text" class="form-control" placeholder="New binary filename"
                                   aria-describedby="p3x-gitlist-modal-{{ type }}-filename-binary-aria"
                                   id="p3x-gitlist-modal-{{ type }}-filename-binary" minlength="1" maxlength="128"
                                   value="">
                        </div>
                        <br/>



                    {% endblock %}
                    {% block buttons %}

                        <button id="p3x-gitlist-modal-new-filename-binary-confirm" type="submit" class="btn btn-info">
                            <span class="far fa-file"></span>
                            Upload file and/or override/binary
                        </button>

                    {% endblock %}
                {% endembed %}

            </div>


        {% endblock %}

    {% endembed %}

    {% if files is not empty %}
        <table class="table table-striped table-hover" id="p3x-gitlist-tree-table">
            <thead>
<!--
            <tr>
                <th width="35%">Name</th>
                <th width="15%" style="text-align: right;">Size</th>
                <th width="35%" style="text-align: left;">Message</th>
                <th width="15%" style="text-align: right;">Modified</th>
            </tr>

-->
            <tr>
                <th width="15%"></th>
                <th width="15%" style="text-align: right;"></th>
                <th width="55%" style="text-align: left;"></th>
                <th width="15%" style="text-align: right;"></th>
            </tr>

            </thead>
            <tbody>
            {% if parent is not null %}
                <tr style="cursor: pointer">
                    {% if not parent %}
                        <td colspan="4" onclick='location.href = "{{ path('branch', {repo: repo, branch: branch}) }}"'>
                            <a href="{{ path('branch', {repo: repo, branch: branch}) }}">..</a>
                        </td>
                    {% else %}
                        <td colspan="4" onclick='location.href = "{{ path('tree', {repo: repo, commitishPath: branch ~ '/' ~ parent}) }}"'>
                            <a href="{{ path('tree', {repo: repo, commitishPath: branch ~ '/' ~ parent}) }}">..</a>
                        </td>
                    {% endif %}
                </tr>
            {% endif %}
            {% for file in files %}
                <tr>
                    <td nowrap>
                        {%- if file.type == "folder" or file.type == "symlink" -%}
                            <span class="fas fa-folder"></span>
                            &nbsp;
                            <a href="{{ path('tree', {repo: repo, commitishPath: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}">{{ file.name }}</a>

                        {%- elseif file.type == "module" -%}
                            <span class="fas fa-folder-open"></span>
                            &nbsp;
                            <a title="Head: {{ head }}" href="{{ file.url }}/tree/{{ head }}">{{ file.name }}</a>
                            @
                            <a title="Commit: {{ file.hash }}"
                               href="{{ file.url }}/tree/{{ file.hash }}">{{ file.shortHash }}</a>

                        {%- else -%}
                            <span class="far fa-file-alt"></span>
                            &nbsp;
                            <a href="{{ path('blob', {repo: repo, commitishPath: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}">{{ file.name }}</a>

                        {%- endif -%}
                        </a>


                    </td>
                    <td class="p3x-gitlist-tree-table-item" style="text-align: right;" title="{% if file.size %}{{ (file.size / 1024) | number_format | htmlentities}} kb{% endif %}">
                        {% if file.size %}
                            {{ file.size | format_size }}
                        {% endif %}
                    </td>
                    <td class="p3x-gitlist-tree-table-item p3x-gitlist-tree-table-item-message" title="{{ file.message | htmlentities }}">
                        {{ file.message }}
                    </td>
                    <td class="p3x-gitlist-tree-table-item"  style="text-align: right;" title="{{ file.lastModified | htmlentities }}" >
                        {{ file.lastModified }}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>This repository is empty.</p>
    {% endif %}
    {% if readme is defined and readme is not empty %}
        {% include 'markdown.twig' with {'filename': readme.filename, 'data': readme.content} %}
    {% endif %}


{% endblock %}