recherche full texte

This commit is contained in:
2026-12-01 21:11:30 +01:00
parent d021058b11
commit 1ea6326bf4
16 changed files with 833 additions and 15 deletions
+315
View File
@@ -0,0 +1,315 @@
uuid: f0aef62b-1654-481b-9951-b41d088053c9
langcode: fr
status: true
dependencies:
config:
- search_api.server.base_de_donnees
module:
- node
- search_api
id: contenu
name: Contenu
description: 'Projets et événements, avec les personnes, lieux, partenaires et types qui y sont liés.'
read_only: false
field_settings:
accompagnants:
label: 'Accompagné·e(s) par'
datasource_id: 'entity:node'
property_path: 'field_invite_accompagne_curate_p:entity:title'
type: text
boost: 3.0
accompagnants_bio:
label: 'Accompagné·e(s) par : biographie'
datasource_id: 'entity:node'
property_path: 'field_invite_accompagne_curate_p:entity:body'
type: text
boost: 0.3
artistes:
label: 'Artiste(s) invité(s)'
datasource_id: 'entity:node'
property_path: 'field_artiste_s_invite_s:entity:title'
type: text
boost: 3.0
artistes_bio:
label: 'Artiste(s) invité(s) : biographie'
datasource_id: 'entity:node'
property_path: 'field_artiste_s_invite_s:entity:body'
type: text
boost: 0.3
body:
label: Texte
datasource_id: 'entity:node'
property_path: body
type: text
evenements_lies:
label: 'Événement(s) lié(s)'
datasource_id: 'entity:node'
property_path: 'field_evenement_s_lie_s:entity:title'
type: text
infos_pratiques:
label: 'Infos pratiques'
datasource_id: 'entity:node'
property_path: field_infos_pratiques
type: text
language_with_fallback:
label: 'Langue (avec repli)'
property_path: language_with_fallback
type: string
lieu:
label: Lieu
datasource_id: 'entity:node'
property_path: 'field_lieu:entity:title'
type: text
boost: 2.0
lieu_ville:
label: 'Lieu : ville'
datasource_id: 'entity:node'
property_path: 'field_lieu:entity:field_address:locality'
type: text
boost: 2.0
partenaires:
label: Partenaire(s)
datasource_id: 'entity:node'
property_path: 'field_partenaire_s:entity:title'
type: text
boost: 2.0
projets_lies:
label: 'Projet(s) lié(s)'
datasource_id: 'entity:node'
property_path: 'field_projet_s_lie_s:entity:title'
type: text
status:
label: Publié
datasource_id: 'entity:node'
property_path: status
type: boolean
indexed_locked: true
type_locked: true
title:
label: Titre
datasource_id: 'entity:node'
property_path: title
type: text
boost: 8.0
type:
label: 'Type de contenu'
datasource_id: 'entity:node'
property_path: type
type: string
type_d_evenement:
label: "Type d'événement"
datasource_id: 'entity:node'
property_path: 'field_type_d_evenement:entity:name'
type: text
boost: 2.0
type_de_projet:
label: 'Type de projet'
datasource_id: 'entity:node'
property_path: 'field_type_de_projet:entity:name'
type: text
boost: 2.0
datasource_settings:
'entity:node':
bundles:
default: false
selected:
- evenement
- projet
languages:
default: true
selected: { }
processor_settings:
add_url: { }
aggregated_field: { }
entity_status: { }
entity_type: { }
html_filter:
weights:
preprocess_index: -15
preprocess_query: -15
all_fields: false
fields:
- accompagnants_bio
- artistes_bio
- body
- infos_pratiques
title: false
alt: false
tags:
b: 2.0
h2: 3.0
h3: 2.0
strong: 2.0
ignorecase:
weights:
preprocess_index: -20
preprocess_query: -20
all_fields: true
fields:
- accompagnants
- accompagnants_bio
- artistes
- artistes_bio
- body
- evenements_lies
- infos_pratiques
- lieu
- lieu_ville
- partenaires
- projets_lies
- title
- type_d_evenement
- type_de_projet
language_with_fallback: { }
stopwords:
weights:
preprocess_index: -5
preprocess_query: -2
all_fields: true
fields:
- accompagnants
- accompagnants_bio
- artistes
- artistes_bio
- body
- evenements_lies
- infos_pratiques
- lieu
- lieu_ville
- partenaires
- projets_lies
- title
- type_d_evenement
- type_de_projet
stopwords:
- a
- an
- and
- au
- aux
- avec
- c
- ce
- ces
- d
- dans
- de
- des
- du
- elle
- en
- est
- et
- eux
- for
- il
- in
- j
- je
- l
- la
- le
- les
- leur
- lui
- m
- ma
- mais
- me
- mes
- moi
- mon
- même
- 'n'
- ne
- nos
- notre
- nous
- of
- 'on'
- 'on'
- ou
- par
- pas
- pour
- qu
- que
- qui
- s
- sa
- se
- ses
- son
- sont
- sur
- t
- ta
- te
- tes
- the
- to
- toi
- ton
- tu
- un
- une
- vos
- votre
- vous
- with
- 'y'
- été
- être
tokenizer:
weights:
preprocess_index: -6
preprocess_query: -6
all_fields: true
fields:
- accompagnants
- accompagnants_bio
- artistes
- artistes_bio
- body
- evenements_lies
- infos_pratiques
- lieu
- lieu_ville
- partenaires
- projets_lies
- title
- type_d_evenement
- type_de_projet
spaces: ''
ignored: ._-
overlap_cjk: 1
minimum_word_size: '2'
transliteration:
weights:
preprocess_index: -20
preprocess_query: -20
all_fields: true
fields:
- accompagnants
- accompagnants_bio
- artistes
- artistes_bio
- body
- evenements_lies
- infos_pratiques
- lieu
- lieu_ville
- partenaires
- projets_lies
- title
- type_d_evenement
- type_de_projet
tracker_settings:
default:
indexing_order: fifo
options:
cron_limit: 50
delete_on_fail: true
index_directly: true
track_changes_in_references: true
server: base_de_donnees
@@ -0,0 +1,18 @@
uuid: e46c37b4-c965-47d3-82e7-7823b2a09545
langcode: fr
status: true
dependencies:
module:
- search_api_db
id: base_de_donnees
name: 'Base de données'
description: 'Recherche plein texte du site, stockée dans MariaDB.'
backend: search_api_db
backend_config:
database: 'default:default'
min_chars: 2
matching: partial
phrase: bigram
autocomplete:
suggest_suffix: true
suggest_words: true
+229
View File
@@ -0,0 +1,229 @@
uuid: e13e2f8f-827c-4fd1-b801-25eb51391d5d
langcode: fr
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- search_api.index.contenu
module:
- search_api
id: recherche
label: Recherche
module: views
description: 'Résultats de la recherche plein texte (projets et événements).'
tag: ''
base_table: search_api_index_contenu
base_field: search_api_id
display:
default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options:
title: Recherche
pager:
type: full
options:
offset: 0
items_per_page: 24
total_pages: null
id: 0
tags:
next: ›
previous: ‹
first: «
last: »
expose:
items_per_page: false
items_per_page_label: 'Éléments par page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- Tout -'
offset: false
offset_label: Décalage
quantity: 9
exposed_form:
type: input_required
options:
submit_button: Rechercher
reset_button: false
reset_button_label: Réinitialiser
exposed_sorts_label: 'Trier par'
expose_sort_order: false
sort_asc_label: Asc
sort_desc_label: Desc
text_input_required: ''
text_input_required_format: plain_text
access:
type: perm
options:
perm: 'access content'
cache:
type: search_api_tag
options: { }
empty:
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
relationship: none
group_type: group
admin_label: ''
plugin_id: text_custom
empty: true
content: 'Aucun résultat.'
tokenize: false
sorts:
search_api_relevance:
id: search_api_relevance
table: search_api_index_contenu
field: search_api_relevance
relationship: none
group_type: group
admin_label: ''
plugin_id: search_api
order: DESC
expose:
label: ''
field_identifier: ''
exposed: false
arguments: { }
filters:
search_api_fulltext:
id: search_api_fulltext
table: search_api_index_contenu
field: search_api_fulltext
relationship: none
group_type: group
admin_label: ''
plugin_id: search_api_fulltext
operator: and
value: ''
group: 1
exposed: true
expose:
operator_id: search_api_fulltext_op
label: Rechercher
description: ''
use_operator: false
operator: search_api_fulltext_op
operator_limit_selection: false
operator_list: { }
identifier: search
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
placeholder: 'Rechercher sur le site…'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
parse_mode: terms
min_length: 2
fields: { }
language_with_fallback:
id: language_with_fallback
table: search_api_index_contenu
field: language_with_fallback
relationship: none
group_type: group
admin_label: ''
plugin_id: search_api_language
operator: in
value:
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
style:
type: default
row:
type: search_api
options:
view_modes:
'entity:node':
evenement: teaser
projet: teaser
query:
type: search_api_query
options:
bypass_access: false
skip_access: false
preserve_facet_query_args: false
query_tags: { }
relationships: { }
css_class: views-recherche
header: { }
footer: { }
rendering_language: '***LANGUAGE_entity_translation***'
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags:
- 'config:search_api.index.contenu'
- 'search_api_list:contenu'
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 1
display_options:
display_extenders: { }
path: recherche
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags:
- 'config:search_api.index.contenu'
- 'search_api_list:contenu'
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -91,6 +91,9 @@ gsap.registerPlugin(ScrollTrigger);
let header_right = document.getElementById('burger-btn'); let header_right = document.getElementById('burger-btn');
header_right.parentElement.addEventListener('click', function(e){ header_right.parentElement.addEventListener('click', function(e){
// console.log('click header_right', this); // console.log('click header_right', this);
// Le champ de recherche du burger vit dans ce conteneur : y cliquer
// (pour saisir, ou sur la loupe) ne doit pas refermer le menu.
if (e.target.closest('form')) return;
this.firstElementChild.toggleAttribute('opened'); this.firstElementChild.toggleAttribute('opened');
this.firstElementChild.nextElementSibling.toggleAttribute('opened'); this.firstElementChild.nextElementSibling.toggleAttribute('opened');
}) })
@@ -6,6 +6,7 @@
@use "partials/global/base"; @use "partials/global/base";
@use "partials/global/layout"; @use "partials/global/layout";
@use "partials/global/header"; @use "partials/global/header";
@use "partials/global/search-form";
@use "partials/global/variable-titles"; @use "partials/global/variable-titles";
// ── Pages (l'ordre ci-dessous EST la cascade) ────────────────────────────── // ── Pages (l'ordre ci-dessous EST la cascade) ──────────────────────────────
@@ -15,3 +16,4 @@
@use "partials/pages/evenement"; @use "partials/pages/evenement";
@use "partials/pages/views-archives-projets"; @use "partials/pages/views-archives-projets";
@use "partials/pages/views-archives-evenements"; @use "partials/pages/views-archives-evenements";
@use "partials/pages/recherche";
@@ -135,12 +135,22 @@ header[role="banner"]{
grid-row: 1 / -1; grid-row: 1 / -1;
} }
// Recherche (templates/search-form.html.twig) : sous la langue.
>form.search-pill{
--search-pill-width: 22rem;
margin-top: 1.5em;
font-size: 1.1em;
}
@media #{$mobile}{ @media #{$mobile}{
grid-template-columns: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
grid-template-rows: none; grid-template-rows: none;
>div#block-leshed-config-pages{ >div#block-leshed-config-pages{
grid-column: 1; grid-column: 1;
grid-row: auto; grid-row: auto;
// Après la recherche, qui suit la langue (maquette p. 24).
order: 1;
margin-top: 1.5em;
} }
} }
} }
@@ -0,0 +1,65 @@
// ____ _
// / ___| ___ __ _ _ __ ___| |__
// \___ \ / _ \/ _` | '__/ __| '_ \
// ___) | __/ (_| | | | (__| | | |
// |____/ \___|\__,_|_| \___|_| |_|
//
// Champ de recherche « pilule » (templates/search-form.html.twig) : burger
// et page /recherche (maquette p. 3, 22, 24). Contour noir fin, loupe à
// droite ; la largeur est donnée par le contexte (--search-pill-width).
form.search-pill{
display: flex;
align-items: center;
box-sizing: border-box;
width: var(--search-pill-width, 16rem);
max-width: 100%;
height: 2.3em;
padding: 0 0.35em 0 1em;
border: 1px solid #000;
border-radius: 999px;
background-color: #fff;
input[type="search"]{
flex: 1 1 auto;
min-width: 0;
height: 100%;
padding: 0;
border: 0;
background: transparent;
font: inherit;
font-weight: 300;
color: #000;
outline: none;
-webkit-appearance: none;
appearance: none;
&::placeholder{
color: #555;
opacity: 1;
}
// Croix native d'effacement : pas dans la maquette.
&::-webkit-search-cancel-button{
-webkit-appearance: none;
}
}
button{
flex: 0 0 auto;
display: flex;
align-items: center;
justify-content: center;
width: 2em;
height: 2em;
padding: 0;
border: 0;
background: transparent;
color: #000;
cursor: pointer;
}
// Focus : le contour s'épaissit (pas d'anneau extérieur, absent de la
// maquette, mais un repère visible au clavier).
&:focus-within{
box-shadow: 0 0 0 1px #000;
}
}
@@ -0,0 +1,98 @@
// ____ _ _
// | _ \ ___ ___| |__ ___ _ __ ___| |__ ___
// | |_) / _ \/ __| '_ \ / _ \ '__/ __| '_ \ / _ \
// | _ < __/ (__| | | | __/ | | (__| | | | __/
// |_| \_\___|\___|_| |_|\___|_| \___|_| |_|\___|
//
// Page /recherche (vue recherche, page_1 — maquette p. 22) : en-tête
// « Résultats pour la recherche "…" » + champ à droite, grille de teasers.
@use "../abstracts/variables" as *;
@use "../abstracts/nodes-on-liste" as *;
@use "../abstracts/breakpoints" as *;
@mixin carteRecherche{
>header>h2{
font-size: 3em;
}
.body,
.field_infos_pratiques,
.field_lieu{
display: none;
}
.field_artiste_s_invite_s,
.field_type_de_projet,
.field_type_d_evenement{
font-size: 0.9em;
font-weight: 300;
line-height: 1.3;
}
.field_artiste_s_invite_s{
margin-top: 0.4em;
}
}
div.views-recherche{
>header.recherche-header{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: 1em $colsgap;
padding: 1em 0 2.5em;
p.recherche-resume{
margin: 0;
em{
font-style: italic;
font-weight: 600;
}
}
form.search-pill{
--search-pill-width: 15rem;
}
}
// Même grille que les archives projets : 4 colonnes, 2 en mobile.
div.view-content{
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
column-gap: $colsgap;
row-gap: 0;
align-items: start;
>.views-row{
margin-bottom: $colsgap;
display: flex;
flex-direction: column;
}
@media #{$mobile}{
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
// Maquette p. 22 : titre, image, artistes et type en petit, sans résumé.
// Surcharges posées après les mixins, à la même spécificité.
article.node-type-projet.view-mode-teaser{
@include projetOnListe();
@include carteRecherche();
}
article.node-type-evenement.view-mode-teaser{
@include evenementOnListe();
@include carteRecherche();
}
div.view-empty{
padding-bottom: 4em;
}
nav.pager{
ul{
display: flex;
justify-content: center;
gap: 1em;
padding: 0;
li{ list-style: none; }
li.is-active{ font-weight: 600; }
}
}
}
+17
View File
@@ -361,3 +361,20 @@ function leshed_preprocess_links__language_block(&$variables){
function leshed_preprocess_time(&$variables){ function leshed_preprocess_time(&$variables){
} }
/**
* Implements hook_preprocess_HOOK() for views-view--recherche--page-1.
*
* Expose les termes cherchés au template (en-tête « Résultats pour la
* recherche "…" » et champ pré-rempli). Texte brut : Twig l'échappe.
*/
function leshed_preprocess_views_view__recherche(&$variables) {
$input = $variables['view']->getExposedInput();
$variables['search_keys'] = trim((string) ($input['search'] ?? ''));
// « ?search= » vide : le plugin input_required le compte comme saisi et
// Views renverrait tout l'index. Pas de terme, pas de résultat.
if ($variables['search_keys'] === '') {
$variables['rows'] = [];
$variables['pager'] = [];
}
}
@@ -19,7 +19,9 @@
<div{{ attributes }}> <div{{ attributes }}>
<div class="inner-wrapper"> <div class="inner-wrapper">
{{ content }} {{ content }}
{# Recherche plein texte : envoie vers la vue « recherche » (/recherche,
/en/recherche), même paramètre que son formulaire exposé. #}
{% include '@leshed/search-form.html.twig' with { id: 'burger-search' } only %}
</div> </div>
</div> </div>
{% endif %} {% endif %}
@@ -0,0 +1,16 @@
{#
/**
* @file
* Champ de recherche « pilule » (maquette p. 3, 22, 24), réutilisé dans le
* burger. Envoie en GET vers la vue recherche, paramètre « search ».
*
* Variables :
* - id : id du champ (unique dans la page).
* - value : texte pré-rempli (facultatif).
*/
#}
<form class="search-pill" action="{{ path('view.recherche.page_1') }}" method="get" role="search">
<label class="visually-hidden" for="{{ id }}">{{ 'Rechercher sur le site'|t }}</label>
<input type="search" id="{{ id }}" name="search" value="{{ value }}" placeholder="{{ 'Rechercher sur le site…'|t }}" required minlength="2">
<button type="submit" aria-label="{{ 'Rechercher'|t }}">{% include '@leshed/search-icon.html.twig' %}</button>
</form>
@@ -0,0 +1 @@
<svg class="search-icon" viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false"><circle cx="10.5" cy="10.5" r="6.5" fill="none" stroke="currentColor" stroke-width="2"/><path d="M15.5 15.5 21 21" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>

After

Width:  |  Height:  |  Size: 302 B

@@ -0,0 +1,42 @@
{#
/**
* @file
* Page de résultats de la vue Recherche (maquette p. 22) : ligne d'en-tête
* « Résultats pour la recherche "…" » + champ pilule à droite, puis grille
* de teasers (projets et événements).
*
* Variable ajoutée par leshed_preprocess_views_view__recherche() :
* - search_keys : termes cherchés (texte brut, échappé par Twig).
*
* @see template_preprocess_views_view()
*/
#}
{%
set classes = [
dom_id ? 'js-view-dom-id-' ~ dom_id,
]
%}
<div{{ attributes.addClass(classes) }}>
{{ title_prefix }}
{{ title_suffix }}
<header class="recherche-header">
{% if search_keys %}
<p class="recherche-resume">{{ 'Résultats pour la recherche'|t }} "<em>{{ search_keys }}</em>"</p>
{% else %}
<p class="recherche-resume">{{ 'Rechercher sur le site'|t }}</p>
{% endif %}
{# Même champ que le burger plutôt que le formulaire exposé de Views :
même markup, même style ; « search » est l'identifiant du filtre. #}
{% include '@leshed/search-form.html.twig' with { id: 'recherche-search', value: search_keys } only %}
</header>
{% if rows -%}
<div class="view-content">
{{ rows }}
</div>
{% elseif empty and search_keys -%}
<div class="view-empty">{{ empty }}</div>
{% endif %}
{{ pager }}
</div>