# HG changeset patch # User Goffi # Date 1517294843 -3600 # Node ID da8f1ba9034d0a47746d69465d901c94965d7457 # Parent 5d9e2270ceb45800600b3e5fbad281f50010e655 input/comment: renamed "comment" library to "textbox", and made it more generic diff -r 5d9e2270ceb4 -r da8f1ba9034d default/blog/macros.html --- a/default/blog/macros.html Tue Jan 30 07:47:21 2018 +0100 +++ b/default/blog/macros.html Tue Jan 30 07:47:23 2018 +0100 @@ -1,4 +1,4 @@ -{% import 'input/comment.html' as comment with context %} +{% import 'input/textbox.html' as textbox with context %} {% macro show_items(items, comments=False, expanded=false, dates_fmt=none) %} {# show items and comments items if present after each item, @@ -26,7 +26,7 @@
{% if allow_commenting %}
- {{- comment.comment(service=comments_items.service, node=comments_items.node) -}} + {{- textbox.comment(service=comments_items.service, node=comments_items.node) -}}
{% endif %} diff -r 5d9e2270ceb4 -r da8f1ba9034d default/input/comment.html --- a/default/input/comment.html Tue Jan 30 07:47:21 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -{% 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 #} - - - -{% endmacro %} - -{% macro submit() %} - -{% 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 %} -
-

{% trans %}You are not logged. You need to log in to comment.{% endtrans %}

- {% if login_url is defined %} - - {% endif %} -
- {% endif %} -{% endmacro %} diff -r 5d9e2270ceb4 -r da8f1ba9034d default/input/field.html --- a/default/input/field.html Tue Jan 30 07:47:21 2018 +0100 +++ b/default/input/field.html Tue Jan 30 07:47:23 2018 +0100 @@ -36,8 +36,8 @@ {% endmacro %} -{% macro textarea(name, rows=10, cols=50, placeholder='') %} - +{% macro textarea(name, rows=10, cols=50, placeholder='', required=false) %} + {% endmacro %} {% macro meta(name, value) %} diff -r 5d9e2270ceb4 -r da8f1ba9034d default/input/textbox.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/input/textbox.html Tue Jan 30 07:47:23 2018 +0100 @@ -0,0 +1,52 @@ +{% import 'input/form.html' as form with context %} +{% import 'input/field.html' as field %} + +{% macro head(service, node, type="textbox") %} + {# include data needed to identify the node to use for commenting #} + + + +{% endmacro %} + +{% macro submit(label=_("Send")) %} + +{% endmacro %} + +{% macro textbox(service, node, action='', placeholder='', submit_label=_("Send"), type="textbox") %} + {# generic content area for comments/blog posts/etc. Only a body by default, but new elements can be + added by using this macro with call #} + {% set extra_content = caller() if caller is defined else '' %} + {% call form.form(action=action, class="textbox") %} + {{ head(service, node, type) }} + {{ extra_content }} + {{ field.textarea("body", placeholder=placeholder, required=True) }} + {{ submit(label=submit_label) }} + {% endcall %} +{% endmacro %} + +{% macro comment(service, node, action='', placeholder=_("Your comment")) %} + {{ textbox(service, node, action=action, placeholder=placeholder, type="comment") }} +{% endmacro %} + +{% macro comment_or_login(service, node, action='', placeholder=none) %} + {# show comment form a a message asking to log in + login is checked using profile #} + {% if profile %} + {% if placeholder is none %} + {{ comment(service, node, action) }} + {% else %} + {{ comment(service, node, action, placeholder=placeholder) }} + {% endif %} + {% else %} +
+

{% trans %}You are not logged. You need to log in to comment.{% endtrans %}

+ {% if login_url is defined %} + + {% endif %} +
+ {% endif %} +{% endmacro %} diff -r 5d9e2270ceb4 -r da8f1ba9034d default/merge-request/item.html --- a/default/merge-request/item.html Tue Jan 30 07:47:21 2018 +0100 +++ b/default/merge-request/item.html Tue Jan 30 07:47:23 2018 +0100 @@ -11,7 +11,7 @@ {% if not embedded %}{% extends 'base/base.html' %}{% endif %} {% import 'input/xmlui.html' as xmlui with context %} {% import 'blog/macros.html' as blog with context %} -{% import 'input/comment.html' as comment with context %} +{% import 'input/textbox.html' as textbox with context %} {% block title %}{{item|adv_format('[{value.widget_value.id}] {value.widget_value.title}') }}{% endblock %} @@ -43,7 +43,7 @@ {% endif %} {% if comments_node is defined %}
- {{- comment.comment_or_login(service=comments_service, node=comments_node) -}} + {{- textbox.comment_or_login(service=comments_service, node=comments_node) -}}
{% endif %}
diff -r 5d9e2270ceb4 -r da8f1ba9034d default/static/blog.css --- a/default/static/blog.css Tue Jan 30 07:47:21 2018 +0100 +++ b/default/static/blog.css Tue Jan 30 07:47:23 2018 +0100 @@ -225,11 +225,6 @@ text-align: center; } -.comment_post input { - display: block; - margin: 0 auto; -} - .comment_post textarea { border-style: solid; border-width: 1px 0; @@ -273,6 +268,7 @@ background: rgba(200,200,200,0.6); border-radius: 0.5em 0.5em 0 0; padding: 0 0.5em; + margin-top: 1em; } } diff -r 5d9e2270ceb4 -r da8f1ba9034d default/static/styles.css --- a/default/static/styles.css Tue Jan 30 07:47:21 2018 +0100 +++ b/default/static/styles.css Tue Jan 30 07:47:23 2018 +0100 @@ -221,6 +221,24 @@ display: block; } +/* Textboxes */ + +form.textbox>* { + display: block; + margin: 1em auto; + text-align: center; + max-width: 100%; + box-sizing: border-box; +} + +form.textbox>textarea { + text-align: left; +} + +.log_request { + text-align: center; +} + /*** Navigation ***/ .prev_next_links ul { diff -r 5d9e2270ceb4 -r da8f1ba9034d default/ticket/item.html --- a/default/ticket/item.html Tue Jan 30 07:47:21 2018 +0100 +++ b/default/ticket/item.html Tue Jan 30 07:47:23 2018 +0100 @@ -11,7 +11,7 @@ {% if not embedded %}{% extends 'base/base.html' %}{% endif %} {% import 'input/xmlui.html' as xmlui with context %} {% import 'blog/macros.html' as blog with context %} -{% import 'input/comment.html' as comment with context %} +{% import 'input/textbox.html' as textbox with context %} {% block title %}{{item|adv_format('[{value.widget_value.id}] {value.widget_value.title}') }}{% endblock %} @@ -35,7 +35,7 @@ {% endif %} {% if comments_node is defined %}
- {{- comment.comment_or_login(service=comments_service, node=comments_node) -}} + {{- textbox.comment_or_login(service=comments_service, node=comments_node) -}}
{% endif %} {% endblock body %}