Projet

Général

Profil

0001-pages-always-display-placeholder-blocks-in-skeleton-.patch

Lauréline Guérin, 28 octobre 2019 09:02

Télécharger (3,98 ko)

Voir les différences:

Subject: [PATCH] pages: always display placeholder blocks in skeleton (#26641)

 combo/manager/templates/combo/page_view.html  | 6 ++++++
 combo/public/templates/combo/placeholder.html | 6 +++---
 combo/public/templatetags/combo.py            | 2 +-
 tests/test_public.py                          | 4 ++--
 4 files changed, 12 insertions(+), 6 deletions(-)
combo/manager/templates/combo/page_view.html
91 91

  
92 92
<div id="page-content">
93 93

  
94
{% if object.redirect_url %}
95
<div class="infonotice">
96
    <p>{% blocktrans with redirect_url=object.redirect_url %}This page is configured as a redirection to the URL "{{ redirect_url }}", it can also be used as a template for the pages behind this URL.{% endblocktrans %}</p>
97
</div>
98
{% endif %}
99

  
94 100
<div id="placeholders"
95 101
     data-cell-order-url="{% url 'combo-manager-cell-order' page_pk=object.id %}"
96 102
     >
combo/public/templates/combo/placeholder.html
1 1
{% load combo i18n %}
2 2
{% if render %}
3
{% if render_skeleton %}
4
{{ skeleton }}
5
{% endif %}
3 6
{% for cell in cells %}
4 7
<div class="cell {{ cell.css_class_names }} {% if cell.slug %}{{cell.slug}}{% endif %} {% if cell|shown_because_admin:request %}shown-because-admin{% endif %}"
5 8
     {% if cell.slug and cell.use_slug_as_id %}id="{{ cell.slug }}"{% endif %}
......
9 12
     {% if request.extra_context_data %}data-extra-context="{{ request.extra_context_data|signed|urlencode }}"{% endif %}
10 13
     ><div>{% render_cell cell %}</div></div>
11 14
{% endfor %}
12
{% if render_skeleton %}
13
{{ skeleton }}
14
{% endif %}
15 15
{% endif %}
combo/public/templatetags/combo.py
67 67
            x.placeholder == placeholder_name and
68 68
            (context.get('render_skeleton') or x.is_relevant(context) and
69 69
            x.is_visible(context['request'].user))]
70
    if context.get('render_skeleton') and not context['cells']:
70
    if context.get('render_skeleton'):
71 71
        context['skeleton'] = skeleton_text(context, placeholder_name)
72 72
    else:
73 73
        context['skeleton'] = ''
tests/test_public.py
269 269
    cell.save()
270 270
    resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net'))
271 271
    assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text
272
    assert not '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
272
    assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
273 273
    assert 'Foobar' in resp.text
274 274

  
275 275
    # check {% now %} inside a skeleton_extra_placeholder is not interpreted
......
281 281
    page.save()
282 282
    resp = app.get('/__skeleton__/?source=%s' % quote('http://127.0.0.1:8999/'))
283 283
    assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text
284
    assert not '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
284
    assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
285 285
    assert 'Foobar' in resp.text
286 286

  
287 287
    # check link cells provide a full URL
288
-