From b9cdb20a1dbe16d21567685cd6a7d68d0580e219 Mon Sep 17 00:00:00 2001
From: Thomas JUND <tjund@entrouvert.com>
Date: Mon, 22 Mar 2021 14:54:10 +0100
Subject: [PATCH] themes: easily move the user-info block (#52275)

* add block 'header-content'
* add block 'top-links'
* move user-info code in own file
---
 templates/combo/page_template.html | 19 ++-----------------
 templates/includes/user-info.html  | 24 ++++++++++++++++++++++++
 templates/theme.html               | 17 +++++------------
 3 files changed, 31 insertions(+), 29 deletions(-)
 create mode 100644 templates/includes/user-info.html

diff --git a/templates/combo/page_template.html b/templates/combo/page_template.html
index 26fbe6e8..4b2410bb 100644
--- a/templates/combo/page_template.html
+++ b/templates/combo/page_template.html
@@ -134,23 +134,8 @@ data-api-root="{{ site_base }}/api/"
   {% placeholder "footer" acquired=True name=name %}
 {% endblock %}
 
-{% block user-info %}
-{% skeleton_extra_placeholder user-info %}
-          {% if user.is_authenticated %}
-          <span class="logged-in">
-            {% if idp_account_url %}<a class="account-link" href="{{idp_account_url}}">{% endif %}
-            <span class="connected-user">{% block user-info-user-name %}{{user.first_name}} {{user.last_name}}{% endblock %}</span>{% if idp_account_url %}</a>{% endif %}
-            <a accesskey="o" class="logout" href="{% url 'auth_logout' %}">{% block user-info-logout-label %}Déconnexion{% endblock %}</a>
-          </span>
-          {% else %}
-            <span class="login"><a accesskey="2" class="login-link" href="{% url 'auth_login' %}"
-              >{% block user-info-login-label %}Connexion{% endblock %}
-              {% if idp_registration_url and include_registration_link != False %}</a>{% endif %}
-              <span class="sep">/</span>
-              {% if idp_registration_url and include_registration_link != False %}<a class="registration" href="{{idp_registration_url}}"
-              >{% block user-info-registration-label %}Inscription{% endblock %}{% endif %}</a></span>
-          {% endif %}
-{% end_skeleton_extra_placeholder %}
+{% block top-links %}
+  {% include 'includes/user-info.html' %}
 {% endblock %}
 
 {% block back-top %}
diff --git a/templates/includes/user-info.html b/templates/includes/user-info.html
new file mode 100644
index 00000000..3bf0aa49
--- /dev/null
+++ b/templates/includes/user-info.html
@@ -0,0 +1,24 @@
+{% load combo %}
+
+{% if include_top_links != False %}
+<div id="toplinks">
+{% block user-info %}
+{% skeleton_extra_placeholder user-info %}
+  {% if user.is_authenticated %}
+  <span class="logged-in">
+    {% if idp_account_url %}<a class="account-link" href="{{idp_account_url}}">{% endif %}
+    <span class="connected-user">{% block user-info-user-name %}{{user.first_name}} {{user.last_name}}{% endblock %}</span>{% if idp_account_url %}</a>{% endif %}
+    <a accesskey="o" class="logout" href="{% url 'auth_logout' %}">{% block user-info-logout-label %}Déconnexion{% endblock %}</a>
+  </span>
+  {% else %}
+    <span class="login"><a accesskey="2" class="login-link" href="{% url 'auth_login' %}"
+      >{% block user-info-login-label %}Connexion{% endblock %}
+      {% if idp_registration_url and include_registration_link != False %}</a>{% endif %}
+      <span class="sep">/</span>
+      {% if idp_registration_url and include_registration_link != False %}<a class="registration" href="{{idp_registration_url}}"
+      >{% block user-info-registration-label %}Inscription{% endblock %}{% endif %}</a></span>
+  {% endif %}
+{% end_skeleton_extra_placeholder %}
+{% endblock %}
+</div>
+{% endif %}
diff --git a/templates/theme.html b/templates/theme.html
index b28bbb4a..19e38baa 100644
--- a/templates/theme.html
+++ b/templates/theme.html
@@ -60,18 +60,11 @@
        {% block header-title %}
        <h1 id="logo"><a accesskey="1" href="{% firstof logo_link_url portal_url '/' %}">{% firstof global_title site_title "Compte Citoyen" %}</a></h1>
        {% endblock %}
-       {% if include_top_links != False %}
-        <div id="toplinks">
-          {% block user-info %}
-          {% if user.is_authenticated %}
-          <span class="logged-in">
-            <span class="connected-user">{{user.first_name}} {{user.last_name}}</span>
-            <a class="logout" href="{% url 'auth_logout' %}">D&eacute;connexion</a>
-          </span>
-          {% endif %}
-          {% endblock %}
-        </div> <!-- toplinks -->
-        {% endif %}
+
+       {% block header-content %}
+         {% block top-links %}
+         {% endblock %}
+       {% endblock %}
      </div>
      {% block header-bottom %}{% endblock %}
     </div> <!-- header -->
-- 
2.20.1

