<commit_before>{% from "macros/flags.jinja" import insert_flag with context %}

{% set navigation_bar = [
    ('/about', 'about', _('About')),
    ('/tracking/', 'tracking', _('Live')),
    ('/flights/', 'flights', _('Flights')),
    ('/ranking/', 'ranking', _('Ranking')),
    ('/statistics/', 'statistics', _('Statistics'))
] -%}

{% macro topbar(active_page) -%}
<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            {{ _topbar_content(active_page) }}
        </div>
    </div>
</div>
{%- endmacro %}

{% macro _topbar_content(active_page) -%}
<a href="/"><img src="/images/logo.png" class="logo" /></a>
<a class="brand" href="/">
    <span class="skylines-blue">Sky</span><span class="skylines-white">Lines</span>
</a>

<ul class="nav">
    {% for href, id, caption in navigation_bar -%}
    <li{% if active_page == id %} class="active"{% endif %}><a href="{{ href }}">{{ caption }}</a></li>
    {%- endfor %}
</ul>

<ul class="nav pull-right">
    <li{% if active_page == 'upload' %} class="active"{% endif %}>
        <a href="/flights/upload/"><i class="icon-upload-alt"></i> {% trans %}Upload{% endtrans %}</a>
    </li>

    {% if request.identity -%}
    {{ _notification_item(active_page) }}
    {{ _user_dropdown(active_page) }}
    {%-  else %}
    {{ _login_dropdown(active_page) }}
    {%- endif %}

    {{ _language_dropdown() }}
</ul>
{%- endmacro %}

{% macro _login_dropdown(active_page) -%}
<li class="dropdown {% if active_page == 'login' %}active{% endif %}">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class="icon-signin"></i> {% trans %}Login{% endtrans %} <i class="icon-caret-down"></i>
    </a>
    <div class="dropdown-menu">
        {{ _login_form() }}
    </div>
</li>
{%- endmacro %}

{% macro _login_form() -%}
<form action="{{ tg.url('/login_handler', params=dict(came_from=request.url.encode('utf-8'))) }}" method="post" accept-charset="UTF-8">
    <div class="control-group">
        <label class="control-label" for="username">{% trans %}Email Address{% endtrans %}:</label>
        <div class="controls">
            <input type="text" id="username" name="login"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="password">{% trans %}Password{% endtrans %}:</label>
        <div class="controls">
            <input type="password" id="password" name="password" />
        </div>
    </div>
    <div class="actions clearfix">
        <label id="remember" class="checkbox pull-left">
            <input type="checkbox" name="remember" value="31536000"/> {% trans %}Remember me{% endtrans %}
        </label>
        <input type="submit" value="Login" class="btn btn-primary pull-right" />
    </div>
    <hr/>
    <a href="/users/recover">{% trans %}Forgot password?{% endtrans %}</a>
    <a href="/users/new">{% trans %}Don't have an account?{% endtrans %}</a>
</form>
{%- endmacro %}

{%- macro _notification_item(active_page) -%}
{%- with notifications = request.identity['notifications'] %}
<li{% if active_page == 'notifications' %} class="active"{% endif %}>
    <a href="/notifications/" title="{{ _('Notifications') }}">
        <span class="badge{% if notifications != 0 %} badge-warning{% endif %}">{{ notifications }}</span>
    </a>
</li>
{%- endwith %}
{%- endmacro %}

{%- macro _user_dropdown(active_page) -%}
<li class="dropdown {% if active_page == 'settings' %}active{% endif %}">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">
      {{ request.identity['user'].display_name|e }} <i class="icon-caret-down"></i>
  </a>
  <ul class="dropdown-menu">
      <li><a href="/users/{{ request.identity['user'].id }}/"><i class="icon-user"></i> {{ request.identity['user'].display_name|e }}</a></li>
      {%- if request.identity['user'].club %}
      <li><a href="/clubs/{{ request.identity['user'].club.id }}/"><i class="icon-group"></i> {{ request.identity['user'].club.name|e }}</a></li>
      {%- endif %}
      <li class="divider"></li>
      <li><a href="/flights/pilot/{{ request.identity['user'].id }}"><i class="icon-plane"></i> {% trans %}Flights{% endtrans %}</a></li>
      <li><a href="/statistics/pilot/{{ request.identity['user'].id }}"><i class="icon-tasks"></i> {% trans %}Statistics{% endtrans %}</a></li>
      <li class="divider"></li>
      <li><a href="/logout_handler"><i class="icon-signout"></i> {% trans %}Logout{% endtrans %}</a></li>
  </ul>
</li>
{%- endmacro %}

{%- macro _language_dropdown() -%}
<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        {{ insert_flag(c.current_language['country_code']) }} <i class="icon-caret-down"></i>
    </a>
    <ul class="dropdown-menu">
      {% for lang in c.primary_languages %}
      <li>
          <a href="/set_lang/{{ lang['language_code'] }}" title="{{ lang['english_name'] }}">{{ insert_flag(lang['country_code']) }} {{ lang['local_name'] }}</a>
      </li>
      {% endfor %}
      <li class="divider"></li>
      {% for lang in c.secondary_languages %}
      <li>
          <a href="/set_lang/{{ lang['language_code'] }}" title="{{ lang['english_name'] }}">{{ insert_flag(lang['country_code']) }} {{ lang['local_name'] }}</a>
      </li>
      {% endfor %}
    </ul>
</li>
{%- endmacro %}
<commit_msg>topbar.jinja: Merged duplicate code into _language_item() macro<commit_after>{% from "macros/flags.jinja" import insert_flag with context %}

