mirror of
https://git.j0bot.ch/admin_j0bot/ploxion-calendar.git
synced 2026-11-29 06:12:05 +00:00
synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
commit
bb83b9406e
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# 📅 Calendrier
|
||||||
|
|
||||||
|
Ton agenda : groupes colorés, événements, partage en lecture seule.
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `calendar` |
|
||||||
|
| fournit | `events` `groups` `share-link` |
|
||||||
|
| bions qu'il nomme | `jOSApps` `jOSPorts` `jOSWire` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/calendar/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=calendar — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre calendar` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||||
|
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||||
|
|
||||||
|
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||||
|
|
||||||
|
© 2026 chill-tekk · ne pas nuire
|
||||||
158
app.blade.php
Normal file
158
app.blade.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
{{-- =============================================================
|
||||||
|
PL0XI0N Calendrier — app cliente. S'enregistre dans window.jOSApps['calendar']
|
||||||
|
et se monte comme ÉCRAN dans une fenêtre du window-manager (jOS).
|
||||||
|
|
||||||
|
Calendrier est un ploxion server-rendered (page /calendrier, multi-user).
|
||||||
|
On la monte telle quelle dans une IFRAME same-origin : la page se charge en
|
||||||
|
mode EMBEDDED (html.is-embedded -> chrome du site masqué) donc on ne voit
|
||||||
|
que le calendrier. Émis seulement aux utilisateurs CONNECTÉS (manifeste
|
||||||
|
'auth' => true) ; /calendrier re-vérifie l'auth côté serveur.
|
||||||
|
|
||||||
|
PORTS (bus jOSPorts) :
|
||||||
|
- OUT event : chaque événement qui NAÎT dans l'agenda (submit du formulaire
|
||||||
|
« + Nouvel événement », ou création via le bus) part en ploxion.calendar.event
|
||||||
|
-> jOSWire le route vers roadmap.import (jalon) / logion (journal de vie).
|
||||||
|
- IN event : une opération datée venue d'ailleurs (ex: xerfarm.log) devient
|
||||||
|
un VRAI événement de l'agenda (POST /calendrier/event, 1er groupe du user)
|
||||||
|
puis l'iframe se recharge. in et out partagent le topic ploxion.calendar.event
|
||||||
|
-> garde anti-boucle src:'calendar' sur nos propres émissions.
|
||||||
|
|
||||||
|
Contrat avec jOS : mount(container, ctx) -> { unmount } (arrêt propre,
|
||||||
|
droit au silence §4.4). 100% client-side, aucune route neuve.
|
||||||
|
============================================================= --}}
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
function describe() {
|
||||||
|
return { v: 1, id: 'calendar', title: 'Calendrier', icon: '📅', items: [
|
||||||
|
{ p: 1, kind: 'text', label: 'calendrier', value: 'agenda personnel (/calendrier)' }
|
||||||
|
] };
|
||||||
|
}
|
||||||
|
function mount(container, ctx) {
|
||||||
|
var url = (ctx && ctx.config && ctx.config.url) ? ctx.config.url : '/calendrier';
|
||||||
|
container.innerHTML = '';
|
||||||
|
container.style.padding = '0';
|
||||||
|
// mobile : le wrapper remplit le pane et ne laisse fuir aucun scroll
|
||||||
|
// horizontal (le vrai layout responsive vit dans la page /calendrier).
|
||||||
|
container.style.height = '100%';
|
||||||
|
container.style.overflow = 'hidden';
|
||||||
|
var frame = document.createElement('iframe');
|
||||||
|
frame.src = url;
|
||||||
|
frame.title = 'Calendrier';
|
||||||
|
frame.setAttribute('loading', 'lazy');
|
||||||
|
frame.style.cssText = 'width:100%;height:100%;border:0;display:block;background:transparent';
|
||||||
|
container.appendChild(frame);
|
||||||
|
|
||||||
|
// ==================== PORTS (bus jOSPorts) — best-effort, additif ====================
|
||||||
|
var offs = []; // désabonnements bus (rappelés à l'unmount)
|
||||||
|
var pending = []; // payloads in reçus avant que l'iframe soit prête
|
||||||
|
|
||||||
|
function idoc() { try { return frame.contentDocument; } catch (e) { return null; } }
|
||||||
|
function two(n) { return ('0' + n).slice(-2); }
|
||||||
|
function todayStr() { var d = new Date(); return d.getFullYear() + '-' + two(d.getMonth() + 1) + '-' + two(d.getDate()); }
|
||||||
|
function nowTime() { var d = new Date(); return two(d.getHours()) + ':' + two(d.getMinutes()); }
|
||||||
|
|
||||||
|
// Émet SOUS NOTRE id. src:'calendar' = garde anti-boucle (le port in et le
|
||||||
|
// port out partagent le topic ploxion.calendar.event, self-delivery locale).
|
||||||
|
function emitEvent(ev) {
|
||||||
|
try {
|
||||||
|
if (window.jOSPorts && window.jOSPorts.emit) {
|
||||||
|
ev.src = 'calendar';
|
||||||
|
window.jOSPorts.emit('calendar', 'event', ev);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OUT event — hooke le formulaire « + Nouvel événement » de l'iframe
|
||||||
|
// (same-origin) : au submit (déjà validé par le navigateur), l'événement
|
||||||
|
// daté part sur le bus au moment où il est créé. Re-hooké à chaque load
|
||||||
|
// (la page POST puis se recharge -> nouveau document).
|
||||||
|
function hookCreateForm() {
|
||||||
|
var d = idoc();
|
||||||
|
var card = (d && d.getElementById) ? d.getElementById('new-event') : null;
|
||||||
|
var form = card ? card.querySelector('form') : null;
|
||||||
|
if (!form || form.__josPorts) return;
|
||||||
|
form.__josPorts = true;
|
||||||
|
form.addEventListener('submit', function () {
|
||||||
|
try {
|
||||||
|
var val = function (n) { var el = form.querySelector('[name="' + n + '"]'); return (el && el.value) ? String(el.value) : ''; };
|
||||||
|
var title = val('title');
|
||||||
|
if (!title) return;
|
||||||
|
emitEvent({
|
||||||
|
title: title.slice(0, 160),
|
||||||
|
date: val('date'),
|
||||||
|
time: val('time'),
|
||||||
|
end_date: val('end_date'),
|
||||||
|
note: val('note').slice(0, 300),
|
||||||
|
location: val('location_label')
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
frame.addEventListener('load', function () { hookCreateForm(); flush(); });
|
||||||
|
|
||||||
|
// IN event — un payload du bus (ex: xerfarm.log routé par jOSWire) devient
|
||||||
|
// un VRAI événement de l'agenda : POST /calendrier/event (CSRF + 1er groupe
|
||||||
|
// lus dans l'iframe same-origin), puis reload de l'iframe = visible direct.
|
||||||
|
function addEvent(p) {
|
||||||
|
var d = idoc();
|
||||||
|
var opt = (d && d.querySelector) ? d.querySelector('select[name="calendar_id"] option') : null;
|
||||||
|
if (!opt) { if (pending.length < 20) pending.push(p); return; } // iframe pas prête (ou aucun groupe) -> on retente au load
|
||||||
|
var title = String(p.title || p.name || p.label || (typeof p.value === 'string' ? p.value : '') || '').slice(0, 160);
|
||||||
|
if (!title) return; // payload sans titre exploitable : ignoré proprement
|
||||||
|
var tokenEl = d.querySelector('input[name="_token"]');
|
||||||
|
var meta = document.querySelector('meta[name="csrf-token"]');
|
||||||
|
var token = (tokenEl && tokenEl.value) ? tokenEl.value : (meta ? meta.getAttribute('content') : '');
|
||||||
|
if (!token) return;
|
||||||
|
var date = /^\d{4}-\d{2}-\d{2}$/.test(String(p.date || '')) ? p.date : todayStr();
|
||||||
|
var time = /^\d{2}:\d{2}$/.test(String(p.time || '')) ? p.time : nowTime();
|
||||||
|
var note = String(p.note || p.notes || (p.type ? 'via bus · ' + p.type : 'via bus xerboxion')).slice(0, 2000);
|
||||||
|
var body = new URLSearchParams();
|
||||||
|
body.set('_token', token);
|
||||||
|
body.set('calendar_id', opt.value);
|
||||||
|
body.set('title', title);
|
||||||
|
body.set('date', date);
|
||||||
|
body.set('time', time);
|
||||||
|
body.set('note', note);
|
||||||
|
fetch('/calendrier/event', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'same-origin',
|
||||||
|
headers: { 'X-CSRF-TOKEN': token, 'Accept': 'application/json' },
|
||||||
|
body: body
|
||||||
|
}).then(function (r) {
|
||||||
|
if (!r.ok) return;
|
||||||
|
// L'événement existe vraiment -> il part aussi sur le bus (roadmap/logion).
|
||||||
|
emitEvent({ title: title, date: date, time: time, note: note });
|
||||||
|
try { frame.contentWindow.location.reload(); } catch (e) { frame.src = url; }
|
||||||
|
}).catch(function () {});
|
||||||
|
}
|
||||||
|
function flush() { var q = pending; pending = []; q.forEach(function (p) { try { addEvent(p); } catch (e) {} }); }
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (window.jOSPorts && window.jOSPorts.on) {
|
||||||
|
offs.push(window.jOSPorts.on('ploxion.calendar.event', function (p) {
|
||||||
|
if (!p || typeof p !== 'object') return; // payload invalide : ignoré
|
||||||
|
if (p.src === 'calendar') return; // notre propre out (anti-boucle)
|
||||||
|
try { addEvent(p); } catch (e) {}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// unmount : off() des ports + on coupe l'iframe -> plus aucune requête/écoute (silence §4.4).
|
||||||
|
return {
|
||||||
|
unmount: function () {
|
||||||
|
offs.forEach(function (off) { try { off(); } catch (e) {} });
|
||||||
|
offs = [];
|
||||||
|
pending = [];
|
||||||
|
container.innerHTML = '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
window.jOSApps = window.jOSApps || {};
|
||||||
|
window.jOSApps.calendar = {
|
||||||
|
manifest: { id: 'calendar', name: 'Calendrier', icon: '📅' },
|
||||||
|
mount: mount,
|
||||||
|
describe: describe
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user