{% block header_wrapper %}
{% block header_account %}
  <header class="account-masthead">
    <div class="container">
      {% if c.userobj %}
        <div class="account avatar authed" data-module="me" data-me="{{ c.userobj.id }}">
          <ul class="unstyled">
            {% block header_account_logged %}
            {% if c.userobj.sysadmin %}
              <li>
                <a href="{{ h.url_for(controller='admin', action='index') }}" title="{{ _('Sysadmin settings') }}">
                  <i class="icon-legal"></i>
                </a>
              </li>
            {% endif %}
            <li>
              <a href="{{ h.url_for(controller='user', action='read', id=c.userobj.name) }}" class="image" title="{{ _('View profile') }}">
                {{ h.gravatar((c.userobj.email_hash if c and c.userobj else ''), size=22) }}
                <span class="username">{{ c.userobj.display_name }}</span>
              </a>
            </li>
            <li class="notifications {% if c.new_activities > 0 %}notifications-important{% endif %}">
              {% set notifications_tooltip = ngettext('Dashboard (%(num)d new item)', 'Dashboard (%(num)d new items)', c.new_activities) %}
              <a href="{{ h.url_for(controller='user', action='dashboard') }}" title="{{ notifications_tooltip }}">
                <i class="icon-dashboard"></i>
                <span>{{ c.new_activities }}</span>
              </a>
            </li>
            {% block header_account_settings_link %}
            <li>
              <a href="{{ h.url_for(controller='user', action='edit', id=c.userobj.name) }}" title="{{ _('Edit settings') }}">
                <i class="icon-cog"></i>
              </a>
            </li>
            {% endblock %}
            {% block header_account_log_out_link %}
            <li>
              <a href="{{ h.url_for('/user/_logout') }}" title="{{ _('Log out') }}">
                <i class="icon-signout"></i>
              </a>
            </li>
            {% endblock %}
            {% endblock %}
          </ul>
        </div>
      {% else %}
        <nav class="account not-authed">
          <ul class="unstyled">
            {% block header_account_notlogged %}
            <li>{% link_for _('Log in'), controller='user', action='login' %}</li>
            <li>{% link_for _('Register'), controller='user', action='register', class_='sub' %}</li>
            {% endblock %}
          </ul>
        </nav>
      {% endif %}
    </div>
  </header>
{% endblock %}
<header class="masthead">
  {% block header_debug %}
  {% if g.debug and not g.debug_supress_header %}
    <div class="debug">Controller : {{ c.controller }}<br/>Action : {{ c.action }}</div>
  {% endif %}
  {% endblock %}
  <div class="container">
    {# The .header-image class hides the main text and uses image replacement for the title #}
    <hgroup class="{{ g.header_class }}">

      {% block header_logo %}
        {% if g.site_logo %}
          <a class="logo" href="{{ h.url('home') }}"><img src="{{ h.url_for_static(g.site_logo) }}" alt="{{ g.site_title }} Logo" title="{{ g.site_title }} Logo" /></a>
        {% else %}
          <h1>
            <a href="{{ h.url('home') }}">{{ g.site_title }}</a>
          </h1>
          {% if g.site_description %}<h2>{{ g.site_description }}</h2>{% endif %}
        {% endif %}
      {% endblock %}

    </hgroup>

    <div class="content">

      {% block header_site_navigation %}
        <nav class="section navigation">
          <ul class="nav nav-pills">
            {% block header_site_navigation_tabs %}
            {{ h.build_nav_main(
              ('search', _('Datasets')),
              ('organizations_index', _('Organizations')),
              ('group_index', _('Groups')),
              ('about', _('About'))
            ) }}
            {% endblock %}
          </ul>
        </nav>
      {% endblock %}

      {% block header_site_search %}
        <form class="section site-search simple-input" action="{% url_for controller='package', action='search' %}" method="get">
          <div class="field">
            <label for="field-sitewide-search">{{ _('Search Datasets') }}</label>
            <input id="field-sitewide-search" type="text" name="q" placeholder="{{ _('Search') }}" />
            <button class="btn-search" type="submit">{{ _('Search') }}</button>
          </div>
        </form>
      {% endblock %}

    </div>
  </div>
</header>
{% endblock %}