{% set navigation_bar = [
    ('/about', 'about', _('About')),
    ('/tracking/', 'tracking', _('Live')),
    ('/flights/', 'flights', _('Flights')),
    ('/ranking/', 'ranking', _('Ranking')),
    ('/statistics/', 'statistics', _('Statistics'))
] -%}

{% macro topbar(active_page) -%}
<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            {{ _topbar_content(active_page) }}
        </div>
    </div>
</div>
{%- endmacro %}

{% macro _topbar_content(active_page) -%}
<a href="/"><img src="/images/logo.png" class="logo" /></a>
<a class="brand" href="/">
    <span class="skylines-blue">Sky</span><span class="skylines-white">Lines</span>
</a>

<ul class="nav">
    {% for href, id, caption in navigation_bar -%}
    <li{% if active_page == id %} class="active"{% endif %}><a href="{{ href }}">{{ caption }}</a></li>
    {%- endfor %}
</ul>

<ul class="nav pull-right">
    <li{% if active_page == 'upload' %} class="active"{% endif %}>
        <a href="/flights/upload/"><i class="icon-upload-alt"></i> {% trans %}Upload{% endtrans %}</a>
    </li>

    {% if request.identity -%}
    {{ _notification_item(active_page) }}
    {{ _user_dropdown(active_page) }}
    {%-  else %}
    {{ _login_dropdown(active_page) }}
    {%- endif %}

    {{ _language_dropdown() }}
</ul>
{%- endmacro %}

{% macro _login_dropdown(active_page) -%}
<li class="dropdown {% if active_page == 'login' %}active{% endif %}">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class="icon-signin"></i> {% trans %}Login{% endtrans %} <i class="icon-caret-down"></i>
    </a>
    <div class="dropdown-menu">
        {{ _login_form() }}
    </div>
</li>
{%- endmacro %}

{% macro _login_form() -%}
<form action="{{ tg.url('/login_handler', params=dict(came_from=request.url.encode('utf-8'))) }}" method="post" accept-charset="UTF-8">
    <div class="control-group">
        <label class="control-label" for="username">{% trans %}Email Address{% endtrans %}:</label>
        <div class="controls">
            <input type="text" id="username" name="login"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="password">{% trans %}Password{% endtrans %}:</label>
        <div class="controls">
            <input type="password" id="password" name="password" />
        </div>
    </div>
    <div class="actions clearfix">
        <label id="remember" class="checkbox pull-left">
            <input type="checkbox" name="remember" value="31536000"/> {% trans %}Remember me{% endtrans %}
        </label>
        <input type="submit" value="Login" class="btn btn-primary pull-right" />
    </div>
    <hr/>
    <a href="/users/recover">{% trans %}Forgot password?{% endtrans %}</a>
    <a href="/users/new">{% trans %}Don't have an account?{% endtrans %}</a>
</form>
{%- endmacro %}

{%- macro _notification_item(active_page) -%}
{%- with notifications = request.identity['notifications'] %}
<li{% if active_page == 'notifications' %} class="active"{% endif %}>
    <a href="/notifications/" title="{{ _('Notifications') }}">
        <span class="badge{% if notifications != 0 %} badge-warning{% endif %}">{{ notifications }}</span>
    </a>
</li>
{%- endwith %}
{%- endmacro %}

{%- macro _user_dropdown(active_page) -%}
<li class="dropdown {% if active_page == 'settings' %}active{% endif %}">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">
      {{ request.identity['user'].display_name|e }} <i class="icon-caret-down"></i>
  </a>
  <ul class="dropdown-menu">
      <li><a href="/users/{{ request.identity['user'].id }}/"><i class="icon-user"></i> {{ request.identity['user'].display_name|e }}</a></li>
      {%- if request.identity['user'].club %}
      <li><a href="/clubs/{{ request.identity['user'].club.id }}/"><i class="icon-group"></i> {{ request.identity['user'].club.name|e }}</a></li>
      {%- endif %}
      <li class="divider"></li>
      <li><a href="/flights/pilot/{{ request.identity['user'].id }}"><i class="icon-plane"></i> {% trans %}Flights{% endtrans %}</a></li>
      <li><a href="/statistics/pilot/{{ request.identity['user'].id }}"><i class="icon-tasks"></i> {% trans %}Statistics{% endtrans %}</a></li>
      <li class="divider"></li>
      <li><a href="/logout_handler"><i class="icon-signout"></i> {% trans %}Logout{% endtrans %}</a></li>
  </ul>
</li>
{%- endmacro %}

{%- macro _language_dropdown() -%}
<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        {{ insert_flag(c.current_language['country_code']) }} <i class="icon-caret-down"></i>
    </a>
    <ul class="dropdown-menu">
      {% for lang in c.primary_languages -%}
      {{ _language_item(lang) }}
      {%- endfor %}
      <li class="divider"></li>
      {% for lang in c.secondary_languages -%}
      {{ _language_item(lang) }}
      {%- endfor %}
    </ul>
</li>
{%- endmacro %}

{% macro _language_item(lang) %}
<li><a href="/set_lang/{{ lang['language_code'] }}" title="{{ lang['english_name'] }}">{{ insert_flag(lang['country_code']) }} {{ lang['local_name'] }}</a></li>
{%- endmacro %}
{'fraction_non_alphanumeric': 0.24359215981907276, 'fraction_numerical': 0.0020731247644176403, 'mean_word_length': 3.6023417172593235, 'pattern_counts': {'":': 0, '<': 263, '<?xml version=': 0, '>': 263, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1761277', 'n_tokens_mistral': 3818, 'n_tokens_neox': 3508, 'n_words': 713}