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

<!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>

    <%block name="css">
    <link href="${request.static_url('bodhi:server/static/vendor/fedora-bootstrap/fedora-bootstrap.min.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/site.css') }" rel="stylesheet" />
    </%block>

  </head>

  <body>
      <div class="searchbar" style="display:none;">
        <div class="container">
          <div class="row">
            <div class="col-12">
              <form id="search" role="search">
                <div id="bloodhound" class="form-group mb-0">
                  <input class="typeahead form-control" id="searchbox" name="term" autocomplete="off" type="text" placeholder="Search...">
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
      <div class="masthead py-2">
      <div class="container px-0">
        <div class="row no-gutters">
          <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" height="40">
            </a>
          </div>
          <div class="col-sm-6">
            <div class="row">
              <nav class="navbar navbar-light navbar-expand pt-0 pb-0 ml-auto">
                  <div class="container">
                    <ul class="nav navbar-nav nav-pill align-items-center">
                        % if request.matched_route and request.matched_route.name in ('releases', 'release'):
                        <li class="nav-item active font-weight-bold">
                        % else:
                        <li class="nav-item font-weight-bold">
                        % endif
                          <a class="nav-link" href="${request.route_url('releases')}">
                            Releases
                          </a>
                        </li>

                        % if request.matched_route and request.matched_route.name in ('update', 'updates'):
                        <li class="nav-item active font-weight-bold">
                        % else:
                        <li class="nav-item font-weight-bold">
                        % endif
                          <a class="nav-link" href="${request.route_url('updates')}?releases=__current__&releases=__pending__">
                            Updates
                          </a>
                        </li>

                        % if request.matched_route and request.matched_route.name in ('override', 'overrides'):
                        <li class="nav-item active font-weight-bold">
                        % else:
                        <li class="nav-item font-weight-bold">
                        % endif
                          <a class="nav-link" href="${request.route_url('overrides')}?expired=False">
                            Overrides
                          </a>
                        </li>

                        <li class="nav-item">
                            <a class="nav-link" href="javascript:void(0);" id="search-toggle">
                              <span class="fa fa-search"></span>
                            </a>
                          </li>
                        % if request.user:
                        <li class="nav-item dropdown">
                          <a class="nav-link dropdown-toggle" href="javascript:void(0)" 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)}" alt="User Icon"/>
                          </a>
                          <div class="dropdown-menu dropdown-menu-right">
                              <a class="dropdown-item" href="${request.route_url('home')}">
                                  Dashboard
                              </a>
                              <a class="dropdown-item" href="${request.route_url('new_update')}">
                                  Create New Update
                              </a>
                              <a class="dropdown-item" href="${request.route_url('new_override')}">
                                  Create New Override
                              </a>
                              <div class="dropdown-divider"></div>
                              <a class="dropdown-item" href="${request.route_url('user', name=request.user.name)}">
                                Your Public Profile
                              </a>
                              <a class="dropdown-item" href="${request.registry.settings.get('fmn_url')}${request.user.openid}/">
                                Manage Alerts
                              </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 ml-3">
                          % if request.matched_route:
                          <a class="btn btn-primary" href="${request.route_url('login') + '?came_from=' + request.current_route_url()}">Login</a>
                          % else:
                          <a class="btn btn-primary" href="${request.route_url('login')}">Login</a>
                          % endif
                        </li>
                        % endif
                    </ul>
                  </div>
                </nav>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="bodycontent pb-3">
        ${self.body()}
    </div> <!-- /bodycontent -->

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

    <!-- Alert Modal -->
    <div class="modal fade" id="alertModal" tabindex="-1" role="dialog" aria-labelledby="alertModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
      <div class="modal-dialog" role="document">
	<div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="alertModalLabel">Internal Server Error!</h5>
          </div>
          <div class="modal-body" id="alertModalDescription">
	     The server encountered an internal error
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>

    <script>
      var settings = {
          bz_products: ["${ '","'.join(config['bz_products']) | n }"],
          bz_server_rest: "${config['bz_server_rest']}"
      };
    </script>
    <%block name="javascript">
    <script src="${request.static_url('bodhi:server/static/vendor/jquery/jquery-1.10.2.min.js')}"></script>
    <script>
      $('#alertModal').on('hidden.bs.modal', function (e) {
          document.location.href = document.baseURI;
      })
    </script>
    <script src="${request.static_url('bodhi:server/static/vendor/fedora-bootstrap/fedora-bootstrap.min.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/site.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/vendor/typeahead/typeahead.bundle.js')}"></script>
    <script src="${request.static_url('bodhi:server/static/js/search.js')}"></script>
    </%block>
    
  </body>
</html>
