refactor pages

This commit is contained in:
Simon Vieille 2021-11-23 22:48:55 +01:00
parent e03f742d62
commit b6dd9f2347
21 changed files with 138 additions and 124 deletions

View file

@ -21,6 +21,26 @@ core:
name: 'Page de contenu' name: 'Page de contenu'
templates: templates:
- {name: "Par défaut", file: "page/simple/default.html.twig"} - {name: "Par défaut", file: "page/simple/default.html.twig"}
App\Entity\Page\PostPage:
name: 'Page article'
templates:
- {name: "Par défaut", file: "page/post/default.html.twig"}
App\Entity\Page\PostsPage:
name: 'Page d''articles'
templates:
- {name: "Par défaut", file: "page/posts/default.html.twig"}
App\Entity\Page\CategoryPage:
name: 'Page de categorie'
templates:
- {name: "Par défaut", file: "page/category/default.html.twig"}
App\Entity\Page\CategoriesPage:
name: 'Page des catégories'
templates:
- {name: "Par défaut", file: "page/categories/default.html.twig"}
App\Entity\Page\SearchPage:
name: 'Page de recherche'
templates:
- {name: "Par défaut", file: "page/search/default.html.twig"}
App\Entity\Page\ContactPage: App\Entity\Page\ContactPage:
name: 'Contact' name: 'Contact'
templates: templates:
@ -29,10 +49,6 @@ core:
name: 'Liens partagés' name: 'Liens partagés'
templates: templates:
- {name: "Par défaut", file: "page/links/default.html.twig"} - {name: "Par défaut", file: "page/links/default.html.twig"}
App\Entity\Page\TitledPage:
name: 'Page titrée'
templates:
- {name: "Par défaut", file: "page/titled/default.html.twig"}
App\Entity\Page\RssPage: App\Entity\Page\RssPage:
name: 'RSS' name: 'RSS'
templates: templates:
@ -45,6 +61,10 @@ core:
name: 'Texte' name: 'Texte'
templates: templates:
- {name: "Par défaut", file: "page/text/default.txt.twig"} - {name: "Par défaut", file: "page/text/default.txt.twig"}
App\Entity\Page\TitledPage:
name: '_'
templates:
- {name: "Par défaut", file: "page/text/default.txt.twig"}
file_manager: file_manager:
mimes: mimes:

View file

@ -23,7 +23,7 @@ class CategoryController extends PageController
{ {
$entities = $this->createQuery()->find(); $entities = $this->createQuery()->find();
return $this->defaultRender('blog/post/categories.html.twig', [ return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'categories' => $entities, 'categories' => $entities,
]); ]);
} }

View file

@ -75,7 +75,7 @@ class PostController extends PageController
$this->addFlash('error', 'Le formulaire n\'est pas valide.'); $this->addFlash('error', 'Le formulaire n\'est pas valide.');
} }
return $this->defaultRender('blog/post/post.html.twig', [ return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'post' => $post, 'post' => $post,
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);
@ -87,7 +87,7 @@ class PostController extends PageController
->paginate($page, 5) ->paginate($page, 5)
; ;
return $this->defaultRender('blog/post/posts.html.twig', [ return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'pager' => $entities, 'pager' => $entities,
]); ]);
} }
@ -104,7 +104,7 @@ class PostController extends PageController
; ;
} }
return $this->defaultRender('blog/post/search.html.twig', [ return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'pager' => $entities ?? null, 'pager' => $entities ?? null,
'query' => $query, 'query' => $query,
]); ]);
@ -134,7 +134,7 @@ class PostController extends PageController
); );
} }
return $this->defaultRender('blog/post/category.html.twig', [ return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'category' => $category, 'category' => $category,
'pager' => $entities, 'pager' => $entities,
]); ]);

View file

