{% 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) %}
<section class="project_list">
{% if total and total > 1 %}
<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>
{% endif %}
{{ render_row(list) }}
</section>
{% endmacro %}
{% block content %}
{% if username %}
<h2>{{ username | avatar(36) | safe }} {{ username }}</h2>
<h3>Projects</h3>
{{ render_repos(user_repos, total_page_repos, repopage) }}
<h3>Forks</h3>
{{ render_repos(user_forks, total_page_forks, forkpage) }}
{% else %}
<h2>Projects</h2>
{{ render_repos(repos, total_page, page) }}
{% endif %}
{% endblock %}