feat: prima versione del plugin, blocco e shortcode con iframe stampato lato server

This commit is contained in:
Lorenzo Iovino 2026-09-04 15:32:47 +02:00
commit 5c73bbc2b8
20 changed files with 1562 additions and 0 deletions

17
assets/css/widget.css Normal file
View file

@ -0,0 +1,17 @@
/* The widget is an iframe: it only needs to be as wide as its column and to
have no border of its own. Everything else lives inside the frame. */
.pinfesta-embed {
display: block;
width: 100%;
border: 0;
overflow: hidden;
}
.pinfesta-empty {
margin: 0;
padding: 12px 14px;
border: 1px dashed currentColor;
border-radius: 8px;
font-size: 0.9em;
opacity: 0.75;
}

44
assets/js/resize.js Normal file
View file

@ -0,0 +1,44 @@
/**
* Keeps the widget as tall as its content.
*
* The framed page posts its height whenever it changes; we accept the message
* only when it comes from the Piazza in Festa origin and from a window that is
* one of our own iframes, then set the height. Nothing else leaves or enters
* the page.
*/
(function () {
'use strict';
var cfg = window.pinfestaCfg || {};
var origin = cfg.origin || '';
if (!origin) {
return;
}
window.addEventListener('message', function (event) {
if (event.origin !== origin) {
return;
}
var data = event.data;
if (!data || data.tipo !== 'piazzainfesta:altezza') {
return;
}
var altezza = parseInt(data.altezza, 10);
if (!altezza || altezza < 1) {
return;
}
var frames = document.querySelectorAll('iframe.pinfesta-embed');
for (var i = 0; i < frames.length; i++) {
if (frames[i].contentWindow === event.source) {
frames[i].style.height = altezza + 2 + 'px';
}
}
});
})();