@ -0,0 +1,12 @@
<?php
namespace App\Entity\Page;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class CategoriesPage extends TitledPage
{
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Entity\Page;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class CategoryPage extends TitledPage
{
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Entity\Page;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class PostPage extends TitledPage
{
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Entity\Page;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class PostsPage extends TitledPage
{
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Entity\Page;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class SearchPage extends TitledPage
{
}

View file

@ -19,7 +19,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Blog - {% block meta_title %}{{ _page is defined ? _page.title.value }}{% endblock %}</title> <title>{% block meta_title %}{{ _page is defined ? _page.metaTitle }}{% endblock %}</title>
{% block metas %} {% block metas %}
<meta name="description" content="{% block meta_description %}{{ _page is defined and _page ? _page.metaDescription }}{% endblock %}"> <meta name="description" content="{% block meta_description %}{{ _page is defined and _page ? _page.metaDescription }}{% endblock %}">

View file

@ -4,7 +4,7 @@
<div class="wide-menu hidden-small"> <div class="wide-menu hidden-small">
<div class="fixed-menu"> <div class="fixed-menu">
<div class="align-center"> <div class="align-center">
<a href="{{ safe_path('blog_menu_posts') }}"> <a href="{{ safe_path('blog_menu_posts', {_domain: _domain}) }}">
{{ include('module/_logo.html.twig') }} {{ include('module/_logo.html.twig') }}
<span class="d-none">Accueil Deblan Blog</a> <span class="d-none">Accueil Deblan Blog</a>
@ -27,7 +27,7 @@
{%- endif -%} {%- endif -%}
{%- endset -%} {%- endset -%}
<a href="{{ safe_node_url(item) }}" {% if _store.isActiveNode(item, true) %}class="active"{% endif %} {% if item.hasExternalUrl %}target="_blank"{% endif %}> <a href="{{ safe_node_url(item, {_domain: _domain}) }}" {% if _store.isActiveNode(item, true) %}class="active"{% endif %} {% if item.hasExternalUrl %}target="_blank"{% endif %}>
{{- icon|raw -}} {{- icon|raw -}}
{{- item.label -}} {{- item.label -}}
</a> </a>
@ -63,7 +63,7 @@
<ul class="list--inline"> <ul class="list--inline">
{%- for item in menu.rootNode.children -%} {%- for item in menu.rootNode.children -%}
<li> <li>
<a href="{{ safe_node_url(item) }}"> <a href="{{ safe_node_url(item, {_domain: _domain}) }}">
{%- set icon -%} {%- set icon -%}
{%- if item.attributes.icon is defined -%} {%- if item.attributes.icon is defined -%}
<span class="deblan-icon deblan-icon-{{ item.attributes.icon.value }}"></span> <span class="deblan-icon deblan-icon-{{ item.attributes.icon.value }}"></span>

View file

@ -1,11 +1,4 @@
{% extends "base.html.twig" %} {% extends "page/titled/default.html.twig" %}
{% block page_title %}
Catégories
{% endblock %}
{% block page_subtitle %}
{% endblock %}
{% block body %} {% block body %}
<div class="col-12"> <div class="col-12">
@ -15,7 +8,8 @@
<li class="h3"> <li class="h3">
<a href="{{ safe_path('blog_menu_category', { <a href="{{ safe_path('blog_menu_category', {
category: category.id, category: category.id,
slug: category.slug slug: category.slug,
_domain: _domain,
}) }}"> }) }}">
{{- category.title -}} {{- category.title -}}
</a> </a>

View file

@ -1,17 +1,19 @@
{% extends 'blog/post/posts.html.twig' %} {% extends "page/titled/default.html.twig" %}
{%- block meta_title -%} {%- block meta_title -%}
{{- category.title -}} {{- parent()|build_string(category) -}}
{% endblock %}
{% block meta_description %}
{{- parent()|build_string(post) -}}
{% endblock %} {% endblock %}
{% block page_title %} {% block page_title %}
{{- category.title -}} {{- parent()|build_string(category) -}}
{% endblock %} {% endblock %}
{% block page_subtitle %} {% block page_subtitle %}
<p class="h3"> {{- parent()|build_string(category) -}}
{{- category.description -}}
</p>
{% endblock %} {% endblock %}
{% block pager %} {% block pager %}
@ -19,7 +21,8 @@
route: _node.routeName, route: _node.routeName,
routeParams: { routeParams: {
category: category.id, category: category.id,
slug: category.slug slug: category.slug,
_domain: _domain,
}, },
pages: pager.paginationData.endPage, pages: pager.paginationData.endPage,
currentPage: pager.paginationData.current currentPage: pager.paginationData.current

View file

@ -1,14 +1,4 @@
{% extends 'base.html.twig' %} {% extends "page/titled/default.html.twig" %}
{% block page_title %}
{{- _page.title.value -}}
{% endblock %}
{% block page_subtitle %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endblock %}
{% block body %} {% block body %}
<div class="col-12"> <div class="col-12">
@ -21,7 +11,7 @@
{% if showForm %} {% if showForm %}
<div class="body col-12"> <div class="body col-12">
<form class="form" method="POST" data-form-bot action="{{ safe_url('blog_tech_form_without_javascript', {page: app.request.uri}) }}"> <form class="form" method="POST" data-form-bot action="{{ safe_url('blog_tech_form_without_javascript', {page: app.request.uri, _domain: _domain}) }}">
<div class="row"> <div class="row">
<div class="field col-6"> <div class="field col-6">
{{ form_label(form.name) }} {{ form_label(form.name) }}

View file

@ -1,14 +1,4 @@
{% extends 'base.html.twig' %} {% extends "page/titled/default.html.twig" %}
{% block page_title %}
{{- _page.title.value -}}
{% endblock %}
{% block page_subtitle %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endblock %}
{% block css %} {% block css %}
{{- parent() -}} {{- parent() -}}

View file

@ -1,18 +1,4 @@
{% extends 'base.html.twig' %} {% extends "page/titled/default.html.twig" %}
{%- block meta_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_title -%}
{{- _page.title.value -}}
{% endblock %}
{% block page_subtitle %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endblock %}
{% block body %} {% block body %}
<div class="col-12"> <div class="col-12">

View file

@ -10,7 +10,7 @@
</head> </head>
<body> <body>
<div id="mesh-viewer" data-file="{{ path('mesh_download', {stlMesh: mesh.id, key: key}) }}"></div> <div id="mesh-viewer" data-file="{{ path('mesh_download', {stlMesh: mesh.id, key: key, _domain: _domain}) }}"></div>
<script src="{{ asset('stl_viewer/stl_viewer.min.js') }}"></script> <script src="{{ asset('stl_viewer/stl_viewer.min.js') }}"></script>
{{ encore_entry_script_tags('viewer') }} {{ encore_entry_script_tags('viewer') }}

View file

@ -41,6 +41,5 @@
{% set level = level + 1 %} {% set level = level + 1 %}
{% for child in comment.comments %} {% for child in comment.comments %}
{{ include('blog/post/_comment.html.twig', {level: level, comment: child}) }} {{ include('page/post/_comment.html.twig', {level: level, comment: child}) }}
{% endfor %} {% endfor %}

View file

@ -51,7 +51,7 @@
{% if not full %} {% if not full %}
<p> <p>
<a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug}) }}"> <a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug, _domain: _domain}) }}">
{{- 'Lien permanent' -}} {{- 'Lien permanent' -}}
</a> </a>
</p> </p>
@ -61,7 +61,7 @@
{% else %} {% else %}
{% if not full %} {% if not full %}
<h2 class="h2 no-margin"> <h2 class="h2 no-margin">
<a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug}) }}"> <a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug, _domain: _domain}) }}">
{{- post.title -}} {{- post.title -}}
</a> </a>
</h2> </h2>
@ -74,7 +74,7 @@
</li> </li>
{% for category in post.categories %} {% for category in post.categories %}
<li> <li>
<a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug}) }}"> <a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug, _domain: _domain}) }}">
{{- category.title -}} {{- category.title -}}
</a> </a>
</li> </li>
@ -82,7 +82,7 @@
{% for tag in post.tags %} {% for tag in post.tags %}
<li> <li>
<a href="{{ safe_path('blog_menu_search', {tag: tag.label}) }}"> <a href="{{ safe_path('blog_menu_search', {tag: tag.label, _domain: _domain}) }}">
{{- '#' ~ tag.label -}} {{- '#' ~ tag.label -}}
</a> </a>
</li> </li>
@ -116,13 +116,13 @@
{% if comments|length %} {% if comments|length %}
<div class="grid"> <div class="grid">
{% for comment in comments %} {% for comment in comments %}
{{ include('blog/post/_comment.html.twig', {comment: comment, level: 1}) }} {{ include('page/post/_comment.html.twig', {comment: comment, level: 1}) }}
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
<div class="grid" id="form"> <div class="grid" id="form">
<form class="form col-12" method="POST" data-form-bot action="{{ safe_url('blog_tech_form_without_javascript', {page: app.request.uri}) }}"> <form class="form col-12" method="POST" data-form-bot action="{{ safe_url('blog_tech_form_without_javascript', {page: app.request.uri, _domain: _domain}) }}">
{% if comments|length %} {% if comments|length %}
<hr> <hr>
{% endif %} {% endif %}
@ -151,7 +151,7 @@
<div class="field"> <div class="field">
<p class="no-margin"> <p class="no-margin">
{{- 'Votre commentaire - Vous pouvez utiliser du markdown ' }} {{- 'Votre commentaire - Vous pouvez utiliser du markdown ' }}
[<a title="Afficher l'aide" href="{{ safe_path('blog_tech_mardown') }}" target="_blank">?</a>] [<a title="Afficher l'aide" href="{{ safe_path('blog_tech_mardown', {_domain: _domain}) }}" target="_blank">?</a>]
</p> </p>
{{ form_errors(form.content) }} {{ form_errors(form.content) }}

