Spaces:
Running
Running
File size: 19,674 Bytes
f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 f7b328e 5cb9c23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 51 52 53 54 55 56 57 58 59 60 61 62 63 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 99 100 101 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | <!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Cloner - Generador de Plantillas WordPress</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.iframe-container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 60%;
background-color: #f3f4f6;
border-radius: 0.5rem;
overflow: hidden;
}
.iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
.loading-spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255,255,255,.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.progress-bar {
height: 6px;
background-color: #e5e7eb;
border-radius: 3px;
overflow: hidden;
margin: 10px 0;
}
.progress-bar-fill {
height: 100%;
background-color: #3b82f6;
transition: width 0.3s ease;
}
.json-viewer {
font-family: 'Courier New', monospace;
white-space: pre-wrap;
background-color: #1e293b;
color: #f8fafc;
padding: 1rem;
border-radius: 0.5rem;
max-height: 300px;
overflow-y: auto;
font-size: 0.875rem;
line-height: 1.5;
}
.toast {
position: fixed;
bottom: 20px;
right: 20px;
padding: 12px 20px;
border-radius: 8px;
color: white;
font-weight: 500;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
z-index: 1000;
opacity: 0;
transition: opacity 0.3s ease;
}
.toast.show {
opacity: 1;
}
.toast.success {
background-color: #10b981;
}
.toast.error {
background-color: #ef4444;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen">
<div class="container mx-auto px-4 py-8 max-w-6xl">
<header class="mb-8 text-center">
<h1 class="text-3xl font-bold text-gray-800 mb-2">
<i class="fas fa-clone text-blue-500 mr-2"></i> Web Cloner
</h1>
<p class="text-gray-600">Clona cualquier página web y genera una plantilla WordPress funcional</p>
</header>
<div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
<div class="p-6">
<div class="mb-6">
<label for="url-input" class="block text-sm font-medium text-gray-700 mb-2">
<i class="fas fa-link mr-2"></i> URL de la página a clonar
</label>
<div class="flex shadow-sm">
<input type="url" id="url-input" class="flex-1 min-w-0 block w-full px-4 py-3 rounded-l-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" placeholder="https://ejemplo.com">
<button id="clone-button" class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-r-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-copy mr-2"></i> Clonar Página
</button>
</div>
</div>
<div id="preview-section" class="hidden">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-medium text-gray-900">
<i class="fas fa-eye mr-2 text-blue-500"></i> Vista previa
</h3>
<div class="flex space-x-2">
<button id="refresh-preview" class="inline-flex items-center px-3 py-1.5 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-sync-alt mr-1.5"></i> Actualizar
</button>
</div>
</div>
<div class="progress-bar">
<div id="clone-progress" class="progress-bar-fill" style="width: 0%"></div>
</div>
<div class="iframe-container">
<iframe id="preview-iframe" sandbox="allow-same-origin allow-scripts allow-popups allow-forms"></iframe>
</div>
</div>
</div>
</div>
<div id="output-section" class="bg-white rounded-xl shadow-lg overflow-hidden mb-8 hidden">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-medium text-gray-900">
<i class="fas fa-file-code mr-2 text-blue-500"></i> Plantilla WordPress
</h3>
<div class="flex space-x-3">
<button id="copy-json" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-copy mr-2"></i> Copiar JSON
</button>
<button id="download-json" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="fas fa-download mr-2"></i> Descargar Plantilla
</button>
</div>
</div>
<div class="mb-4">
<label for="template-name" class="block text-sm font-medium text-gray-700 mb-2">
<i class="fas fa-tag mr-2"></i> Nombre de la plantilla
</label>
<input type="text" id="template-name" class="block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500" placeholder="Mi Plantilla Personalizada">
</div>
<div class="json-viewer" id="json-output">El contenido JSON de la plantilla aparecerá aquí...</div>
<div class="mt-6 bg-blue-50 p-4 rounded-lg">
<h4 class="text-sm font-medium text-blue-800 mb-2">
<i class="fas fa-info-circle mr-2"></i> Cómo usar esta plantilla en WordPress:
</h4>
<ol class="list-decimal list-inside text-sm text-blue-700 space-y-1.5 pl-4">
<li>Descarga el archivo JSON haciendo clic en "Descargar Plantilla"</li>
<li>En WordPress, ve a <span class="font-semibold">Apariencia → Editor de archivos de tema</span></li>
<li>Crea un nuevo archivo de plantilla (o edita uno existente)</li>
<li>Pega el contenido JSON y guarda los cambios</li>
<li>Asigna la plantilla a tus páginas o publicaciones</li>
</ol>
</div>
</div>
</div>
</div>
<!-- Toast notifications -->
<div id="toast" class="toast"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Elementos del DOM
const cloneButton = document.getElementById('clone-button');
const urlInput = document.getElementById('url-input');
const previewSection = document.getElementById('preview-section');
const previewIframe = document.getElementById('preview-iframe');
const cloneProgress = document.getElementById('clone-progress');
const refreshPreview = document.getElementById('refresh-preview');
const outputSection = document.getElementById('output-section');
const jsonOutput = document.getElementById('json-output');
const copyJsonButton = document.getElementById('copy-json');
const downloadJsonButton = document.getElementById('download-json');
const templateNameInput = document.getElementById('template-name');
const toast = document.getElementById('toast');
// Función para mostrar notificaciones
function showToast(message, type) {
toast.textContent = message;
toast.className = `toast ${type} show`;
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
// Función para clonar la página web usando un proxy CORS
cloneButton.addEventListener('click', async () => {
const url = urlInput.value.trim();
if (!url) {
showToast('Por favor ingresa una URL válida', 'error');
return;
}
try {
// Mostrar estado de carga
cloneButton.disabled = true;
cloneButton.innerHTML = '<span class="loading-spinner mr-2"></span> Clonando...';
// Simular progreso
simulateProgress();
// Usamos un proxy CORS para evitar problemas
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(url)}`;
// Obtener el HTML de la página
const response = await fetch(proxyUrl);
const data = await response.json();
if (!data.contents) {
throw new Error('No se pudo obtener el contenido de la página');
}
let htmlContent = data.contents;
// Procesar el HTML
const processedHtml = processHtmlContent(htmlContent);
// Mostrar vista previa
previewIframe.srcdoc = processedHtml;
previewSection.classList.remove('hidden');
// Generar la plantilla WordPress
generateWordPressTemplate(processedHtml, url);
// Restaurar estado del botón
cloneButton.disabled = false;
cloneButton.innerHTML = '<i class="fas fa-copy mr-2"></i> Clonar Página';
showToast('Página clonada con éxito!', 'success');
} catch (error) {
console.error('Error al clonar la página:', error);
showToast('Error al clonar la página. Verifica la URL e intenta nuevamente.', 'error');
cloneButton.disabled = false;
cloneButton.innerHTML = '<i class="fas fa-copy mr-2"></i> Clonar Página';
}
});
// Función para procesar el HTML
function processHtmlContent(html) {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
// Eliminar elementos no deseados
const elementsToRemove = [
'script[src*="ads"]',
'iframe',
'link[rel*="ads"]',
'meta[name*="ads"]',
'noscript'
];
elementsToRemove.forEach(selector => {
doc.querySelectorAll(selector).forEach(el => el.remove());
});
// Convertir URLs relativas a absolutas
const baseUrl = urlInput.value;
doc.querySelectorAll('[href]').forEach(el => {
const href = el.getAttribute('href');
if (href && !href.startsWith('http') && !href.startsWith('#')) {
el.setAttribute('href', new URL(href, baseUrl).href);
}
});
doc.querySelectorAll('[src]').forEach(el => {
const src = el.getAttribute('src');
if (src && !src.startsWith('http') && !src.startsWith('data:')) {
el.setAttribute('src', new URL(src, baseUrl).href);
}
});
// Serializar el documento de nuevo a HTML
const serializer = new XMLSerializer();
let processedHtml = serializer.serializeToString(doc);
// Limpiar el HTML
processedHtml = cleanHtml(processedHtml);
return processedHtml;
}
// Función para simular progreso de clonación
function simulateProgress() {
let progress = 0;
const progressInterval = setInterval(() => {
progress += Math.floor(Math.random() * 10) + 1;
if (progress >= 100) {
progress = 100;
clearInterval(progressInterval);
}
cloneProgress.style.width = `${progress}%`;
}, 200);
}
// Función para generar la plantilla WordPress
function generateWordPressTemplate(htmlContent, originalUrl) {
const templateName = originalUrl ? new URL(originalUrl).hostname.replace('www.', '') + ' Clone' : 'Custom Template';
templateNameInput.value = templateName;
// Crear el objeto JSON para la plantilla WordPress
const wordpressTemplate = {
"templateName": templateName,
"templateType": "page",
"templateDescription": `Plantilla clonada de ${originalUrl}`,
"templateVersion": "1.0",
"templateAuthor": "Web Cloner",
"templateContent": htmlContent,
"templateCSS": extractCssFromHtml(htmlContent),
"templateJS": extractJsFromHtml(htmlContent),
"createdAt": new Date().toISOString(),
"compatibleWith": ["WordPress 5.0+"]
};
// Mostrar el JSON formateado
jsonOutput.textContent = JSON.stringify(wordpressTemplate, null, 2);
// Mostrar la sección de salida
outputSection.classList.remove('hidden');
// Configurar eventos para los botones de copiar y descargar
setupDownloadButtons(wordpressTemplate);
}
// Función para extraer CSS del HTML
function extractCssFromHtml(html) {
const styleRegex = /<style[^>]*>([\s\S]*?)<\/style>/gi;
const matches = html.match(styleRegex);
return matches ? matches.join('\n') : '';
}
// Función para extraer JS del HTML
function extractJsFromHtml(html) {
const scriptRegex = /<script[^>]*>([\s\S]*?)<\/script>/gi;
const matches = html.match(scriptRegex);
return matches ? matches.join('\n') : '';
}
// Función para configurar los botones de copiar y descargar
function setupDownloadButtons(templateData) {
copyJsonButton.addEventListener('click', () => {
navigator.clipboard.writeText(JSON.stringify(templateData, null, 2))
.then(() => showToast('JSON copiado al portapapeles!', 'success'))
.catch(err => showToast('Error al copiar: ' + err, 'error'));
});
downloadJsonButton.addEventListener('click', () => {
const templateName = templateNameInput.value || 'wordpress-template';
const fileName = templateName.toLowerCase().replace(/\s+/g, '-') + '.json';
const jsonStr = JSON.stringify(templateData, null, 2);
const blob = new Blob([jsonStr], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
showToast('Plantilla descargada correctamente!', 'success');
});
}
// Función para limpiar HTML
function cleanHtml(html) {
// Eliminar espacios en blanco múltiples
html = html.replace(/\s+/g, ' ');
// Eliminar comentarios HTML
html = html.replace(/<!--[\s\S]*?-->/g, '');
return html.trim();
}
// Evento para actualizar la vista previa
refreshPreview.addEventListener('click', () => {
if (previewIframe.srcdoc) {
previewIframe.srcdoc = previewIframe.srcdoc;
showToast('Vista previa actualizada', 'success');
}
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Intimafit/app-clon-web" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |