<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>API version {{ content.0 }}</title>
        <link rel="stylesheet" href="http://blueprintcss.org/blueprint/screen.css" type="text/css" media="screen, projection">
		<link rel="stylesheet" href="http://blueprintcss.org/blueprint/print.css" type="text/css" media="print">    
		<!--[if lt IE 8]><link rel="stylesheet" href="http://blueprintcss.org/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
        <script>
            $(function(){
                $('.uri_link-active').click(function(e){
                    $(this).parent().find('.uri_info').toggleClass('uri_info-show');
                });
            });
        </script>
        <style>
            .navbar {
                -webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1);
                height: 60px;
                font-family: Palatino,Georgia,"Times New Roman",Times,serif;
                font-size: 16px;
                color: #282828;
            }
            .uri_link {
                font-size: 1.5em;
                color: #339
            }
            .uri { margin: 0.5em 0 1em; font-weight: bold }
            .uri_item { margin-left: .5em }
            .uri_methods { color: #999 }
            .uri_resource { color: #393; margin: 0; }
            .uri_name { color: #933 }
            .uri_link-active { border-bottom: 1px dashed; cursor: pointer; }
            .uri_auth { margin: 0; }
            .uri_info { display: none; font-weight: bold; margin-left: 1em; }
            .uri_info-show { display: block; }
            .uri_info_required { font-weight: bold; color: red; }
            dt, dd { display: inline-block; }
            dt { color: #999; font-weight: normal; }
            dl { margin: 0 }
        </style>
    </head>
    <body>
        <div class="navbar">
            <div class="container"><h1>API version {{ resource.api }}</h1></div>
        </div>

        <div class="container">
            {% for uri, info in content %}
            <div class="uri">
                <span class="uri_link">{{ uri }}</span>
                <sup class="uri_name">[{{ info.url_name }}]</sup>
                <span class="uri_item uri_methods"> {% for m in info.allowed_methods %}{{ m }}&nbsp;{% endfor %}</span>
                    {% if info.doc %}
                        <p class="uri_resource">{{ info.doc|linebreaksbr }}</p>
                    {% endif %}
                    {% if info.model %}
                    <dl>
                        <dt>Resource:</dt>
                        <span class="uri_link-active" href="#">{{ info.model.name }}</span>
                        <table class="uri_info info">
                            {% for f in info.model.fields %}
                                <tr>
                                    <td> {{ f.name }} </td>
                                    <td> {{ f.get_internal_type }} </td>
                                    <td> {{ f.help_text }} </td>
                                </tr>
                            {% endfor %}
                        </table>
                    </dl>
                    {% endif %}
                    <dl>
                        <dt>Authentication:</dt>
                        <dd>{% for a in info.auth %} {{ a }} {% endfor %}</dd>
                    </dl>
                    <dl>
                        <dt>Emmiters:</dt>
                        <dd>{{ info.emitters }}</dd>
                    </dl>

                {% if info.fields %}
                    <div>
                        <span class="uri_link-active" href="#">Form data</span>
                        <table class="uri_info info">
                            {% for f, v in info.fields %}
                            <tr>
                                <td {% if v.required %} class="uri_info_required" {% endif %}> {{ f }} </td>
                                <td> {{ v.label }}. {{ v.help }} </td>
                            </tr>
                            {% endfor %}
                        </table>
                    </div>
                {% endif %}
                {% if info.methods %}
                <span class="uri_link-active" href="#">RPC methods</span>
                <table class="uri_info info">
                    {% for name, inspect in info.methods.items %}
                        <tr>
                            <td> {{ name }} </td>
                            <td> {{ inspect.args }} </td>
                    {% endfor %}
                </table>{% endif %}
            </div>
            {% endfor %}
        </div>
    </body>
</html>
