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">
        <strong>
            {% if all %}My repos:{% else %}Repos:{% endif %}
        </strong>
        <div class="switch oneline">
            <input type="radio" class="switch-input" name="{% if all %}my{% endif %}repos" value="on" id="myreposon" checked="checked">
            <label for="myreposon" class="switch-label switch-label-off">Show</label>
            <input type="radio" class="switch-input" name="{% if all %}my{% endif %}repos" 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="{% if all %}my{% endif %}forks" value="on" id="forkson" checked="checked">
            <label for="forkson" class="switch-label switch-label-off">Show</label>
            <input type="radio" class="switch-input" name="{% if all %}my{% endif %}forks" 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 %}