Blob Blame Raw
{% macro render_row(items) -%}
    {% for repo in items %}
        {% if loop.index == 1 %}
    <div class="project_row">
        {% endif %}
        <a class="project_link"
            href="{{ url_for('view_repo', repo=repo.name) }}" class="logo_link"
            style="background-image: url({{ url_for("static", filename="placebo.png") }})">
            {# TODO: get project logo #}
            <span class="repo_name">{{ repo.name }}</span>
            {% if repo.description %}
            <span class="repo_desc">{{ repo.description | wraps(20) }}</span>
            {% endif %}
        </a>
        {% if loop.last %}
    </div>
        {% elif loop.index is divisibleby(3) or loop.last %}
    </div>
    <div class="project_row">
        {% endif %}
    {% else %}
    <p>No project found</p>
    {% endfor %}
{%- endmacro %}


{% macro render_repos(list, total, page, title, count, id) %}
<section class="project_list" id="{{ id }}">
        <header>
            <h{% if username %}3{% else %}2{% endif %}>{{ title }} ({{ count }})</h{% if username %}3{% else %}2{% endif %}>
        </header>
        {% if total and total > 1 %}
        <aside>
            <table>
                <tr>
                    <td>
                    {% if page > 1%}
                        <a href="{{ url_for('index') }}?page={{page - 1}}">
                            &lt; Previous
                        </a>
                    {% else %}
                        &lt; Previous
                    {% endif %}
                    </td>
                    <td>{{ page }} / {{ total }}</td>
                    <td>
                        {% if page < total %}
                        <a href="{{ url_for('index') }}?page={{page + 1}}">
                            Next &gt;
                        </a>
                        {% else %}
                        Next >
                        {% endif %}
                    </td>
                </tr>
            </table>
        </aside>
        {% endif %}
        <div>
            {{ render_row(list) }}
        </div>
    </section>
{% endmacro %}


{% macro repos_switch(all = True) %}
    <aside class="show_parts">
        <strong>My repos:</strong>
        <div class="switch oneline">
            <input type="radio" class="switch-input" name="myrepos" value="on" id="myreposon" checked="checked">
            <label for="myreposon" class="switch-label switch-label-off">Show</label>
            <input type="radio" class="switch-input" name="myrepos" value="off" id="myreposoff">
            <label for="myreposoff" class="switch-label switch-label-on">Hide</label>
            <span class="switch-selection"></span>
        </div>
        <strong>Forks:</strong>
        <div class="switch oneline">
            <input type="radio" class="switch-input" name="myforks" value="on" id="forkson" checked="checked">
            <label for="forkson" class="switch-label switch-label-off">Show</label>
            <input type="radio" class="switch-input" name="myforks" value="off" id="forksoff">
            <label for="forksoff" class="switch-label switch-label-on">Hide</label>
            <span class="switch-selection"></span>
        </div>
        {% if all %}
        <strong>All repos:</strong>
        <div class="switch oneline">
            <input type="radio" class="switch-input" name="repos" value="on" id="reposon" checked="checked">
            <label for="reposon" class="switch-label switch-label-off">Show</label>
            <input type="radio" class="switch-input" name="repos" value="off" id="reposoff">
            <label for="reposoff" class="switch-label switch-label-on">Hide</label>
            <span class="switch-selection"></span>
        </div>
        {% endif %}
    </aside>
{% endmacro %}