<!doctype html>
<html>
  <head>
    <title>SQLite Web: {{ dataset.base_name }}</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex">
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/sqlbrowse.css') }}" />
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/syntax-highlight.css') }}" />
    {% block extra_head %}{% endblock %}
    <script src="{{ url_for('static', filename='js/jquery-1.11.0.min.js') }}" type="text/javascript"></script>
    <script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script>
    <script type="text/javascript">
      $(function() {
        $('a#toggle-helper-tables').on('click', function(e) {
          e.preventDefault();
          $('ul#helper-tables').toggle();
        });
        $('input#table-search').on('keyup', function(e) {
          var searchQuery = $(this).val().toUpperCase();
          $('li.table-link').each(function() {
            var elem = $(this),
                tableName = elem.find('a').prop('innerText').toUpperCase();
            elem.toggle(tableName.indexOf(searchQuery) != -1);
          });
        });
      });
    </script>
    {% block extra_scripts %}{% endblock %}
  </head>

  <body class="{% block body_class %}{% endblock %}">
    <div class="container">
      {% block page_header %}
        <div class="page-header">
          {% block content_header %}
            {% if not dataset.is_readonly %}
            <form action="{{ url_for('table_create') }}" class="form-inline float-right" method="post" style="margin-top: 10px;">
              <input name="redirect" type="hidden" value="{{ request.path }}" />
              <input class="form-control form-control-sm" name="table_name" placeholder="new_table_name" />
              <button class="btn btn-primary btn-sm" type="submit">Create</button>
            </form>
            {% endif %}
          {% endblock %}
          <h1>{% block content_title %}{% endblock %}</h1>
        </div>
      {% endblock %}
      <div class="row">
        <div class="col-3" id="sidebar">
          {% block sidebar %}{% endblock %}
          {% block logout %}{% if login_required %}<a href="{{ url_for('logout') }}">Log-out</a>{% endif %}{% endblock %}
        </div>
        <div class="col-9" id="content">
          {% for category, message in get_flashed_messages(with_categories=true) %}
            <div class="alert alert-{{ category }} alert-dismissable">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
              <p>{{ message }}</p>
            </div>
          {% endfor %}
          {% block content %}{% endblock %}
        </div>
      </div>
      <div class="row">
        <div class="col-9 offset-3">
          <footer>
            <hr />
            <p>
              Web-based SQLite database browser, powered by
              <a href="http://flask.pocoo.org/">Flask</a> and <a href="http://docs.peewee-orm.com/">Peewee</a>.
              &copy; {{ now.year }} <a href="http://charlesleifer.com/">Charles Leifer</a>
            </p>
          </footer>
        </div>
      </div>
    </div>
  </body>
</html>
