feat: il widget ha tre aspetti (elenco, schede con locandina, carosello) e i comuni si tagliano al limite del servizio

This commit is contained in:
Lorenzo Iovino 2026-09-04 16:33:50 +02:00
parent 5c73bbc2b8
commit fbae03e4f3
7 changed files with 71 additions and 6 deletions

View file

@ -18,6 +18,7 @@
"regione": { "type": "string", "default": "" },
"categoria": { "type": "string", "default": "" },
"limite": { "type": "string", "default": "5" },
"formato": { "type": "string", "default": "lista" },
"tema": { "type": "string", "default": "chiaro" },
"colore": { "type": "string", "default": "" },
"titolo": { "type": "string", "default": "" },

View file

@ -99,7 +99,21 @@
set({ categoria: v });
}
}),
campo('limite', __('How many events', 'piazza-in-festa'), __('From 1 to 20.', 'piazza-in-festa'))
campo('limite', __('How many events', 'piazza-in-festa'), __('From 1 to 20.', 'piazza-in-festa')),
el(SelectControl, {
label: __('Layout', 'piazza-in-festa'),
value: a.formato,
options: [
{ label: __('List', 'piazza-in-festa'), value: 'lista' },
{ label: __('Cards', 'piazza-in-festa'), value: 'schede' },
{ label: __('Carousel', 'piazza-in-festa'), value: 'carosello' }
],
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
onChange: function (v) {
set({ formato: v });
}
})
),
el(
PanelBody,

View file

@ -20,6 +20,7 @@ function pinfesta_defaults() {
'regione' => '',
'categoria' => '',
'limite' => '5',
'formato' => 'lista',
'tema' => 'chiaro',
'colore' => '',
'titolo' => '',
@ -55,8 +56,12 @@ function pinfesta_categorie() {
/**
* Cleans a comma separated list of town identifiers (the slug you see in the
* address of a town page, for instance "la-morra"). Twelve at most, which is
* what the service accepts.
* address of a town page, for instance "la-morra").
*
* The hard limit is the service's, not ours: twelve towns on the free plan,
* fifty with a key. Here we only cut at the higher of the two, so a site with
* a key is not trimmed by the plugin; the extra towns are simply ignored by
* the service when the key is missing.
*
* @param string $raw Raw attribute value.
* @return string Normalised list, empty when nothing survives.
@ -72,7 +77,7 @@ function pinfesta_clean_comuni( $raw ) {
}
}
return implode( ',', array_slice( array_unique( $out ), 0, 12 ) );
return implode( ',', array_slice( array_unique( $out ), 0, 50 ) );
}
/**
@ -102,6 +107,11 @@ function pinfesta_build_url( $args ) {
$query['limite'] = min( $limite, 20 );
}
// Elenco, schede con la locandina, o carosello che scorre da solo.
if ( in_array( $args['formato'], array( 'schede', 'carosello' ), true ) ) {
$query['formato'] = $args['formato'];
}
if ( 'scuro' === $args['tema'] ) {
$query['tema'] = 'scuro';
}

View file

@ -1,5 +1,5 @@
{
"translation-revision-date": "2026-09-04 12:00+0000",
"translation-revision-date": "2026-09-04 16:00+0000",
"generator": "manuale (nessun build step)",
"domain": "messages",
"locale_data": {
@ -68,6 +68,18 @@
],
"Piazza in Festa: set at least one town or a region in the block settings.": [
"Piazza in Festa: indica almeno un comune o una regione nelle impostazioni del blocco."
],
"Layout": [
"Aspetto"
],
"List": [
"Elenco"
],
"Cards": [
"Schede"
],
"Carousel": [
"Carosello"
]
}
}

View file

@ -1,5 +1,5 @@
{
"translation-revision-date": "2026-09-04 12:00+0000",
"translation-revision-date": "2026-09-04 16:00+0000",
"generator": "manuale (nessun build step)",
"domain": "messages",
"locale_data": {
@ -68,6 +68,18 @@
],
"Piazza in Festa: set at least one town or a region in the block settings.": [
"Piazza in Festa: indica almeno un comune o una regione nelle impostazioni del blocco."
],
"Layout": [
"Aspetto"
],
"List": [
"Elenco"
],
"Cards": [
"Schede"
],
"Carousel": [
"Carosello"
]
}
}

Binary file not shown.

View file

@ -120,3 +120,19 @@ msgstr "Si adatta da sola appena carica."
#: blocks/eventi/index.js
msgid "Piazza in Festa: set at least one town or a region in the block settings."
msgstr "Piazza in Festa: indica almeno un comune o una regione nelle impostazioni del blocco."
#: blocks/eventi/index.js
msgid "Layout"
msgstr "Aspetto"
#: blocks/eventi/index.js
msgid "List"
msgstr "Elenco"
#: blocks/eventi/index.js
msgid "Cards"
msgstr "Schede"
#: blocks/eventi/index.js
msgid "Carousel"
msgstr "Carosello"