Spaces:
Build error
Build error
Update templates/html_launcher.html
Browse files- templates/html_launcher.html +220 -178
templates/html_launcher.html
CHANGED
|
@@ -1,179 +1,221 @@
|
|
| 1 |
-
<html lang="fr">
|
| 2 |
-
<head>
|
| 3 |
-
<meta charset="UTF-8">
|
| 4 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 5 |
-
<link rel="icon" type="image/png" href="https://i.imgur.com/7Gn3toV.png">
|
| 6 |
-
<title>Mailix |
|
| 7 |
-
<link rel="
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
--
|
| 14 |
-
--
|
| 15 |
-
--
|
| 16 |
-
--
|
| 17 |
-
--button-
|
| 18 |
-
--
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
.
|
| 50 |
-
background:
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
cursor: pointer;
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
.
|
| 62 |
-
background-color: var(--button-hover);
|
| 63 |
-
color: var(--text-color);
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
.
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
<
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
<button id="import-btn" class="
|
| 99 |
-
<
|
| 100 |
-
|
| 101 |
-
<button
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
<
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
</html>
|
|
|
|
| 1 |
+
<html lang="fr">
|
| 2 |
+
<head>
|
| 3 |
+
<meta charset="UTF-8">
|
| 4 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 5 |
+
<link rel="icon" type="image/png" href="https://i.imgur.com/7Gn3toV.png">
|
| 6 |
+
<title>Mailix | Lanceur HTML</title>
|
| 7 |
+
<link rel="stylesheet"
|
| 8 |
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0" />
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
<style>
|
| 11 |
+
:root {
|
| 12 |
+
--dark-bg: #1e1e1e; /* Fond principal (très sombre) */
|
| 13 |
+
--main-bg: #2d2d30; /* Arrière-plan de la plateforme */
|
| 14 |
+
--bar-color: #3e3e42; /* Couleur de la barre horizontale (gris foncé) */
|
| 15 |
+
--text-color: #f0f0f0;
|
| 16 |
+
--button-hover: #007acc; /* Bleu pour le survol (standard dark theme) */
|
| 17 |
+
--button-icon: #cccccc;
|
| 18 |
+
--border-color: #444444;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
* {
|
| 22 |
+
box-sizing: border-box;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
body {
|
| 26 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 27 |
+
background-color: var(--dark-bg);
|
| 28 |
+
color: var(--text-color);
|
| 29 |
+
margin: 0;
|
| 30 |
+
display: flex;
|
| 31 |
+
flex-direction: column;
|
| 32 |
+
height: 100vh;
|
| 33 |
+
overflow: hidden; /* Empêche le défilement global */
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.header-bar {
|
| 37 |
+
background-color: var(--bar-color);
|
| 38 |
+
display: flex;
|
| 39 |
+
align-items: center;
|
| 40 |
+
padding: 8px 20px;
|
| 41 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
| 42 |
+
flex-shrink: 0;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.header-bar button, .header-bar input[type="file"] {
|
| 46 |
+
margin-right: 10px;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.btn {
|
| 50 |
+
background-color: transparent;
|
| 51 |
+
color: var(--button-icon);
|
| 52 |
+
border: none;
|
| 53 |
+
padding: 8px 12px;
|
| 54 |
+
border-radius: 4px;
|
| 55 |
+
cursor: pointer;
|
| 56 |
+
transition: background-color 0.2s;
|
| 57 |
+
display: flex;
|
| 58 |
+
align-items: center;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.btn:hover:not(:disabled) {
|
| 62 |
+
background-color: var(--button-hover);
|
| 63 |
+
color: var(--text-color);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.btn:disabled {
|
| 67 |
+
opacity: 0.5;
|
| 68 |
+
cursor: not-allowed;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.iframe-container {
|
| 72 |
+
flex-grow: 1;
|
| 73 |
+
padding: 0;
|
| 74 |
+
background-color: white; /* Fond blanc pour le contenu HTML */
|
| 75 |
+
position: relative;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.iframe-container iframe {
|
| 79 |
+
width: 100%;
|
| 80 |
+
height: 100%;
|
| 81 |
+
border: none;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
#status-message {
|
| 85 |
+
margin-left: auto;
|
| 86 |
+
font-size: 0.9em;
|
| 87 |
+
color: #ccc;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
#html-file-input {
|
| 91 |
+
display: none;
|
| 92 |
+
}
|
| 93 |
+
</style>
|
| 94 |
+
</head>
|
| 95 |
+
<body>
|
| 96 |
+
|
| 97 |
+
<div class="header-bar">
|
| 98 |
+
<button id="import-btn" class="btn">
|
| 99 |
+
<span class="material-symbols-rounded text-xl mr-1">folder_open</span>
|
| 100 |
+
Importer Fichier HTML
|
| 101 |
+
</button>
|
| 102 |
+
<input type="file" id="html-file-input" accept=".html,.htm">
|
| 103 |
+
|
| 104 |
+
<button id="run-btn" class="btn" disabled>
|
| 105 |
+
<span class="material-symbols-rounded text-xl mr-1">play_arrow</span>
|
| 106 |
+
Lancer (▶)
|
| 107 |
+
</button>
|
| 108 |
+
|
| 109 |
+
<button id="static-deploy-btn" class="btn">
|
| 110 |
+
<span class="material-symbols-rounded text-xl mr-1">web</span>
|
| 111 |
+
Déploiement Statique
|
| 112 |
+
</button>
|
| 113 |
+
|
| 114 |
+
<span id="status-message"></span>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
<div class="iframe-container">
|
| 118 |
+
<iframe id="html-iframe" title="HTML Renderer"></iframe>
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<script>
|
| 122 |
+
const fileInput = document.getElementById('html-file-input');
|
| 123 |
+
const importBtn = document.getElementById('import-btn');
|
| 124 |
+
const runBtn = document.getElementById('run-btn');
|
| 125 |
+
const iframe = document.getElementById('html-iframe');
|
| 126 |
+
const statusMessage = document.getElementById('status-message');
|
| 127 |
+
const staticDeployBtn = document.getElementById('static-deploy-btn');
|
| 128 |
+
|
| 129 |
+
let uploadedFileUrl = null;
|
| 130 |
+
|
| 131 |
+
// --- NOUVELLE LOGIQUE : GESTION DE L'URL PASSÉE EN PARAMÈTRE ---
|
| 132 |
+
const urlParams = new URLSearchParams(window.location.search);
|
| 133 |
+
const initialLaunchUrl = urlParams.get('url');
|
| 134 |
+
|
| 135 |
+
if (initialLaunchUrl) {
|
| 136 |
+
// Mode "Déploiement Statique" activé
|
| 137 |
+
// Décoder l'URL et l'injecter directement dans l'iframe
|
| 138 |
+
const decodedUrl = decodeURIComponent(initialLaunchUrl);
|
| 139 |
+
iframe.src = decodedUrl;
|
| 140 |
+
|
| 141 |
+
uploadedFileUrl = decodedUrl; // Mettre à jour l'URL pour la fonction Run
|
| 142 |
+
|
| 143 |
+
// Mettre à jour l'interface
|
| 144 |
+
importBtn.disabled = true; // Désactiver l'importation de fichier simple
|
| 145 |
+
runBtn.disabled = false;
|
| 146 |
+
statusMessage.textContent = "Site statique lancé depuis l'URL: " + decodedUrl.split('/').pop();
|
| 147 |
+
|
| 148 |
+
} else {
|
| 149 |
+
// Mode "Importation de Fichier Simple"
|
| 150 |
+
statusMessage.textContent = "Importez un fichier HTML pour commencer.";
|
| 151 |
+
}
|
| 152 |
+
// ------------------------------------------------------------------------
|
| 153 |
+
|
| 154 |
+
// 1. Ouvrir le dialogue de fichier lorsque le bouton 'Import' est cliqué
|
| 155 |
+
importBtn.addEventListener('click', () => {
|
| 156 |
+
// Seulement si nous ne sommes PAS en mode site statique lancé
|
| 157 |
+
if (!initialLaunchUrl) {
|
| 158 |
+
fileInput.click();
|
| 159 |
+
}
|
| 160 |
+
});
|
| 161 |
+
|
| 162 |
+
// 2. Gérer la sélection du fichier et l'upload (ancienne logique pour un seul fichier)
|
| 163 |
+
fileInput.addEventListener('change', async (event) => {
|
| 164 |
+
const files = event.target.files;
|
| 165 |
+
if (files.length === 0) return;
|
| 166 |
+
|
| 167 |
+
const file = files[0];
|
| 168 |
+
statusMessage.textContent = `Téléversement de ${file.name}...`;
|
| 169 |
+
runBtn.disabled = true;
|
| 170 |
+
|
| 171 |
+
const formData = new FormData();
|
| 172 |
+
formData.append('file', file);
|
| 173 |
+
|
| 174 |
+
try {
|
| 175 |
+
// Utiliser l'ancienne route pour l'upload d'un seul fichier (si elle existe toujours)
|
| 176 |
+
const response = await fetch('/upload-html', {
|
| 177 |
+
method: 'POST',
|
| 178 |
+
body: formData
|
| 179 |
+
});
|
| 180 |
+
|
| 181 |
+
const data = await response.json();
|
| 182 |
+
|
| 183 |
+
if (response.ok && data.status === 'success') {
|
| 184 |
+
uploadedFileUrl = data.file_url;
|
| 185 |
+
statusMessage.textContent = `Fichier prêt: ${file.name}. Cliquez sur Lancer (▶).`;
|
| 186 |
+
runBtn.disabled = false; // Activer le bouton Run
|
| 187 |
+
} else {
|
| 188 |
+
// Afficher l'erreur du backend
|
| 189 |
+
throw new Error(data.message || "Erreur de téléversement.");
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
} catch (error) {
|
| 193 |
+
console.error("Erreur d'upload:", error);
|
| 194 |
+
statusMessage.textContent = `Erreur: ${error.message}`;
|
| 195 |
+
runBtn.disabled = true;
|
| 196 |
+
uploadedFileUrl = null;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
// Réinitialiser l'input file pour permettre l'upload du même fichier
|
| 200 |
+
fileInput.value = "";
|
| 201 |
+
});
|
| 202 |
+
|
| 203 |
+
// 3. Gérer le clic sur le bouton 'Run'
|
| 204 |
+
runBtn.addEventListener('click', () => {
|
| 205 |
+
if (uploadedFileUrl) {
|
| 206 |
+
// Charger l'URL temporaire dans l'iframe
|
| 207 |
+
iframe.src = uploadedFileUrl;
|
| 208 |
+
statusMessage.textContent = "Contenu lancé ou rechargé.";
|
| 209 |
+
} else {
|
| 210 |
+
statusMessage.textContent = "Veuillez d'abord importer un fichier ou un site statique.";
|
| 211 |
+
}
|
| 212 |
+
});
|
| 213 |
+
|
| 214 |
+
// 4. Redirection vers la nouvelle page de déploiement statique
|
| 215 |
+
staticDeployBtn.addEventListener('click', () => {
|
| 216 |
+
window.location.href = '/static-deploy';
|
| 217 |
+
});
|
| 218 |
+
</script>
|
| 219 |
+
|
| 220 |
+
</body>
|
| 221 |
</html>
|