{% extends g.theme.master %}

{% block extra_css %}
    <link rel="alternate" type="application/rss+xml" title="RSS" href="{{c.app.url}}feed.rss"/>
    <link rel="alternate" type="application/atom+xml" title="Atom" href="{{c.app.url}}feed.atom"/>
{% endblock %}

{% block extra_js %}
<script type="text/javascript">(function() {
  $('#access_urls .btn').click(function(evt){
    evt.preventDefault();
    var parent = $(this).parents('.btn-bar');
    $(parent).find('input').val($(this).attr('data-url'));
    $(parent).find('span').text($(this).attr('title')+' access');
    $(this).parent().children('.btn').removeClass('active');
    $(this).addClass('active');
  });
  $('#access_urls .btn').first().click();
}());
</script>
{% endblock %}

{% macro clone_info(repo) %}
  {% if repo %}
    <div id="access_urls" class="btn-bar grid-19">
      <div class="btn-set{% if not h.has_access(c.app, 'write')() %} duo{% endif %}">
        {% if h.has_access(c.app, 'write')() %}
        <a class="btn" data-url="{{repo.clone_command('rw')}}" title="Read/Write">
          RW
        </a>
        <a href="#" class="btn" data-url="{{repo.clone_command('ro')}}" title="Read Only">
          RO
        </a>
        <a href="#" class="btn" data-url="{{repo.clone_command('https')}}" title="HTTP">
          HTTP
        </a>
        {% else %}
        <a href="#" class="btn" data-url="{{repo.clone_command('ro')}}" title="Read Only">
          RO
        </a>
        <a href="#" class="btn" data-url="{{repo.clone_command('https_anon')}}" title="HTTP">
          HTTP
        </a>
        {% endif %}
      </div>
      <span></span>
      <input id="access_url" readonly type="text"
             class="selectText"
             value=""/>
    </div>
    <hr>
  {% endif %}
{% endmacro %}

{% macro commit_labels(commit) %}
  {% set branches, tags = commit.symbolic_ids %}
  {% for b in branches %}
    <span class="scm-branch-label">{{b}}</span>
  {% endfor %}
  {% for t in tags %}
    <span class="scm-tag-label">{{t}}</span>
  {% endfor %}
{% endmacro %}
