synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
22
README.md
22
README.md
@@ -1,3 +1,21 @@
|
||||
# ploxion-torrent
|
||||
# 🧲 Torrent
|
||||
|
||||
PLOXION · Partage de fichiers P2P décentralisé (WebTorrent) : sème un fichier → magnet à partager, ouvre un magnet → reçoit. Navigateur↔navigateur via WebRTC, sans serveur. · fournit: torrent, p2p, fichier, partage
|
||||
Partage de fichiers P2P décentralisé (WebTorrent) : sème un fichier → magnet à partager, ouvre un magnet → reçoit. Navigateur↔navigateur via WebRTC, sans serveur.
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| id | `torrent` |
|
||||
| fournit | `torrent` `p2p` `fichier` `partage` |
|
||||
| bions qu'il nomme | `jOSApps` |
|
||||
| fichiers | `app.blade.php` |
|
||||
| dans le labo | `resources/views/ploxions/torrent/` (dépôt `my_website2`) |
|
||||
|
||||
## Contribuer
|
||||
|
||||
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=torrent — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||
- **Dans VS Code** : `xb prendre torrent` (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
|
||||
|
||||
172
app.blade.php
Normal file
172
app.blade.php
Normal file
@@ -0,0 +1,172 @@
|
||||
{{-- PL0XION torrent 🧲 — partage de fichiers P2P DÉCENTRALISÉ (WebTorrent). RS-7 :
|
||||
« les torrents… tout décentralisé ». Navigateur↔navigateur via WebRTC + trackers WSS.
|
||||
Honnête : c'est le réseau WebTorrent (pairs WebRTC), PAS le BitTorrent classique
|
||||
(le navigateur n'a ni UDP ni DHT). On peut SEED un fichier (→ magnet à partager) et
|
||||
OUVRIR un magnet (→ téléchargement + aperçu). WebTorrent chargé à la demande (CDN).
|
||||
window.jOSApps['torrent'].mount(container, ctx). Thémé --xr-*. --}}
|
||||
<style>
|
||||
.tor{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--xr-bg,#0b1220);
|
||||
color:var(--xr-text,#e7f0ff);font-family:var(--xr-font-ui,system-ui)}
|
||||
.tor *{box-sizing:border-box}
|
||||
.tor__hd{flex:0 0 auto;padding:12px 14px;border-bottom:1px solid var(--xr-border,#22324f);
|
||||
display:flex;align-items:center;gap:9px;background:var(--xr-surface,#0c1320)}
|
||||
.tor__hd b{flex:1;color:var(--xr-accent,#3fe0d0)}
|
||||
.tor__st{font-size:.66rem;color:var(--xr-muted,#8aa0c0)}
|
||||
.tor__bd{flex:1;min-height:0;overflow:auto;padding:14px;display:flex;flex-direction:column;gap:12px}
|
||||
.tor__note{font-size:.74rem;color:var(--xr-muted,#8aa0c0);line-height:1.4;
|
||||
border:1px dashed var(--xr-border,#22324f);border-radius:11px;padding:9px 11px}
|
||||
.tor__drop{border:1.5px dashed var(--xr-border,#22324f);border-radius:14px;padding:20px;text-align:center;
|
||||
cursor:pointer;transition:border-color .15s,background .15s}
|
||||
.tor__drop.over{border-color:var(--xr-accent,#3fe0d0);background:color-mix(in srgb,var(--xr-accent,#3fe0d0) 8%,transparent)}
|
||||
.tor__drop .big{font-size:1.8rem}
|
||||
.tor__row{display:flex;gap:8px}
|
||||
.tor__in{flex:1;min-width:0;background:var(--xr-bg,#0b1220);border:1px solid var(--xr-border,#22324f);
|
||||
border-radius:10px;color:var(--xr-text,#e7f0ff);padding:10px 12px;font:14px system-ui;outline:none}
|
||||
.tor__in:focus{border-color:var(--xr-accent,#3fe0d0)}
|
||||
.tor__btn{cursor:pointer;border:none;border-radius:10px;font-weight:800;padding:10px 14px;
|
||||
background:var(--xr-accent,#3fe0d0);color:#08111b}
|
||||
.tor__btn.sec{background:var(--xr-surface,#0c1320);color:var(--xr-text,#e7f0ff);border:1px solid var(--xr-border,#22324f)}
|
||||
.tor__btn:disabled{opacity:.5}
|
||||
.tor__t{border:1px solid var(--xr-border,#22324f);border-radius:13px;padding:11px 12px;background:var(--xr-surface,#0c1320)}
|
||||
.tor__t .nm{font-weight:700;font-size:.9rem;word-break:break-word;display:flex;gap:7px;align-items:center}
|
||||
.tor__t .meta{font-size:.7rem;color:var(--xr-muted,#8aa0c0);margin-top:4px;display:flex;gap:12px;flex-wrap:wrap}
|
||||
.tor__bar{height:6px;border-radius:4px;background:var(--xr-bg,#0b1220);margin-top:8px;overflow:hidden}
|
||||
.tor__bar i{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--xr-accent,#3fe0d0),var(--xr-accent-2,#a85cff));transition:width .4s}
|
||||
.tor__t .mag{margin-top:8px;display:flex;gap:6px}
|
||||
.tor__t .mag input{flex:1;min-width:0;font-size:.7rem;background:var(--xr-bg,#0b1220);border:1px solid var(--xr-border,#22324f);
|
||||
border-radius:8px;color:var(--xr-muted,#8aa0c0);padding:6px 8px}
|
||||
.tor__view{margin-top:9px}
|
||||
.tor__view img,.tor__view video,.tor__view audio{max-width:100%;border-radius:9px;display:block}
|
||||
.tor__err{color:var(--xr-ko,#e87a6a);font-size:.78rem}
|
||||
.tor__empty{color:var(--xr-muted,#8aa0c0);font-size:.82rem;text-align:center;padding:8px}
|
||||
</style>
|
||||
<script>
|
||||
(function () {
|
||||
"use strict";
|
||||
var ID = 'torrent';
|
||||
var LIB = '/vendor/js/webtorrent.min.js';
|
||||
// trackers WSS publics (WebRTC) — les seuls joignables depuis un navigateur
|
||||
var TRACKERS = ['wss://tracker.openwebtorrent.com', 'wss://tracker.btorrent.xyz', 'wss://tracker.files.fm:7073/announce'];
|
||||
var _libP = null;
|
||||
function ensureLib() {
|
||||
if (window.WebTorrent) return Promise.resolve(window.WebTorrent);
|
||||
if (_libP) return _libP;
|
||||
_libP = new Promise(function (resolve, reject) {
|
||||
var s = document.createElement('script'); s.src = LIB; s.async = true;
|
||||
s.onload = function () { window.WebTorrent ? resolve(window.WebTorrent) : reject(new Error('WebTorrent absent')); };
|
||||
s.onerror = function () { _libP = null; reject(new Error('chargement WebTorrent échoué')); };
|
||||
document.head.appendChild(s);
|
||||
});
|
||||
return _libP;
|
||||
}
|
||||
function fmt(b) { if (!b) return '0 o'; var u = ['o','Ko','Mo','Go'], i = Math.floor(Math.log(b) / Math.log(1024)); return (b / Math.pow(1024, i)).toFixed(i ? 1 : 0) + ' ' + u[i]; }
|
||||
function esc(s){ return (s==null?'':String(s)).replace(/[&<>"]/g,function(c){return {'&':'&','<':'<','>':'>','"':'"'}[c];}); }
|
||||
|
||||
var LIVE = null; // posé au mount : {count:function()}
|
||||
function describe() {
|
||||
var n = LIVE ? LIVE.count() : 0;
|
||||
return { v: 1, id: ID, title: 'Torrent', icon: '🧲', items: [
|
||||
{ p: 1, kind: 'stat', label: 'torrents actifs', value: n }
|
||||
] };
|
||||
}
|
||||
|
||||
function mount(container, ctx) {
|
||||
var alive = true, client = null, cards = {};
|
||||
LIVE = { count: function () { return Object.keys(cards).length; } };
|
||||
container.classList.add('tor');
|
||||
container.innerHTML =
|
||||
'<div class="tor__hd"><span style="font-size:1.2rem">🧲</span><b>Torrent</b><span class="tor__st" id="tor-st">P2P navigateur</span></div>'
|
||||
+ '<div class="tor__bd">'
|
||||
+ '<div class="tor__note">Partage <b>décentralisé</b> navigateur↔navigateur (WebTorrent / WebRTC). '
|
||||
+ 'Glisse un fichier pour le <b>semer</b> → tu obtiens un <b>magnet</b> à envoyer. Colle un magnet pour le recevoir. '
|
||||
+ '⚠️ Réseau WebTorrent (pairs WebRTC), pas le BitTorrent classique.</div>'
|
||||
+ '<div class="tor__drop" id="tor-drop"><div class="big">📂</div><div>Glisse un fichier ici, ou tape pour en choisir un<br><small style="opacity:.7">il reste semé tant que ce ploxion est ouvert</small></div>'
|
||||
+ '<input type="file" id="tor-file" multiple hidden></div>'
|
||||
+ '<div class="tor__row"><input class="tor__in" id="tor-mag" placeholder="magnet:?xt=urn:btih:… ou un lien torrent"><button class="tor__btn" id="tor-add">Ouvrir</button></div>'
|
||||
+ '<div class="tor__err" id="tor-err"></div>'
|
||||
+ '<div id="tor-list"><div class="tor__empty" id="tor-empty">aucun torrent — sème ou ouvre un magnet.</div></div>'
|
||||
+ '</div>';
|
||||
|
||||
function q(s){ return container.querySelector(s); }
|
||||
function st(m){ var e = q('#tor-st'); if (e) e.textContent = m; }
|
||||
function err(m){ var e = q('#tor-err'); if (e) e.textContent = m || ''; }
|
||||
|
||||
function withClient() {
|
||||
if (client) return Promise.resolve(client);
|
||||
st('connexion P2P…');
|
||||
return ensureLib().then(function (WT) { if (!alive) return null; client = new WT(); st('prêt · pairs WebRTC'); return client; });
|
||||
}
|
||||
|
||||
// ---- carte d'un torrent (seed ou download) ----
|
||||
function addCard(t) {
|
||||
var empty = q('#tor-empty'); if (empty) empty.remove();
|
||||
var el = document.createElement('div'); el.className = 'tor__t';
|
||||
el.innerHTML = '<div class="nm">🧲 <span class="x">' + esc(t.name || 'torrent…') + '</span></div>'
|
||||
+ '<div class="meta"><span class="pr">0%</span><span class="pe">0 pair</span><span class="sp"></span><span class="sz"></span></div>'
|
||||
+ '<div class="tor__bar"><i></i></div>'
|
||||
+ '<div class="mag"><input readonly value="' + esc(t.magnetURI || '') + '"><button class="tor__btn sec cp">copier</button></div>'
|
||||
+ '<div class="tor__view"></div>';
|
||||
q('#tor-list').appendChild(el); cards[t.infoHash] = el;
|
||||
el.querySelector('.cp').onclick = function () {
|
||||
try { navigator.clipboard.writeText(t.magnetURI); el.querySelector('.cp').textContent = 'copié ✓'; } catch (e) {}
|
||||
};
|
||||
// aperçu du premier fichier rendu (image/vidéo/audio)
|
||||
var rendered = false;
|
||||
function render() {
|
||||
if (rendered || !t.files || !t.files.length) return; rendered = true;
|
||||
var f = t.files.sort(function (a, b) { return b.length - a.length; })[0];
|
||||
try { f.appendTo(el.querySelector('.tor__view'), { autoplay: false, controls: true }); } catch (e) {}
|
||||
el.querySelector('.x').textContent = t.name || f.name;
|
||||
}
|
||||
t.on('ready', render); if (t.ready) render();
|
||||
t.on('done', render);
|
||||
function tick() {
|
||||
if (!alive || !cards[t.infoHash]) return;
|
||||
var pr = Math.round((t.progress || 0) * 100);
|
||||
el.querySelector('.pr').textContent = pr + '%';
|
||||
el.querySelector('.pe').textContent = (t.numPeers || 0) + ' pair' + ((t.numPeers > 1) ? 's' : '');
|
||||
el.querySelector('.sp').textContent = '↓ ' + fmt(t.downloadSpeed || 0) + '/s · ↑ ' + fmt(t.uploadSpeed || 0) + '/s';
|
||||
el.querySelector('.sz').textContent = fmt(t.length || 0);
|
||||
el.querySelector('.tor__bar i').style.width = pr + '%';
|
||||
}
|
||||
t.on('download', tick); t.on('upload', tick); t.on('wire', tick); var iv = setInterval(tick, 1000); tick();
|
||||
el._iv = iv;
|
||||
}
|
||||
|
||||
function seedFiles(files) {
|
||||
if (!files || !files.length) return;
|
||||
withClient().then(function (c) { if (!c) return; err('');
|
||||
c.seed(files, { announce: TRACKERS }, function (t) { if (alive) addCard(t); });
|
||||
}).catch(function (e) { err(e.message); });
|
||||
}
|
||||
function addMagnet(m) {
|
||||
m = (m || '').trim(); if (!m) return;
|
||||
withClient().then(function (c) { if (!c) return; err('');
|
||||
try { c.add(m, { announce: TRACKERS }, function (t) { if (alive) addCard(t); }); }
|
||||
catch (e) { err('magnet invalide'); }
|
||||
}).catch(function (e) { err(e.message); });
|
||||
}
|
||||
|
||||
// ---- wiring ----
|
||||
var drop = q('#tor-drop'), fi = q('#tor-file');
|
||||
drop.onclick = function () { fi.click(); };
|
||||
fi.onchange = function () { seedFiles(fi.files); fi.value = ''; };
|
||||
['dragenter','dragover'].forEach(function (ev){ drop.addEventListener(ev, function (e){ e.preventDefault(); drop.classList.add('over'); }); });
|
||||
['dragleave','drop'].forEach(function (ev){ drop.addEventListener(ev, function (e){ e.preventDefault(); drop.classList.remove('over'); }); });
|
||||
drop.addEventListener('drop', function (e){ if (e.dataTransfer && e.dataTransfer.files) seedFiles(e.dataTransfer.files); });
|
||||
q('#tor-add').onclick = function () { addMagnet(q('#tor-mag').value); q('#tor-mag').value = ''; };
|
||||
q('#tor-mag').addEventListener('keydown', function (e){ if (e.key === 'Enter') q('#tor-add').click(); });
|
||||
|
||||
return { unmount: function () {
|
||||
alive = false;
|
||||
LIVE = null;
|
||||
Object.keys(cards).forEach(function (h){ if (cards[h]._iv) clearInterval(cards[h]._iv); });
|
||||
try { if (client) client.destroy(); } catch (e) {}
|
||||
container.classList.remove('tor'); container.innerHTML = '';
|
||||
} };
|
||||
}
|
||||
|
||||
window.jOSApps = window.jOSApps || {};
|
||||
window.jOSApps[ID] = { manifest: { id: ID, name: 'Torrent', icon: '🧲' }, mount: mount, describe: describe };
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user