{% extends "flask_debug/base.html" %}

{% block scripts %}
{{super()}}
<script>
    $(document).ready(function() {
       $('#show-debug-endpoints').change(function() {
          if ($(this).is(':checked')) $('.debug-rule').removeClass('hidden');
          else $('.debug-rule').addClass('hidden');
       });
       $('#show-debug-views').change(function() {
          if ($(this).is(':checked')) $('.debug-view').removeClass('hidden');
          else $('.debug-view').addClass('hidden');
       });
    });
</script>
{% endblock %}

{% block container %}
    {{super()}}
        <h1>Reflection for {{g.app.name}}</h1>
        <h2>Views</h2>
        <div class="checkbox">
            <label>
              <input type="checkbox" id="show-debug-views">Show
                Flask-Debug views
            </label>
        </div>
        <table class="table table-striped table-hover">
            <tr>
                <th>Name</th>
                <th>View function</th>
            </tr>
        {% for name, view in g.app.view_functions.items()|sort(True) %}
            <tr{% if name.startswith('debug.') %} class="debug-view hidden"{% endif %}>
                <td><a name="endpoint_{{name.__hash__()}}"></a>{{name}}</td>
                <td><code>{{view}}</code></td>
            </tr>
        {% endfor %}
        </table>

        <h2>URLMap</h2>
        <div class="checkbox">
            <label>
              <input type="checkbox" id="show-debug-endpoints">Show
                Flask-Debug endpoints
            </label>
        </div>
        <table class="table table-striped table-hover">
            <tr>
                <th>Rule</th>
                <th>Methods</th>
                <th>Endpoint</th>
            </tr>
        {% for rule in g.app.url_map.iter_rules()|sort(True,
            attribute='endpoint') %}
            <tr{% if rule.endpoint.startswith('debug.debug_') %}
            class="debug-rule hidden"{% endif %}>
                <td><a href="{{rule}}">{{rule}}</a></td>
                <td>{{rule.methods|sort|join(', ')}}</td>
                <td><a href="#endpoint_{{rule.endpoint.__hash__()}}">{{rule.endpoint}}</a></td>
            </tr>
        {% endfor %}
        </table>

        <h2>Converters</h2>
        <table class="table table-striped table-hover">
            <tr>
                <th>Type-name</th>
                <th>Converter function</th>
            </tr>
        {% for name, conv in g.app.url_map.converters.items() %}
            <tr>
                <td>{{name}}</td>
                <td><code>{{conv}}</code></td>
            </tr>
        {% endfor %}
        </table>
{% endblock %}