View file

@ -1,11 +1,15 @@
{% extends "base.html.twig" %} {% extends "page/titled/default.html.twig" %}
{%- block meta_title -%} {%- block meta_title -%}
{{- post.title -}} {{- parent()|build_string(post) -}}
{% endblock %} {% endblock %}
{%- block page_title -%} {% block meta_description %}
{{- post.title -}} {{- parent()|build_string(post) -}}
{% endblock %}
{% block page_title %}
{{- parent()|build_string(post) -}}
{% endblock %} {% endblock %}
{%- block page_subtitle -%} {%- block page_subtitle -%}
@ -17,7 +21,7 @@
</li> </li>
{% for category in post.categories %} {% for category in post.categories %}
<li> <li>
<a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug}) }}"> <a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug, _domain: _domain}) }}">
{{- category.title -}} {{- category.title -}}
</a> </a>
</li> </li>
@ -25,7 +29,7 @@
{% for tag in post.tags %} {% for tag in post.tags %}
<li> <li>
<a href="{{ safe_path('blog_menu_search', {tag: tag.label}) }}"> <a href="{{ safe_path('blog_menu_search', {tag: tag.label, _domain: _domain}) }}">
{{- '#' ~ tag.label -}} {{- '#' ~ tag.label -}}
</a> </a>
</li> </li>
@ -34,7 +38,7 @@
{% endblock %} {% endblock %}
{%- block body -%} {%- block body -%}
{{ include('blog/post/_post.html.twig', {full: true}) }} {{ include('page/post/_post.html.twig', {full: true}) }}
{% endblock %} {% endblock %}
{%- block openGraph -%} {%- block openGraph -%}
@ -55,9 +59,9 @@
{% set name = '' %} {% set name = '' %}
{% endif %} {% endif %}
<link rel="canonical" href="{{ safe_url(_node.routeName, {post: post.id, slug: post.slug}) }}" /> <link rel="canonical" href="{{ safe_url(_node.routeName, {post: post.id, slug: post.slug, _domain: _domain}) }}" />
<meta property="og:title" content="{{ title|raw }}" /> <meta property="og:title" content="{{ _page.ogTitle|build_string(post) }}" />
<meta property="og:url" content="{{ safe_url(_node.routeName, {post: post.id, slug: post.slug}) }}" /> <meta property="og:url" content="{{ safe_url(_node.routeName, {post: post.id, slug: post.slug, _domain: _domain}) }}" />
{% if image %} {% if image %}
<meta property="og:image" content="{{ image }}" /> <meta property="og:image" content="{{ image }}" />

