{% extends "master.html" %}
{% block title %}Home{% endblock %}
{%block tag %}home{% endblock %}
{% macro render_row(items) -%}
{% for repo in items %}
{% if loop.index is divisibleby(3) %}
<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.index is divisibleby(3) %}
</div>
{% endif %}
{% else %}
<p>No project found</p>
{% endfor %}
{%- endmacro %}
{% macro render_repos(list, total, page, title) %}
<section class="project_list">
<header>
<h{% if username %}3{% else %}2{% endif %}>{{ title }}</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}}">
< Previous
</a>
{% else %}
< Previous
{% endif %}
</td>
<td>{{ page }} / {{ total }}</td>
<td>
{% if page < total %}
<a href="{{ url_for('index') }}?page={{page + 1}}">
Next >
</a>
{% else %}
Next >
{% endif %}
</td>
</tr>
</table>
</aside>
{% endif %}
<div>
{{ render_row(list) }}
</div>
</section>
{% endmacro %}
{% block content %}
{% if username %}
<h2>{{ username | avatar(36) | safe }} {{ username }}</h2>
{{ render_repos(user_repos, total_page_repos, repopage, 'My Projects') }}
{{ render_repos(user_forks, total_page_forks, forkpage, 'My Forks') }}
{% endif %}
{{ render_repos(repos, total_page, page, 'All Projects') }}
{% endblock %}