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'
templates:
- {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:
name: 'Contact'
templates:
@ -29,10 +49,6 @@ core:
name: 'Liens partagés'
templates:
- {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:
name: 'RSS'
templates:
@ -45,6 +61,10 @@ core:
name: 'Texte'
templates:
- {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:
mimes:

View File

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

View File

@ -75,7 +75,7 @@ class PostController extends PageController
$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,
'form' => $form->createView(),
]);
@ -87,7 +87,7 @@ class PostController extends PageController
->paginate($page, 5)
;
return $this->defaultRender('blog/post/posts.html.twig', [
return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'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,
'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,
'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 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 %}
<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="fixed-menu">
<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') }}
<span class="d-none">Accueil Deblan Blog</a>
@ -27,7 +27,7 @@
{%- endif -%}
{%- 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 -}}
{{- item.label -}}
</a>
@ -63,7 +63,7 @@
<ul class="list--inline">
{%- for item in menu.rootNode.children -%}
<li>
<a href="{{ safe_node_url(item) }}">
<a href="{{ safe_node_url(item, {_domain: _domain}) }}">
{%- set icon -%}
{%- if item.attributes.icon is defined -%}
<span class="deblan-icon deblan-icon-{{ item.attributes.icon.value }}"></span>

View File

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

View File

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

View File

@ -1,14 +1,4 @@
{% extends 'base.html.twig' %}
{% block page_title %}
{{- _page.title.value -}}
{% endblock %}
{% block page_subtitle %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endblock %}
{% extends "page/titled/default.html.twig" %}
{% block body %}
<div class="col-12">
@ -21,7 +11,7 @@
{% if showForm %}
<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="field col-6">
{{ form_label(form.name) }}

View File

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

View File

@ -1,18 +1,4 @@
{% extends 'base.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 %}
{% extends "page/titled/default.html.twig" %}
{% block body %}
<div class="col-12">

View File

@ -10,7 +10,7 @@
</head>
<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>
{{ encore_entry_script_tags('viewer') }}

View File

@ -41,6 +41,5 @@
{% set level = level + 1 %}
{% 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 %}

View File

@ -51,7 +51,7 @@
{% if not full %}
<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' -}}
</a>
</p>
@ -61,7 +61,7 @@
{% else %}
{% if not full %}
<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 -}}
</a>
</h2>
@ -74,7 +74,7 @@
</li>
{% for category in post.categories %}
<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 -}}
</a>
</li>
@ -82,7 +82,7 @@
{% for tag in post.tags %}
<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 -}}
</a>
</li>
@ -116,13 +116,13 @@
{% if comments|length %}
<div class="grid">
{% 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 %}
</div>
{% endif %}
<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 %}
<hr>
{% endif %}
@ -151,7 +151,7 @@
<div class="field">
<p class="no-margin">
{{- '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>
{{ form_errors(form.content) }}

View File

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

View File

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

View File

@ -1,20 +1,4 @@
{% extends 'base.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 %}
{% extends "page/titled/default.html.twig" %}
{% block body %}
<div class="col-12">
@ -47,7 +31,7 @@
{% block pager %}
{{ include('module/_pager.html.twig', {
route: _node.routeName,
routeParams: {query: query},
routeParams: {query: query, _domain: _domain},
pages: pager.paginationData.endPage,
currentPage: pager.paginationData.current
}) }}