View file

@ -1,20 +1,4 @@
{% extends 'base.html.twig' %} {% extends "page/titled/default.html.twig" %}
{%- block meta_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_subtitle -%}
{% if _page.subTitle.value %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endif %}
{% endblock %}
{% block body %} {% block body %}
{% for post in pager %} {% for post in pager %}
@ -22,7 +6,7 @@
<hr class="col-12"> <hr class="col-12">
{% endif %} {% endif %}
{{ include('blog/post/_post.html.twig', {post: post}) }} {{ include('page/post/_post.html.twig', {post: post}) }}
{% endfor %} {% endfor %}
{% if pager.getPaginationData.pageCount > 1 %} {% if pager.getPaginationData.pageCount > 1 %}
@ -32,7 +16,7 @@
{% block pager %} {% block pager %}
{{ include('module/_pager.html.twig', { {{ include('module/_pager.html.twig', {
route: _node.routeName, route: _node.routeName,
routeParams: {}, routeParams: {_domain: _domain},
pages: pager.paginationData.endPage, pages: pager.paginationData.endPage,
currentPage: pager.paginationData.current currentPage: pager.paginationData.current
}) }} }) }}

View file

@ -1,20 +1,4 @@
{% extends 'base.html.twig' %} {% extends "page/titled/default.html.twig" %}
{%- block meta_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_subtitle -%}
{% if _page.subTitle.value %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endif %}
{% endblock %}
{% block body %} {% block body %}
<div class="col-12"> <div class="col-12">
@ -47,7 +31,7 @@
{% block pager %} {% block pager %}
{{ include('module/_pager.html.twig', { {{ include('module/_pager.html.twig', {
route: _node.routeName, route: _node.routeName,
routeParams: {query: query}, routeParams: {query: query, _domain: _domain},
pages: pager.paginationData.endPage, pages: pager.paginationData.endPage,
currentPage: pager.paginationData.current currentPage: pager.paginationData.current
}) }} }) }}