synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
48
app.blade.php
Normal file
48
app.blade.php
Normal file
@@ -0,0 +1,48 @@
|
||||
{{-- PL0XI0N wiki — wrapper iframe (le wiki vivant, /wiki). S'enregistre dans
|
||||
window.jOSApps['wiki'] et monte /wiki en mode embedded.
|
||||
mount(container, ctx) -> { unmount }. 100% client-side, aucune route neuve. --}}
|
||||
<script>
|
||||
(function () {
|
||||
function mount(container, ctx) {
|
||||
var url = (ctx && ctx.config && ctx.config.url) ? ctx.config.url : '/wiki';
|
||||
// LE XW (docs/dev/42-lanceurs.md) : un mot du lexique choisi dans le xw arrive en demande {slug} (lue une fois) → sa page
|
||||
try {
|
||||
var XP = window.jOSXerPrefs, d = (XP && typeof XP.params === 'function') ? XP.params('wiki', ctx) : ((ctx && ctx.params) || {});
|
||||
var sl = d && typeof d.slug === 'string' ? d.slug.trim().toLowerCase() : '';
|
||||
if (/^[a-z0-9][a-z0-9_-]*$/.test(sl)) url = (String(url).split(/[?#]/)[0].replace(/\/+$/, '') || '/wiki') + '/' + encodeURIComponent(sl);
|
||||
} catch (e0) {}
|
||||
container.innerHTML = ''; container.style.padding = '0';
|
||||
var f = document.createElement('iframe');
|
||||
f.src = url; f.title = 'Wiki'; f.setAttribute('loading', 'lazy');
|
||||
f.style.cssText = 'width:100%;height:100%;border:0;display:block;background:transparent';
|
||||
container.appendChild(f);
|
||||
|
||||
// IN goto : un terme choisi ailleurs (tree.term / dictionnaire.term routés
|
||||
// par jOSWire) ouvre sa page /wiki/{slug} dans l'iframe. Payload {slug,...}
|
||||
// ou string ; slug wiki only (pas d'URL arbitraire), best-effort.
|
||||
var offGoto = null;
|
||||
if (window.jOSPorts && window.jOSPorts.on) {
|
||||
try {
|
||||
var base = String((ctx && ctx.config && ctx.config.url) ? ctx.config.url : '/wiki').split(/[?#]/)[0].replace(/\/+$/, '') || '/wiki';
|
||||
offGoto = window.jOSPorts.on('ploxion.wiki.goto', function (p) {
|
||||
try {
|
||||
var slug = (typeof p === 'string') ? p : (p && (p.slug || p.term || p.name));
|
||||
if (typeof slug !== 'string') return;
|
||||
slug = slug.trim().toLowerCase();
|
||||
if (!/^[a-z0-9][a-z0-9_-]*$/.test(slug)) return;
|
||||
var next = base + '/' + encodeURIComponent(slug);
|
||||
if (f.getAttribute('src') !== next) f.src = next;
|
||||
} catch (e) {}
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return { unmount: function () {
|
||||
try { if (offGoto) offGoto(); } catch (e) {}
|
||||
container.innerHTML = '';
|
||||
} };
|
||||
}
|
||||
window.jOSApps = window.jOSApps || {};
|
||||
window.jOSApps['wiki'] = { manifest: { id: 'wiki', name: 'Wiki', icon: '📖' }, mount: mount };
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user