Mercurial > libervia-templates
comparison default/input/textbox.html @ 116:da8f1ba9034d
input/comment: renamed "comment" library to "textbox", and made it more generic
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 Jan 2018 07:47:23 +0100 |
parents | default/input/comment.html@102356338118 |
children |
comparison
equal
deleted
inserted
replaced
115:5d9e2270ceb4 | 116:da8f1ba9034d |
---|---|
1 {% import 'input/form.html' as form with context %} | |
2 {% import 'input/field.html' as field %} | |
3 | |
4 {% macro head(service, node, type="textbox") %} | |
5 {# include data needed to identify the node to use for commenting #} | |
6 <input type="hidden" name="type" value="{{type}}"> | |
7 <input type="hidden" name="service" value="{{service}}"> | |
8 <input type="hidden" name="node" value="{{node}}"> | |
9 {% endmacro %} | |
10 | |
11 {% macro submit(label=_("Send")) %} | |
12 <input type="submit" value="{{label}}"> | |
13 {% endmacro %} | |
14 | |
15 {% macro textbox(service, node, action='', placeholder='', submit_label=_("Send"), type="textbox") %} | |
16 {# generic content area for comments/blog posts/etc. Only a body by default, but new elements can be | |
17 added by using this macro with call #} | |
18 {% set extra_content = caller() if caller is defined else '' %} | |
19 {% call form.form(action=action, class="textbox") %} | |
20 {{ head(service, node, type) }} | |
21 {{ extra_content }} | |
22 {{ field.textarea("body", placeholder=placeholder, required=True) }} | |
23 {{ submit(label=submit_label) }} | |
24 {% endcall %} | |
25 {% endmacro %} | |
26 | |
27 {% macro comment(service, node, action='', placeholder=_("Your comment")) %} | |
28 {{ textbox(service, node, action=action, placeholder=placeholder, type="comment") }} | |
29 {% endmacro %} | |
30 | |
31 {% macro comment_or_login(service, node, action='', placeholder=none) %} | |
32 {# show comment form a a message asking to log in | |
33 login is checked using profile #} | |
34 {% if profile %} | |
35 {% if placeholder is none %} | |
36 {{ comment(service, node, action) }} | |
37 {% else %} | |
38 {{ comment(service, node, action, placeholder=placeholder) }} | |
39 {% endif %} | |
40 {% else %} | |
41 <div class="log_request"> | |
42 <p class="not_logged">{% trans %}You are not logged. You need to log in to comment.{% endtrans %}</p> | |
43 {% if login_url is defined %} | |
44 <p class="log_in_url"> | |
45 {% trans link_start=('<a href="',login_url,'">')|join|safe, link_end='</a>'|safe %} | |
46 To log in {{link_start}}follow this link{{link_end}} | |
47 {% endtrans %} | |
48 </p> | |
49 {% endif %} | |
50 </div> | |
51 {% endif %} | |
52 {% endmacro %} |