Blob Blame Raw
{% macro render_row(items) -%}
    {% for repo in items %}
        {% if loop.index == 1 %}
    <div class="project_row">
        {% endif %}
        {% if repo.is_fork %}
        {% set url = url_for('view_repo', username=repo.user.username, repo=repo.name) %}
        {% else %}
        {% set url = url_for('view_repo', repo=repo.name) %}
        {% endif %}
        <a class="project_link logo_link"
            href="{{ url }}"
            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, username=None) %}
<section class="project_list" id="{{ id }}">
        <header>
            {% set title_lvl = 3 if username else 2 %}
            <h{{ title_lvl }}>{{ title }} ({{ count }})</h{{ title_lvl }}>
        </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">
        <div class="container">
        <strong>
            {% if all %}My repos:{% else %}Repos:{% endif %}
        </strong>

            <label class="switch">
                <input type="checkbox" class="switch-input"
                    name="{% if all %}my{% endif %}repos" checked>
                <span class="switch-label" data-on="On" data-off="Off"></span>
                <span class="switch-handle"></span>
            </label>
        <strong>Forks:</strong>
            <label class="switch">
                <input type="checkbox" class="switch-input"
                    name="{% if all %}my{% endif %}forks" checked>
                <span class="switch-label" data-on="On" data-off="Off"></span>
                <span class="switch-handle"></span>
            </label>
        {% if all %}
        <strong>All repos:</strong>
            <label class="switch">
                <input type="checkbox" class="switch-input"
                    name="repos" id="allrepos" checked />
                <span class="switch-label" data-on="On" data-off="Off"></span>
                <span class="switch-handle"></span>
            </label>
        {% endif %}
        </div>
    </aside>
{% endmacro %}