Blob Blame History Raw
{% macro render_row(items) -%}
    {% for repo in items %}
        {% 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="col-lg-4 col-md-6">
    <div class="project_wrapper m-b-1">
            {% if repo.avatar_email %}

            <img class="projecticon pull-xs-left" src="{{ repo.avatar_email | avatar_url }}" width=60 height=60 />

            {% else %}
            <div class="projecticon pull-xs-left"><span class="oi" data-glyph="document"></span></div>
            {% endif %}
        <a class="project_link logo_link" href="{{ url }}">
            <div class="repo_name"><strong>{{ repo.name }}</strong></div>
       </a>
       <div class="repo_desc" title="{{ repo.description }}" data-toggle="tooltip">
        <small>{% if repo.description %}{{ repo.description }}{%else%}<span class="text-muted">no description<span>{% endif %}</small>
      </div>
      <div class="project_metadata">
        <div style="text-align:right;" class="p-r-1 text-muted"><span class="oi" data-glyph="fork"></span>{{repo.forks|count}}</div>
      </div>
    </div>
  </div>
    {% else %}
<p>No projects found</p>
    {% endfor %}
{%- endmacro %}


{% macro pagination_link(pagetitle, page, total) -%}
<aside>
    <nav class="text-center">
      <ul class="pagination">
        <li {% if page <= 1%} class="disabled" {% endif %}>
          <a href="{{ request.base_url }}?{{ pagetitle }}={{page - 1}}">
            <span aria-hidden="true">&laquo;</span>
            <span class="sr-only">Newer</span>
          </a>
        </li>
        <li class="active">page {{ page }} of {{ total }}</li>
        <li {% if page >= total %}class="disabled"{%endif%}>
          <a href="{{ request.base_url }}?{{ pagetitle }}={{page + 1}}">
            <span aria-hidden="true">&raquo;</span>
            <span class="sr-only">Older</span>
          </a>
        </li>
      </ul>
    </nav>
</aside>
{%- endmacro %}


{% macro render_repos(
        list, total, pagetitle, page, title, count, id,
        username=None, hide=True) %}

    <section class="project_list container p-t-2" id="{{ id }}">
        <h2 class=" m-b-1">{{
            title
            }} <span class="label label-default">{{ count }}</span>
            {%- if username -%}
            <a href="{{ url_for('new_project') }}">
            <button type="button" class="btn btn-success pull-xs-right">
              New Project
            </button>
            </a>
            {%- endif -%}
        </h2>
        {% if total and total > 1 %}
        {{ pagination_link(pagetitle, page, total) }}
        {% endif %}
        <div class="row">
            {{ render_row(list) }}
        </div>
        {% if total and total > 1 %}
        {{ pagination_link(pagetitle, page, total) }}
        {% endif %}
    </section>
{% endmacro %}

{% macro render_user_repos(
        list, total, pagetitle, page, title, count, id, username=None, hide=True) %}
      <div class="card" id="{{ id }}">
          <div class="card-header">
              {{ title }} <span class="label label-default">{{ count }}</span>
          </div>
          {% if total and total > 1 %}
          {{ pagination_link(pagetitle, page, total) }}
          {% endif %}
          <div class="card-block">

                    {% for repo in list %}
                        {% 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 }}">
                            <div><strong>{{ repo.name }}</strong></div>
                       </a>
                    {% else %}
                <p>No projects found</p>
                    {% endfor %}

          </div>
          {% if total and total > 1 %}
          {{ pagination_link(pagetitle, page, total) }}
          {% endif %}
      </div>
{% 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 %}

{% macro render_repos_as_card(list, total, name, pagetitle, page, total_page) %}
        {% if total_page and total_page > 1 %}
        {{ pagination_link(pagetitle, page, total_page) }}
        {% endif %}
        <div class="card">
          <div class="card-header">
            {{name}} <span class="label label-default">{{total}}</span>
          </div>
          {% if list %}
            <div class="list-group">
            {% for repo in list %}
              <div class="list-group-item">
                {% 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 %}

                {% if repo.avatar_email %}
                  <img class="projecticon pull-xs-left" src="{{ repo.avatar_email | avatar_url }}" width=60 height=60 />
                {% else %}
                    <div class="projecticon pull-xs-left"><span class="oi" data-glyph="document"></span></div>
                {% endif %}
                <a class="project_link logo_link" href="{{ url }}">
                    <div class="repo_name">
                      <strong>{{ repo.name }}</strong>
                    </div>
                </a>
                <div class="repo_desc" title="{{ repo.description }}" data-toggle="tooltip">
                  <small>{% if repo.description %}{{ repo.description }}{%else%}<span class="text-muted">no description<span>{% endif %}</small>
                </div>
              </div>
            {% endfor %}
            </div>
        {% else %}
          <div class="card-block">
            <p>No projects found</p>
          </div>
        {% endif %}
        </div>
        {% if total_page and total_page > 1 %}
        {{ pagination_link(pagetitle, page, total_page) }}
        {% endif %}
{% endmacro %}