update default template

This commit is contained in:
Simon Vieille 2022-02-21 23:58:08 +01:00
parent e50d2668f9
commit d7659735cb
6 changed files with 68 additions and 110 deletions

View File

@ -1,5 +1 @@
$theme-colors: (
"primary": #1ab5dc,
"primary-light": lighten(#3183aa, 40%),
"dark-blue": #1e2430,
) !default;

0
assets/css/app.scss Normal file
View File

1
assets/js/app.js Normal file
View File

@ -0,0 +1 @@
import '../css/app.scss'

View File

@ -1,19 +1,62 @@
{% apply spaceless %}
<!DOCTYPE html>
<html>
<html lang="{{ _locale }}">
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
{# Run `composer require symfony/webpack-encore-bundle`
and uncomment the following Encore helpers to start using Symfony UX #}
{% block stylesheets %}
{#{{ encore_entry_link_tags('app') }}#}
{% endblock %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% block javascripts %}
{#{{ encore_entry_script_tags('app') }}#}
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('build/images/logo.png') }}" />
{%- block opengraph -%}
<meta property="og:title" content="{{ _page.ogTitle }}" />
<meta property="og:description" content="{{ _page.ogDescription }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ app.request.uri }}" />
{%- if _page.ogImage -%}
<meta property="og:image" content="{{ absolute_url(asset(_page.ogImage)) }}" />
{%- endif -%}
{%- endblock -%}
{%- block stylesheets -%}
{{ encore_entry_link_tags('app') }}
{%- endblock -%}
<title>{{ _page.metaTitle }}</title>
</head>
<body>
{% block body %}{% endblock %}
{#
- The current node is `_node` and its menu is `_menu`
- The current navigation is `_navigation`
- The current locale is `_locale`
- Retrieve all navigations: `_store.navigations`
- Retrieve a navigation by its code: `_store.navigation('the_code')`
- Retrieve all navigation menus: `_navigation.menus`
- Retrieve a menu by its code: `_navigation.menu('the_code')`
- Retrieve all nodes of a menu: `menu.rootNode.children`
- Retrieve visible nodes of a menu: `menu.rootNode.children({visible: true})`
- Test if a node is the current one: `_store.isActiveNode(node)`
- Test if a node is or contains the current one: `_store.isActiveNode(node, true)`
- Generate a node url:
```
{% if node.hasExternalUrl or node.hasAppUrl %}
{% set url = node.url %}
{% else %}
{% set url = safe_node_path(node) %}
{% endif %}
```
- Generate a node url when the navigation has several domains: `safe_node_path(node, {_domain: _domain})`
#}
{% block page %}{% endblock %}
{%- block javascripts -%}
{{ encore_entry_script_tags('app') }}
{%- endblock -%}
</body>
</html>
{% endapply %}

View File

@ -1,99 +1,16 @@
{% import _self as macros %}
{% extends 'base.html.twig' %}
{% macro item(node, store) %}
{% set isActive = store.isActiveNode(node, true) %}
{%- block page -%}
<h1>{{ _page.title.value }}</h1>
{% if node.isVisible %}
{% if node.code == 'post' %}
<a {% if isActive %}style="color: red"{% endif %} href="{{ url(node.routeName, {post: 1}) }}">
{{ node.label }}
</a>
{% elseif node.page %}
{% set url = node.hasExternalUrl ? node.url : url(node.routeName) %}
{{ _page.content.value|murph_url|file_attributes|raw }}
<a {% if isActive %}style="color: red"{% endif %} href="{{ url }}">
{{ node.label }}
</a>
{% else %}
<span {% if isActive %}style="color: red"{% endif %}>
{{ node.label }}
</span>
{% endif %}
<hr>
{% if node.children|length %}
<ul>
{% for child in node.children %}
{% if child.isVisible %}
<li>
{{ macros.item(child, store) }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% set image = _page.image.value %}
{% if image %}
<img src="{{ asset(image) }}" alt="{{ image|file_attribute('alt') }}" title="{{ image|file_attribute('title') }}">
{% endif %}
{% endmacro %}
{%- endblock -%}
{% macro menu(menu, store) %}
<ul>
{% for child in menu.rootNode.children %}
{% if child.isVisible %}
<li>
{{ macros.item(child, store) }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endmacro %}
<h1>{{ _page.title.value }}</h1>
<pre>{{ _page.content.value|murph_url|file_attributes }}</pre>
{% set image = _page.image.value %}
{% if image %}
<img src="{{ asset(image) }}" alt="">
{% endif %}
<h1>Request</h1>
<ul>
<li>
Node: {{ _node.label }}
</li>
<li>
Menu: {{ _menu.label }}
</li>
<li>
Navigation: {{ _navigation.label }}
</li>
<li>
Locale:
<ul>
<li>
Var: {{ _locale }}
</li>
<li>
Navigation: {{ _navigation.locale }}
</li>
<li>
Request: {{ app.request.attributes.get('_locale') }}
</li>
<li>
Test: {{ 'This is a test of translation'|trans }}
</li>
</ul>
</li>
</ul>
<h1>Menus</h1>
{# {% set menu = _navigation.menu('top') %} #}
{% for menu in _navigation.menus %}
<h2>{{ menu.label }} / {{ menu.code }}</h2>
{{ macros.menu(menu, _store) }}
{% endfor %}

View File

@ -21,6 +21,7 @@ Encore
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('admin', './assets/js/admin.js')
.addEntry('app', './assets/js/app.js')
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()