{% macro render_row(items) -%}
{% for repo in items %}
{% if loop.index == 1 %}
<div class="card-deck-wrapper">
<div class="card-deck">
{% 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 %}
<div class="card">
<div class="card-block">
<a class="project_link logo_link"
href="{{ url }}">
<div class="repo_name"><strong>{{ repo.name }}</strong></div>
{% if repo.description %}
<div class="repo_desc"><small>{{ repo.description }}</small></div>
{% endif %}
</a>
</div>
</div>
{% if loop.last %}
</div>
</div>
{% elif loop.index is divisibleby(3) or loop.last %}
</div>
</div>
<div class="card-deck-wrapper">
<div class="card-deck">
{% endif %}
{% else %}
<p>No project found</p>
{% endfor %}
{%- endmacro %}
{% macro pagination_link(pagetitle, page, total) -%}
<aside>
<table>
<tr>
<td>
{% if page > 1%}
<a href="{{ url_for('index') }}?{{ pagetitle }}={{page - 1}}">
< Previous
</a>
{% else %}
< Previous
{% endif %}
</td>
<td>{{ page }} / {{ total }}</td>
<td>
{% if page < total %}
<a href="{{ url_for('index') }}?{{ pagetitle }}={{page + 1}}">
Next >
</a>
{% else %}
Next >
{% endif %}
</td>
</tr>
</table>
</aside>
{%- endmacro %}
{% macro render_repos(
list, total, pagetitle, page, title, count, id, username=None, hide=True) %}
<section class="project_list" id="{{ id }}"{%
if g.fas_user and id not in config.get('SHOW_PROJECTS_INDEX', []) and hide
%} style="display:none;" {% endif %}>
<header>
{% set title_lvl = 3 if username else 2 %}
<h{{ title_lvl }}>{{ title }} ({{ count }})</h{{ title_lvl }}>
</header>
{% if total and total > 1 %}
{{ pagination_link(pagetitle, page, total) }}
{% endif %}
<div>
{{ render_row(list) }}
</div>
{% if total and total > 1 %}
{{ pagination_link(pagetitle, page, total) }}
{% endif %}
</section>
{% endmacro %}
{% macro repos_switch(all=True, hide=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"
{%- if (
(all and 'myrepos' in config.get('SHOW_PROJECTS_INDEX', []))
or
(not all and 'repos' not in config.get('SHOW_PROJECTS_INDEX', []))
)
or not hide %} checked {% endif %}/>
<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" {%
if 'myforks' in config.get('SHOW_PROJECTS_INDEX', []) or not hide
%} checked {% endif %}/>
<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" {%
if 'repos' in config.get('SHOW_PROJECTS_INDEX', []) or not hide
%} checked {% endif %}/>
<span class="switch-label" data-on="On" data-off="Off"></span>
<span class="switch-handle"></span>
</label>
{% endif %}
</div>
</aside>
{% endmacro %}