{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2016-2020 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}
{# TODO: Use url_for instead #}

<div class="community-header">
  <div class="ui container relaxed grid">
    <div class="row">
      <div class="two wide column">
        {% if logo %}
        <div class="ui rounded image community-image">
          <img src="{{logo.links.self}}" alt="No image found"/>
        </div>
        {% else %}
        <div class="ui rounded image">
          <img src="/static/images/placeholder.png" alt="No image found"/>
        </div>
        {% endif %}
      </div>
      <div class="ten wide column">
          <h2 class="ui header">{{ community.metadata.title }}</h2>
          <p>{{ community.metadata.description }}</p>
          {% if community.metadata.website %}
            <a href="{{community.metadata.website}}"> <i class="linkify icon"></i>
              {{community.metadata.website}}
            </a>
          {% endif %}
          {% if community.metadata.type %}
            <i class="tag icon community-tags"></i><div class="ui label small grey type-label">{{ types[community.metadata.type] }}</div>
          {% endif %}
          {% if community.metadata.organizations %}
            <i class="building outline icon community-tags"></i>
            {%- for organization in community.metadata.organizations %}
              <span class="label label-keyword">{{ organization.name }}</span>
            {%- endfor %}
          {% endif %}

      </div>
      {# TODO: Add proper statistics #}
      <!-- <div class="two wide floated right column">
        <div class="ui mini statistic">
          <div class="value">
            5,550
          </div>
          <div class="label">
            Views
          </div>
        </div>
      </div>
      <div class="two wide floated right column">
        <div class="ui mini statistic">
          <div class=" value">
            4,200
          </div>
          <div class="label">
            Downloads
          </div>
        </div>
      </div> -->
    </div>
    <!-- <div class="three wide column"> -->
      {# TODO: use "url_for" with appropriate querystring parameter #}
      <!-- <a href="/uploads/new/?community={{ community.id }}" class="ui positive button">
        <i class="plus icon"></i>
        New upload
      </a> -->
    <!-- </div> -->
    {% set header_menu_items = {
      'search': ('Search', url_for('invenio_communities.communities_detail', pid_value=community.id), 'search icon', True),
      'settings': ('Settings', url_for('invenio_communities.communities_settings', pid_value=community.id), 'settings icon', permissions.can_update),
    } %}
    <div class="row">
      <div class="ui container secondary pointing menu community-header">
        {% for header_menu_key, (header_menu_item, header_menu_link, menu_icon, permission_to_show ) in header_menu_items.items() if permission_to_show %}
          <a class="item {{ 'active' if active_header_menu_item == header_menu_key }} {{ 'disabled' if not header_menu_link }}" href="{{ header_menu_link }}"><i aria-hidden="true" class="{{menu_icon}}"></i>{{ header_menu_item }}</a>
        {% endfor %}
      </div>
    </div>
  </div>
</div>
