]> Raphaël G. Git Repositories - blogbundle/commitdiff
New context layout
authorRaphaël Gertz <git@rapsys.eu>
Tue, 14 Oct 2025 09:45:25 +0000 (11:45 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 14 Oct 2025 09:45:25 +0000 (11:45 +0200)
Resources/views/_base.html.twig

index 7e2c1702f086d229555a0ec3e0bebdc6b6c8c728..0b103c0c9ee659163322241c5f3e247709f5db4c 100644 (file)
@@ -1,18 +1,57 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
-<html{% if head.locale is defined and head.locale %} lang="{{ head.locale }}"{% endif %}>
-       <head{% if head.facebook is defined and head.facebook is not empty %} prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"{% endif %}>
-               {% block head %}
-                       <meta charset="UTF-8" />
-                       <title>{{ head.title }}</title>
+<html{% if locale is defined and locale %} lang="{{ locale }}"{% endif %}>
+       <head{% if facebook is defined and facebook %} prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"{% endif %}>
+               {% block meta %}<meta charset="UTF-8">{% endblock %}
+               <title>{% block title %}{{ [title.page, title.section, title.site]|filter(v => v)|join(' - ') }}{% endblock %}</title>
+               {% block stylesheet %}
                        <meta name="viewport" content="width=device-width, initial-scale=1" />
                        <meta name="viewport" content="width=device-width, initial-scale=1" />
-                       {% if head.description is defined and head.description %}
-                               <meta name="description" content="{{ head.description }}" />
+                       {% if description is defined and description %}
+                               <meta name="description" content="{{ description }}" />
                        {% endif %}
                        {% endif %}
-                       {% if head.keywords is defined and head.keywords %}
-                               <meta name="keywords" content="{{ head.keywords }}" />
+                       {% if keywords is defined and keywords %}
+                               <meta name="keywords" content="{{ keywords|join(', ') }}" />
                        {% endif %}
                        {% endif %}
-                       {% if head.facebook is defined and head.facebook %}
-                               {% for property, contents in head.facebook %}
+                       {% if icon is defined and icon %}
+                               <link rel="shortcut icon" type="image/x-icon" href="{{ asset(icon.ico) }}" />
+                               <link rel="icon" type="image/svg+xml" href="{{ asset(icon.svg) }}" />
+                               {% for size, icon in icon.png %}
+                                       {# Apple #}
+                                       {% if size in [120, 152, 167, 180] %}
+                                               {% if size == 180 %}
+                                                       <link rel="apple-touch-icon" href="{{ asset(icon) }}" />
+                                               {% endif %}
+                                               <link rel="apple-touch-icon" sizes="{{ size }}x{{ size }}" href="{{ asset(icon) }}" />
+                                       {# Windows #}
+                                       {% elseif size in [70, 150, 310] %}
+                                               <meta name="msapplication-square{{ size }}x{{ size }}logo" content="{{ asset(icon) }}" />
+                                       {# Others #}
+                                       {% else %}
+                                               <link rel="icon" type="image/png" sizes="{{ size }}x{{ size }}" href="{{ asset(icon) }}" />
+                                       {% endif %}
+                               {% endfor %}
+                       {% endif %}
+                       {% stopwatch 'stylesheet' %}
+                               {# stylesheet '//fonts.googleapis.com/css?family=Irish+Grover' '//fonts.googleapis.com/css?family=La+Belle+Aurore' '@RapsysBlogBundle/css/{reset,screen}.css' #}
+                               {% stylesheet '@RapsysBlog/css/{reset,droidsans,lemon,notoemoji,screen}.css' %}
+                                       <link rel="stylesheet" type="text/css" href="{{ asset }}?{{ 'now'|date('U') }}" />
+                               {% endstylesheet %}
+                       {% endstopwatch %}
+                       {% if canonical is defined and canonical %}
+                               <link rel="canonical" href="{{ canonical }}"{% if locale is defined and locale %} hreflang="{{ locale }}"{% endif %} />
+                       {% endif %}
+                       {% if alternates is defined and alternates %}
+                               {% for lang, alternate in alternates %}
+                                       <link rel="alternate" href="{{ alternate.absolute }}" hreflang="{{ lang }}" />
+                               {% endfor %}
+                       {% endif %}
+                       {% if prev is defined and prev %}
+                               <link rel="prev" href="{{ prev }}" hreflang="{{ locale }}" />
+                       {% endif %}
+                       {% if next is defined and next %}
+                               <link rel="next" href="{{ next }}" hreflang="{{ locale }}" />
+                       {% endif %}
+                       {% if facebook is defined and facebook %}
+                               {% for property, contents in facebook %}
                                        {% if contents is iterable %}
                                                {% for content in contents %}
                                                        <meta property="{{ property }}" content="{{ content }}" />
                                        {% if contents is iterable %}
                                                {% for content in contents %}
                                                        <meta property="{{ property }}" content="{{ content }}" />
                                        {% endif %}
                                {% endfor %}
                        {% endif %}
                                        {% endif %}
                                {% endfor %}
                        {% endif %}
-                       {% block link %}
-                               {% if head.icon.ico is defined and head.icon.ico is not empty %}
-                                       <link rel="shortcut icon" type="image/x-icon" href="{{ asset(head.icon.ico) }}" />
-                               {% endif %}
-                               {% if head.icon.png is defined and head.icon.png is not empty %}
-                                       {% for size, icon in head.icon.png %}
-                                               {# Apple #}
-                                               {% if size in [120, 152, 167, 180] %}
-                                                       {% if size == 180 %}
-                                                               <link rel="apple-touch-icon" href="{{ asset(icon) }}" />
-                                                       {% endif %}
-                                                       <link rel="apple-touch-icon" sizes="{{ size }}x{{ size }}" href="{{ asset(icon) }}" />
-                                               {# Windows #}
-                                               {% elseif size in [70, 150, 310] %}
-                                                       <meta name="msapplication-square{{ size }}x{{ size }}logo" content="{{ asset(icon) }}" />
-                                               {# Others #}
-                                               {% else %}
-                                                       <link rel="icon" type="image/png" sizes="{{ size }}x{{ size }}" href="{{ asset(icon) }}" />
-                                               {% endif %}
-                                       {% endfor %}
-                               {% endif %}
-                               {% if head.icon.svg is defined and head.icon.svg is not empty %}
-                                       <link rel="icon" type="image/svg+xml" href="{{ asset(head.icon.svg) }}" />
-                               {% endif %}
-                               {# stylesheet '//fonts.googleapis.com/css?family=Irish+Grover' '//fonts.googleapis.com/css?family=La+Belle+Aurore' '@RapsysBlogBundle/Resources/public/css/{reset,screen}.css' #}
-                               {% stylesheet '@RapsysBlog/css/{reset,droidsans,lemon,notoemoji,screen}.css' %}
-                                       <link rel="stylesheet" type="text/css" href="{{ asset_url }}?{{ 'now'|date('U') }}" />
-                               {% endstylesheet %}
-                               {% stopwatch 'stylesheet' %}
-                               {% endstopwatch %}
-                               {% if head.canonical is defined and head.canonical %}
-                                       <link rel="canonical" href="{{ head.canonical }}"{% if head.locale is defined and head.locale %} hreflang="{{ head.locale }}"{% endif %} />
-                               {% endif %}
-                               {% if head.alternates is defined and head.alternates %}
-                                       {% for lang, alternate in head.alternates %}
-                                               <link rel="alternate" href="{{ alternate.absolute }}" hreflang="{{ lang }}" />
-                                       {% endfor %}
-                               {% endif %}
-                               {% if head.prev is defined and head.prev %}
-                                       <link rel="prev" href="{{ head.prev }}" hreflang="{{ head.locale }}" />
-                               {% endif %}
-                               {% if head.next is defined and head.next %}
-                                       <link rel="next" href="{{ head.next }}" hreflang="{{ head.locale }}" />
-                               {% endif %}
-                       {% endblock %}
                {% endblock %}
        </head>
        <body>
                {% block body %}
                        {% block header %}
                                <header id="header">
                {% endblock %}
        </head>
        <body>
                {% block body %}
                        {% block header %}
                                <header id="header">
-                                       <a id="logo" href="{{ path(head.root) }}" title="{{ head.site }}">
-                                               <img src="{{ asset(head.logo.svg) }}?20221024100144" srcset="{{ asset(head.logo.png) }}?20221024100144 200w, {{ asset(head.logo.svg) }}?20221024100144 400w" sizes="(min-width:400px) 400px, 200px" alt="{{ head.logo.alt }}" width="100" height="60" />
-                                               <strong>{{ head.site }}</strong>
-                                       </a>
-                                       <nav id="nav">
-                                               <a href="{{ path('rapsys_blog') }}" rel="home">{% trans %}Home{% endtrans %}</a>
-                                               <a href="{{ path('rapsys_blog_contact') }}" rel="contact">{% trans %}Contact{% endtrans %}</a>
-                                               {#<a href="{{ path('rapsys_blog_frequently_asked_questions') }}">{% trans %}Frequently asked questions{% endtrans %}</a>#}
-                                               {#{% if is_granted('ROLE_ADMIN') %}#}
-                                                       <a href="{{ path('rapsys_blog_user') }}">{% trans %}Users{% endtrans %}</a>
-                                               {#{% endif %}#}
-                                               {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
-                                                       <a href="{{ path('rapsys_user_edit', {mail: app.user.mail|short, hash: app.user.mail|short|hash}) }}">{% trans %}My account{% endtrans %}</a>
-                                                       <a href="{{ path('rapsys_user_logout') }}">{% trans %}Logout{% endtrans %}</a>
-                                               {% else %}
-                                                       <a href="{{ path('rapsys_user_login') }}">{% trans %}Login{% endtrans %}</a>
-                                                       <a href="{{ path('rapsys_user_register') }}">{% trans %}Register{% endtrans %}</a>
-                                               {% endif %}
-                                       </nav>
-                                       {#{% block site_subtitle %}{% endblock %}
-                                       {% block site_tagline %}
-                                               {% if tags is defined and tags %}
-                                                       <ul>
-                                                               {% for id, tag in tags %}
-                                                                       <li><h2><a href="#{{id}}">{{tag}}</a></h2></li>
-                                                               {% endfor %}
-                                                       </ul>
-                                               {% endif %}
-                                       {% endblock %}#}
+                                       {% if logo is defined and logo %}
+                                               {% block header_title %}
+                                                       <a id="logo" href="{{ root }}" title="{{ title.site }}">
+                                                               <img src="{{ asset(logo.svg) }}?{{ 'now'|date('U') }}" srcset="{{ asset(logo.png) }}?{{ 'now'|date('U') }} 200w, {{ asset(logo.svg) }}?{{ 'now'|date('U') }} 400w" sizes="(min-width:400px) 400px, 200px" alt="{{ title.site }}" width="100" height="45" />
+                                                               <strong>{{ title.site }}</strong>
+                                                       </a>
+                                               {% endblock %}
+                                       {% endif %}
+                                       {% block header_nav %}
+                                               <nav id="nav">
+                                                       <a href="{{ path('rapsysblog') }}" rel="home">{% trans %}Home{% endtrans %}</a>
+                                                       <a href="{{ path('rapsysblog_contact') }}" rel="contact">{% trans %}Contact{% endtrans %}</a>
+                                                       {#<a href="{{ path('rapsysblog_frequently_asked_questions') }}">{% trans %}Frequently asked questions{% endtrans %}</a>#}
+                                                       {#{% if is_granted('ROLE_ADMIN') %}#}
+                                                               <a href="{{ path('rapsysblog_user') }}">{% trans %}Users{% endtrans %}</a>
+                                                       {#{% endif %}#}
+                                                       {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
+                                                               <a href="{{ path('rapsysuser_edit', {mail: app.user.mail|short, hash: app.user.mail|short|hash}) }}">{% trans %}My account{% endtrans %}</a>
+                                                               <a href="{{ path('rapsysuser_logout') }}">{% trans %}Logout{% endtrans %}</a>
+                                                       {% else %}
+                                                               <a href="{{ path('rapsysuser_login') }}">{% trans %}Login{% endtrans %}</a>
+                                                               <a href="{{ path('rapsysuser_register') }}">{% trans %}Register{% endtrans %}</a>
+                                                       {% endif %}
+                                               </nav>
+                                       {% endblock %}
+                                       {#
+                                               {% block header_subtitle %}{% endblock %}
+                                               {% block header_tagline %}
+                                                       {% if tags is defined and tags %}
+                                                               <ul>
+                                                                       {% for id, tag in tags %}
+                                                                               <li><h2><a href="#{{id}}">{{tag}}</a></h2></li>
+                                                                       {% endfor %}
+                                                               </ul>
+                                                       {% endif %}
+                                               {% endblock %}
+                                       #}
                                </header>
                        {% endblock %}
                        {% block message %}
                                </header>
                        {% endblock %}
                        {% block message %}
                                        {% endif %}
                                {% endfor %}
                        {% endblock %}
                                        {% endif %}
                                {% endfor %}
                        {% endblock %}
-               {% endblock %}
-               {#{% block sidebar %}<aside id="sidebar"></aside>{% endblock %}#}
-               {% block content %}
-                       <article>
-                               <header>
-                                       {% block title %}<h1 id="title"><a href="{{ head.canonical }}">{{ title }}</a></h1>{% endblock %}>
-                                       <p>{{ description }}</p>
-                               </header>
-                       </article>
-               {% endblock %}
-               {% block footer %}
-                       <footer id="footer">
-                               <a href="{{ path('rapsys_blog_about') }}">{% trans %}About{% endtrans %}</a>
-                               {% if copy is defined and copy %}
-                                       <details><summary>{{ copy.long }}</summary><span>{{ copy.short }} <a href="{{ copy.link }}" title="{{ copy.title }}" rel="author">{{ copy.by }}</a></span></details>
-                               {% endif %}
-                               {#<a href="{{ path('rapsys_blog_terms_of_service') }}">{% trans %}Terms of service{% endtrans %}</a>#}
-                               {% if head.alternates is defined and head.alternates %}
-                                       {% set langs = head.alternates|keys|filter(v => v|length == 5) %}
-                                       {% if langs|length > 1 %}
-                                               <ul>
-                                                       {% for lang in langs %}
-                                                               <li><a href="{{ head.alternates[lang].relative }}" hreflang="{{ lang|replace({'_': '-'}) }}" title="{{ head.alternates[lang].title }}">{{ head.alternates[lang].translated }}</a></li>
-                                                       {% endfor %}
-                                               </ul>
+                       {#{% block sidebar %}<aside id="sidebar"></aside>{% endblock %}#}
+                       {% block content %}
+                               <article>
+                                       <header>
+                                               {% block content_title %}<h1 id="title"><a href="{{ canonical }}">{{ title.page }}</a></h1>{% endblock %}>
+                                               <p>{{ description }}</p>
+                                       </header>
+                               </article>
+                       {% endblock %}
+                       {% block footer %}
+                               <footer id="footer">
+                                       <a href="{{ path('rapsysblog_about') }}">{% trans %}About{% endtrans %}</a>
+                                       {% if copy is defined and copy %}
+                                               <details><summary>{{ copy.long }}</summary><span>{{ copy.short }} <a href="{{ copy.link }}" title="{{ copy.title }}" rel="author">{{ copy.by }}</a></span></details>
+                                       {% endif %}
+                                       {#<a href="{{ path('rapsysblog_terms_of_service') }}">{% trans %}Terms of service{% endtrans %}</a>#}
+                                       {% if alternates is defined and alternates %}
+                                               {% set langs = alternates|keys|filter(v => v|length == 5) %}
+                                               {% if langs|length > 1 %}
+                                                       <ul>
+                                                               {% for lang in langs %}
+                                                                       <li><a href="{{ alternates[lang].relative }}" hreflang="{{ lang|replace({'_': '-'}) }}" title="{{ alternates[lang].title }}">{{ alternates[lang].translated }}</a></li>
+                                                               {% endfor %}
+                                                       </ul>
+                                               {% else %}
+                                                       {% set lang = langs|first %}
+                                                       <a href="{{ alternates[lang].relative }}" hreflang="{{ lang|replace({'_': '-'}) }}" title="{{ alternates[lang].title }}">{{ alternates[lang].translated }}</a>
+                                               {% endif %}
                                        {% else %}
                                        {% else %}
-                                               {% set lang = langs|first %}
-                                               <a href="{{ head.alternates[lang].relative }}" hreflang="{{ lang|replace({'_': '-'}) }}" title="{{ head.alternates[lang].title }}">{{ head.alternates[lang].translated }}</a>
+                                               <span>&nbsp;</span>
                                        {% endif %}
                                        {% endif %}
-                               {% else %}
-                                       <span>&nbsp;</span>
-                               {% endif %}
-                       </footer>
+                               </footer>
+                       {% endblock %}
                {% endblock %}
                {% endblock %}
-               {% block javascripts %}
+               {% block javascript %}
                        {% stopwatch 'javascript' %}
                                {#{% javascript '@RapsysBlog/js/*.js' %}
                                        <script type="text/javascript" src="{{ asset_url }}"></script>
                        {% stopwatch 'javascript' %}
                                {#{% javascript '@RapsysBlog/js/*.js' %}
                                        <script type="text/javascript" src="{{ asset_url }}"></script>