{% ckan_extends %}

{% block resource_item_title %}
  {% asset 'feedback/feedback-tooltip-css' %}
  <a class="heading" href="{{ url }}" title="{{ res.name or res.description }}">
    {{ h.resource_display_name(res) | truncate(50) }}<span class="format-label" property="dc:format" data-format="{{ res.format.lower() or 'data' }}">{{ h.get_translated(res, 'format') }}</span>
    {{ h.popular('views', res.tracking_summary.total, min=10) if res.tracking_summary }}
  </a>
  <br>
  {% if h.is_enabled_downloads() %}
    <div class = "bubble">
      <i class="fa fa-arrow-circle-o-down"></i>
      {{ h.get_resource_downloads(res.id) }}
      <div class="description">{{ _('Downloads') }}</div>
    </div>
  {% endif %}
  {% if h.is_enabled_utilizations() %}
    <div class="bubble">
      <i class="fa fa-pencil-square-o"></i>
      <a href="{{ h.url_for('utilization.search', id=res.id, disable_keyword=true) }}">{{ h.get_resource_utilizations(res.id) }}</a>
      <div class="description">{{ _('Utilizations') }}</div>
    </div>
  {% endif %}
  {% if h.is_enabled_resources() %}
    <div class="utilization-data bubble">
      <i class="fa fa-commenting-o"></i>
      <a href="{{ h.url_for('resource_comment.comment', resource_id=res.id) }}">{{ h.get_resource_comments(res.id) }}</a>
      <div class="description">{{ _('Comments') }}</div>
    </div>
    <div class="utilization-data bubble">
      <i class="fa fa-star"></i>
      {{ h.get_resource_rating(res.id)|round(1) }}
      <div class="description">{{ _('Rating') }}</div>
    </div>
  {% endif %}
  {% if h.is_enabled_utilizations() %}
    <div class="bubble">
      <img id="issue-resolution" src="/images/issue_resolution_badge.png">
      {{ h.get_resource_issue_resolutions(res.id) }}
      <div class="description">{{ _('Issue Resolutions') }}</div>
    </div>
  {% endif %}
{% endblock %}

{% block resource_item_explore %}
  {% if not url_is_edit %}
    <div class="dropdown btn-group">
      <a href="#" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
        <i class="fa fa-share"></i>
        {{ _('Explore') }}
        <span class="caret"></span>
      </a>
      <ul class="dropdown-menu">
        {% block resource_item_explore_links %}
          <li>
            <a href="{{ url }}">
              {% if not is_activity_archive and res.has_views %}
                <i class="fa fa-bar-chart-o"></i>
                {{ _('Preview') }}
              {% else %}
                <i class="fa fa-info-circle"></i>
                {{ _('More information') }}
              {% endif %}
            </a>
          </li>
          {% if res.url and h.is_url(res.url) %}
            <li>
              <a href="javascript:window.location.href += '/resource/{{ res.id }}/download';" class="resource-url-analytics">
                {% if res.has_views or res.url_type == 'upload' %}
                  <i class="fa fa-arrow-circle-o-down"></i>
                  {{ _('Download') }}
                {% else %}
                  <i class="fa fa-external-link"></i>
                  {{ _('Go to resource') }}
                {% endif %}
              </a>
            </li>
          {% endif %}
          {% if can_edit %}
            <li>
              <a href="{{ h.url_for(pkg.type ~ '_resource.edit', id=pkg.name, resource_id=res.id) }}">
                <i class="fa fa-pencil-square-o"></i>
                {{ _('Edit') }}
              </a>
            </li>
          {% endif %}
          {% if h.is_enabled_utilizations() %}
            <li>
              <a href="{{ h.url_for('utilization.new', package_name=pkg.name, resource_id=res.id) }}">
                <i class="fa fa-pencil-square-o"></i>{{ _('Create utilization application') }}
              </a>
            </li>
          {% endif %}
          {% if h.is_enabled_resources() %}
            <li>
              <a href="{{ h.url_for('resource_comment.comment', resource_id=res.id) }}">
                <i class="fa fa-commenting-o"></i>
                {{ _('Comment') }}
              </a>
            </li>
          {% endif %}
        {% endblock %}
      </ul>
    </div>
  {% endif %}
{% endblock %}