view default/input/comment.html @ 84:b2ef34e602cf

base, js (websocket), css (main style): dynamic pages implementation, first draft: this patch introduces the browser part of dynamic pages. Dynamic pages work by establishing a websocket between server and the current page, if requested by server (which means that needed arguments are present in template). Once the connection is established, the server can, for now, reload the page, append HTML elements, or receive arbitrary data (without reloading the page, in opposition to data post). If connection can't be established, a popup will be displayed and connection will be retried many times after variable timeouts. The browser will finally give up and display an alert to client if the number of retries is too high (20 for now).
author Goffi <goffi@goffi.org>
date Wed, 03 Jan 2018 01:12:16 +0100
parents 102356338118
children
line wrap: on
line source

{% import 'input/form.html' as form with context %}
{% import 'input/field.html' as field %}

{% macro head(service, node) %}
    {# include data needed to identify the node to use for commenting #}
    <input type="hidden" name="type" value="comment">
    <input type="hidden" name="service" value="{{service}}">
    <input type="hidden" name="node" value="{{node}}">
{% endmacro %}

{% macro submit() %}
    <input type="submit" value="{{_("Send")}}">
{% endmacro %}

{% macro comment(service, node, action='') %}
{% call form.form(action=action) %}
    {{ head(service, node) }}
    {{ field.textarea("body", placeholder=_("Your comment")) }}
    {{ submit() }}
{% endcall %}
{% endmacro %}

{% macro comment_or_login(service, node, action='') %}
    {# show comment form a a message asking to log in
       login is checked using profile #}
    {% if profile %}
        {{ comment(service, node, action) }}
    {% else %}
        <div class="log_request">
        <p class="not_logged">{% trans %}You are not logged. You need to log in to comment.{% endtrans %}</p>
        {% if login_url is defined %}
            <p class="log_in_url">
                {% trans link_start=('<a href="',login_url,'">')|join|safe, link_end='</a>'|safe %}
                    To log in {{link_start}}follow this link{{link_end}}
                {% endtrans %}
            </p>
        {% endif %}
        </div>
    {% endif %}
{% endmacro %}