<%namespace name="util" module="bodhi.server.util" inheritable="True"/>
<%namespace name="pager" file="pager.html" inheritable="True" />
<%namespace name="tables" file="tables.html" inheritable="True" />
<%namespace name="fragments" file="fragments.html" inheritable="True" />

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="management of Fedora Project updates" />
    <meta name="author" content="Luke Macken" />
    <meta name="author" content="Ralph Bean" />
    <meta name="author" content="Randy Barlow" />

    <!-- Only allow websockets connections to fedoraproject.org. -->
    <meta http-equiv="Content-Security-Policy" content="connect-src ${request.registry.settings['cors_connect_src']}">

    <link rel="shortcut icon" href="${request.static_url('bodhi:server/static/ico/favicon.ico')}">

    <base href="${request.registry.settings['base_address']}"/>
    <title>
      <%block name="pagetitle">
      Fedora Updates System
      </%block>
    </title>
    <link href="${request.static_url('bodhi:server/static/fedora-bootstrap-1.0.1/fedora-bootstrap.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/fonts/open-sans.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/fonts/hack.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/fonts/font-awesome.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/css/text.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/css/navbar.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/css/footer.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/css/site.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/css/datagrepper-feed.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/css/panel.css') }" rel="stylesheet" />
    <script src="${request.static_url('bodhi:server/static/js/jquery-1.10.2.min.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/Chart-0.2.0.min.js')}"></script>
  </head>

  <body>
      <div class="searchbar" style="display:none;">
        <div class="container">
          <div class="row">
            <div class="col-xs-12">
              <form id="search" role="search" class="nav navbar-form navbar-left">
                <div id="bloodhound" class="form-group m-b-0">
                  <input class="typeahead form-control" name="term" type="text" placeholder="Search..." style="height:50px;background:rgba(0,0,0,0);border:0;color:white;line-height:50px;">
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
      <div class="masthead">
      <div class="container">
        <div class="row">
          <div class="col-sm-6">
            <a href="${request.route_url('home')}">
              <img src="${request.static_url('bodhi:server/static/img/bodhi-logo.png')}" alt="Fedora Update System" id="kojiLogo" height="40px">
            </a>
          </div>
          <div class="col-sm-6">
            <div class="row">
              <nav class="navbar navbar-light p-t-0 p-b-0">
                  <div class="container">
                    <ul class="nav navbar-nav nav-pill pull-xs-right">
                        % if request.user:
                        % if request.matched_route and request.matched_route.name in ('new_update', 'new_override', 'new_stack'):
                        <li class="nav-item dropdown active">
                        % else:
                        <li class="nav-item dropdown">
                        % endif
                          <a class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <span class="glyphicon glyphicon-plus"></span>
                            Create
                          </a>
                          <div class="dropdown-menu">
                            <a class="dropdown-item" href="${request.route_url('new_update')}">
                                New Update
                            </a>
                            <a class="dropdown-item" href="${request.route_url('new_override')}">
                                New Override
                            </a>
                            % if request.registry.settings.get('stacks_enabled') == True:
                            <a class="dropdown-item" href="${request.route_url('new_stack')}">
                                New Stack
                            </a>
                            % endif
                          </div>
                        </li>
                        % endif

                        % if request.matched_route and request.matched_route.name in ('metrics', 'releases', 'release', 'overrides'):
                        <li class="nav-item dropdown active">
                        % else:
                        <li class="nav-item dropdown">
                        % endif
                          <a class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <span class="glyphicon glyphicon-tags"></span>
                            Stats
                          </a>
                          <div class="dropdown-menu">
                            <a class="dropdown-item" href="${request.route_url('metrics')}">
                              Overall Metrics
                            </a>
                            <a class="dropdown-item" href="${request.route_url('masher_status')}">
                              Masher Status
                            </a>
                            <a class="dropdown-item" href="${request.route_url('collection_composes')}">
                              Composes
                            </a>
                            % for state in request.releases:
                            <div class="dropdown-divider"></div>
                            % for r in request.releases[state]:
                            <a class="dropdown-item" href="${request.route_url('releases')}${r['name']}">
                              ${r['long_name']}
                            </a>
                            % endfor
                            % endfor
                          </div>
                        </li>

                        % if request.user:
                        % if request.matched_route and request.matched_route.name == 'user' and request.user and user and request.user.name == user['name']:
                        <li class="nav-item dropdown active">
                        % else:
                        <li class="nav-item dropdown">
                        % endif
                          <a class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <span class="glyphicon glyphicon-user"></span>
                            <img src="${self.util.avatar(request.user.name, size=24)}"/>
                          </a>
                          <div class="dropdown-menu">
                              <a class="dropdown-item" href="${request.route_url('user', name=request.user.name)}">
                                Your Profile
                              </a>
                              <a class="dropdown-item" href="${request.registry.settings.get('fmn_url')}${request.user.openid}/">
                                Manage Alerts
                              </a>
                              <form id="popup_toggle" action="${request.route_url('popup_toggle')}" method="POST">
                                % if request.matched_route:
                                <input type="hidden" name="next" value="${request.current_route_url()}">
                                % endif
                              </form>
                              <a class="dropdown-item" href="javascript:$('#popup_toggle').submit();">
                                % if request.user.show_popups:
                                Disable popups
                                % else:
                                Enable popups
                                % endif
                              </a>
                              % if request.user:
                              <a class="dropdown-item" href="${request.route_url('logout')}">
                                Log out</a>
                              % endif
                          </div>
                        </li>
                        % endif

                        % if not request.user:
                        <li class="nav-item">
                          % if request.matched_route:
                          <a class="nav-link" href="${request.route_url('login') + '?came_from=' + request.current_route_url()}">
                            <span class="glyphicon glyphicon-log-in"></span>
                            Login</a>
                          % else:
                          <a class="nav-link" href="${request.route_url('login')}">
                            <span class="glyphicon glyphicon-log-in"></span>
                            Login</a>
                          % endif
                        </li>
                        % endif
                        <li class="nav-item">
                          <a class="nav-link" href="javascript:void(0);" id="search-toggle">
                            <span class="fa fa-search"></span>
                          </a>
                        </li>
                    </ul>
                  </div>
                </nav>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="bodycontent p-b-3">
        ${self.body()}
    </div> <!-- /bodycontent -->

    <div class="footer p-y-3">
      <div class="container">
        <p class="text-muted text-xs-center">
          Copyright &copy; 2007-2018 Red Hat, Inc. and
          <a href="https://github.com/fedora-infra/bodhi/graphs/contributors">
          others</a>.
        </p>
        <p class="text-muted text-xs-center">
          Running
          <strong>bodhi-${util.version()}</strong> on
          <strong>${util.hostname()}</strong>.
        </p>
        <p class="text-muted text-xs-center">
          <a href="https://github.com/fedora-infra/bodhi">
          bodhi</a> is Free Software.
          Please <a href="https://github.com/fedora-infra/bodhi/issues">
          file issues</a>
          if you have any problems. Read the <a href="https://bodhi.fedoraproject.org/docs">documentation</a>.
        </p>
        % if request.registry.settings.get('legal_link') or request.registry.settings.get('privacy_link'):
        <p class="text-muted text-xs-center">
            % if request.registry.settings.get('legal_link'):
            <a href="${request.registry.settings.get('legal_link')}">Legal</a>
            % endif
            % if request.registry.settings.get('legal_link') and request.registry.settings.get('privacy_link'):
            |
            % endif
            % if request.registry.settings.get('privacy_link'):
            <a href="${request.registry.settings.get('privacy_link')}">Privacy policy</a>
            % endif
        </p>
        % endif
      </div>
    </div>

    <!-- Placed at the end of the document so the pages load faster -->
    <script src="${request.static_url('bodhi:server/static/jquery.flot.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/jquery.flot.stack.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/fedora-bootstrap-1.0.1/fedora-bootstrap.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/moment/moment.min.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/cabbage.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/forms.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/site.js')}"></script>
    % if request.user and request.user.show_popups:
    <script src="${request.static_url('bodhi:server/static/js/live.js')}"></script>
    % endif
    <script src="${request.static_url('bodhi:server/static/messenger/js/messenger.min.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/messenger/js/messenger-theme-flat.js')}"></script>
    <link href="${request.static_url('bodhi:server/static/messenger/css/messenger.css') }" rel="stylesheet" />
    <link href="${request.static_url('bodhi:server/static/messenger/css/messenger-theme-flat.css') }" rel="stylesheet" />
    <script src="${request.static_url('bodhi:server/static/js/typeahead.bundle.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/search.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/konami.js')}"></script>

    % if 'fedmenu.url' in request.registry.settings:
    <script src="${request.registry.settings.get('fedmenu.url')}/js/fedora-libravatar.js"></script>
    <script src="${request.registry.settings.get('fedmenu.url')}/js/fedmenu.js"></script>
    <script>
      fedmenu({
          'url': '${request.registry.settings.get("fedmenu.data_url")}',
          'mimeType': 'application/javascript',
          'position': 'bottom-right',
          % if update:
            'user': '${update.user.name}',
            % if len(update.builds) == 1:
              'package': '${update.builds[0].package.name}',
            % endif
          % elif override:
            'user': '${override.submitter.name}',
            'package': '${override.build.package.name}',
          % elif user:
            'user': '${user["name"]}',
          % elif package:
            'package': '${package}',
          % endif
      });
    </script>
    % endif

  </body>
</html>
