mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
This results in a substantial performance improvement for all of
Zulip's backend templates.
Changes in templates:
- Change `block.super` to `super()`.
- Remove `load` tag because Jinja2 doesn't support it.
- Use `minified_js()|safe` instead of `{% minified_js %}`.
- Use `compressed_css()|safe` instead of `{% compressed_css %}`.
- `forloop.first` -> `loop.first`.
- Use `{{ csrf_input }}` instead of `{% csrf_token %}`.
- Use `{# ... #}` instead of `{% comment %}`.
- Use `url()` instead of `{% url %}`.
- Use `_()` instead of `{% trans %}` because in Jinja `trans` is a block tag.
- Use `{% trans %}` instead of `{% blocktrans %}`.
- Use `{% raw %}` instead of `{% verbatim %}`.
Changes in tools:
- Check for `trans` block in `check-templates` instead of `blocktrans`
Changes in backend:
- Create custom `render_to_response` function which takes `request` objects
instead of `RequestContext` object. There are two reasons to do this:
1. `RequestContext` is not compatible with Jinja2
2. `RequestContext` in `render_to_response` is deprecated.
- Add Jinja2 related support files in zproject/jinja2 directory. It
includes a custom backend and a template renderer, compressors for js
and css and Jinja2 environment handler.
- Enable `slugify` and `pluralize` filters in Jinja2 environment.
Fixes #620.
60 lines
1.9 KiB
HTML
60 lines
1.9 KiB
HTML
{% extends "zerver/portico.html" %}
|
|
|
|
{# API information page #}
|
|
|
|
{% block customhead %}
|
|
{{ super() }}
|
|
{{ minified_js('api')|safe }}
|
|
{% endblock %}
|
|
|
|
|
|
{% block portico_content %}
|
|
<h1 class="api-page-header">API endpoints documentation</h1>
|
|
|
|
<p>In addition to our <a href="/api">pre-built API bindings for Python</a>, we also have a <a href="http://en.wikipedia.org/wiki/Representational_state_transfer">REST-ful</a> web API.</p>
|
|
|
|
<ul class="nav nav-tabs" id="api-example-tabs">
|
|
<li class="active"><a href="#curl" data-toggle="tab" data-class="curl">curl</a></li>
|
|
<li><a href="#python" data-toggle="tab" data-class="python">Python</a></li>
|
|
</ul>
|
|
|
|
{% autoescape off %}
|
|
|
|
{% for blurb in content %}
|
|
<div class="api-block">
|
|
<h2 class="call">{{ blurb.call }}</h2>
|
|
<div class="endpoint"><code>{{blurb.method}} {{ blurb.endpoint }}</code></div>
|
|
<div class="api-details">
|
|
<h3>Arguments</h3>
|
|
<dl class="dl-horizontal arguments">
|
|
{% for argument in blurb.arguments %}
|
|
<dt><code>{{ argument.0 }}</code></dt>
|
|
<dd>{{ argument.1 }}</dd>
|
|
{% endfor %}
|
|
</dl>
|
|
<h3>Return values</h3>
|
|
<dl class="dl-horizontal returns">
|
|
{% for return in blurb.returns %}
|
|
<dt><code>{{ return.0 }}</code></dt>
|
|
<dd>{{ return.1 }}</dd>
|
|
{% endfor %}
|
|
</dl>
|
|
{% if blurb.example_request %}
|
|
<h3>Example request</h3>
|
|
{% for lang, req in blurb.example_request.items %}
|
|
<div class="example_request {{ lang }}">
|
|
{{ req }}
|
|
</div>
|
|
{% endfor %}{% endif %}
|
|
{% if blurb.rendered_response %}
|
|
<h3>Example response</h3>
|
|
<div class="example_response">
|
|
{{ blurb.rendered_response }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% endautoescape %}
|
|
{% endblock %}
|