/
home
/
oxicore
/
public_html
/
Upload File
HOME
<!DOCTYPE html> <html lang="pt-BR"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Visualizador de Blog Antigo V4</title> <style> :root { --primary: #2563eb; --primary-hover: #1d4ed8; --background: #f8fafc; --surface: #ffffff; --text-main: #1e293b; --text-muted: #64748b; --border: #e2e8f0; } body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background-color: var(--background); color: var(--text-main); margin: 0; padding: 0; line-height: 1.6; } .header { background-color: var(--surface); border-bottom: 1px solid var(--border); padding: 20px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 100; } .header h1 { margin: 0; color: var(--primary); font-size: 1.8rem; } .container { max-width: 1000px; margin: 30px auto; padding: 0 20px; } /* Upload Section */ #upload-section { background: var(--surface); padding: 40px; text-align: center; border-radius: 12px; border: 2px dashed var(--border); margin-top: 50px; } #upload-section p { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 20px; } input[type="file"] { font-size: 1rem; padding: 10px; background: var(--background); border-radius: 6px; cursor: pointer; } /* App Section */ #app-section { display: none; } .controls-card { background: var(--surface); padding: 25px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); margin-bottom: 30px; display: flex; flex-direction: column; gap: 20px; } .filters-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; } .control-group { display: flex; flex-direction: column; gap: 5px; } .control-group label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; } input[type="text"], input[type="date"], select { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; outline: none; transition: border-color 0.2s; } input[type="text"]:focus, select:focus, input[type="date"]:focus { border-color: var(--primary); } .actions-row { display: flex; justify-content: space-between; align-items: center; padding-top: 15px; border-top: 1px solid var(--border); } .btn { padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: none; display: flex; align-items: center; gap: 8px; } .btn-primary { background-color: var(--primary); color: white; } .btn-primary:hover { background-color: var(--primary-hover); } .btn-outline { background-color: transparent; border: 1px solid var(--border); color: var(--text-main); } .btn-outline:hover:not(:disabled) { background-color: var(--border); } .btn:disabled { opacity: 0.5; cursor: not-allowed; } /* Posts */ .post-card { background: var(--surface); border-radius: 12px; padding: 30px; margin-bottom: 30px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); } .post-title { font-size: 1.8rem; color: var(--text-main); margin: 0 0 10px 0; line-height: 1.3; } .post-meta { display: flex; flex-wrap: wrap; gap: 15px; font-size: 0.9rem; color: var(--text-muted); margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid var(--border); } .category-badge { background: #eff6ff; color: var(--primary); padding: 4px 10px; border-radius: 20px; font-weight: 500; font-size: 0.8rem; } .post-content { font-size: 1.05rem; color: #334155; overflow-wrap: break-word; } .post-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 15px 0; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } .empty-state { text-align: center; padding: 50px; color: var(--text-muted); font-size: 1.2rem; } #loading { display: none; text-align: center; padding: 20px; color: var(--primary); font-weight: bold; } /* Paginação */ .pagination-container { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 40px; } .page-info { font-weight: 600; color: var(--text-muted); font-size: 1.1rem; } </style> </head> <body> <div class="header"> <h1>Acervo de Publicações Antigas</h1> </div> <div class="container"> <div id="upload-section"> <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#64748b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-bottom: 15px;"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></svg> <p>Selecione o arquivo de backup <b>.xml</b> para visualizar os conteúdos.</p> <input type="file" id="xmlFileInput" accept=".xml"> </div> <div id="loading">Processando arquivo, por favor aguarde...</div> <div id="app-section"> <div class="controls-card" id="filters-top"> <div class="filters-row"> <div class="control-group"> <label>Pesquisar Título</label> <input type="text" id="searchInput" placeholder="Ex: Gestão..."> </div> <div class="control-group"> <label>Categoria</label> <select id="categorySelect"> <option value="">Todas</option> </select> </div> <div class="control-group"> <label>Data Início</label> <input type="date" id="dateStart"> </div> <div class="control-group"> <label>Data Fim</label> <input type="date" id="dateEnd"> </div> </div> <div class="actions-row"> <div id="stats" style="font-size: 0.9rem; color: var(--text-muted);"></div> <button id="sortBtn" class="btn btn-outline"> <span id="sortIcon">⬇️</span> Ordenar: <b id="sortText">Mais Recente</b> </button> </div> </div> <!-- Container dos posts --> <div id="postsContainer"></div> <!-- Controles de paginação --> <div id="pagination" class="pagination-container"></div> </div> </div> <script> let allPosts = []; let allCategories = new Set(); let sortDesc = true; // Variaveis de Paginação let currentPage = 1; const postsPerPage = 10; document.getElementById('xmlFileInput').addEventListener('change', function(e) { const file = e.target.files[0]; if (!file) return; document.getElementById('upload-section').style.display = 'none'; document.getElementById('loading').style.display = 'block'; const reader = new FileReader(); reader.onload = function(e) { const text = e.target.result; setTimeout(() => { parseXML(text); }, 100); }; reader.readAsText(file); }); function parseXML(xmlText) { try { // Substituição da URL das imagens xmlText = xmlText.replaceAll("https://bisque-zebra-868290.hostingersite.com/", "https://linen-mantis-201614.hostingersite.com/"); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlText, "text/xml"); const items = xmlDoc.querySelectorAll("item"); allPosts = []; allCategories = new Set(); items.forEach(item => { let postType = ""; const ptTags = item.getElementsByTagName("wp:post_type"); if(ptTags.length > 0) postType = ptTags[0].textContent; if (postType === "post") { let title = item.querySelector("title")?.textContent || "Sem título"; let rawDate = ""; const dateTags = item.getElementsByTagName("wp:post_date"); if(dateTags.length > 0) rawDate = dateTags[0].textContent; let content = ""; const contentTags = item.getElementsByTagName("content:encoded"); if(contentTags.length > 0) content = contentTags[0].textContent; const categories = []; const cats = item.querySelectorAll("category[domain='category']"); cats.forEach(c => { categories.push(c.textContent); allCategories.add(c.textContent); }); allPosts.push({ title, pubDate: rawDate, dateObj: new Date(rawDate.replace(' ', 'T')), content, categories }); } }); populateCategories(); // Força iniciar na página 1 e renderiza currentPage = 1; renderPosts(); document.getElementById('loading').style.display = 'none'; document.getElementById('app-section').style.display = 'block'; } catch(err) { alert("Erro ao processar o arquivo XML."); console.error(err); document.getElementById('loading').style.display = 'none'; document.getElementById('upload-section').style.display = 'block'; } } function populateCategories() { const select = document.getElementById('categorySelect'); select.innerHTML = '<option value="">Todas</option>'; Array.from(allCategories).sort().forEach(cat => { const opt = document.createElement('option'); opt.value = cat; opt.textContent = cat; select.appendChild(opt); }); } function formatDate(dateString) { if(!dateString) return "S/D"; const parts = dateString.split(' '); if(parts.length > 0) { const d = parts[0].split('-'); return `${d[2]}/${d[1]}/${d[0]}`; } return dateString; } // Chamada quando qualquer filtro for modificado (reseta a pagina para 1) function onFilterChange() { currentPage = 1; renderPosts(); } function renderPosts() { const search = document.getElementById('searchInput').value.toLowerCase(); const catFilter = document.getElementById('categorySelect').value; const startStr = document.getElementById('dateStart').value; const endStr = document.getElementById('dateEnd').value; const container = document.getElementById('postsContainer'); const paginationDiv = document.getElementById('pagination'); container.innerHTML = ''; paginationDiv.innerHTML = ''; // 1. Filtrar let filtered = allPosts.filter(p => { const matchTitle = p.title.toLowerCase().includes(search); const matchCat = catFilter === "" || p.categories.includes(catFilter); let matchDate = true; const postDateOnly = p.pubDate.split(' ')[0]; if(startStr && postDateOnly < startStr) matchDate = false; if(endStr && postDateOnly > endStr) matchDate = false; return matchTitle && matchCat && matchDate; }); // 2. Ordenar filtered.sort((a, b) => { const valA = a.dateObj.getTime(); const valB = b.dateObj.getTime(); return sortDesc ? valB - valA : valA - valB; }); document.getElementById('stats').textContent = `${filtered.length} publicações encontradas`; // Tratativa de vazio if(filtered.length === 0) { container.innerHTML = '<div class="empty-state">Nenhum post encontrado para os filtros selecionados.</div>'; return; } // 3. Paginar const totalPages = Math.ceil(filtered.length / postsPerPage); if (currentPage > totalPages) currentPage = totalPages; const startIndex = (currentPage - 1) * postsPerPage; const paginatedPosts = filtered.slice(startIndex, startIndex + postsPerPage); // 4. Renderizar Apenas os da Página Atual paginatedPosts.forEach(p => { const div = document.createElement('div'); div.className = 'post-card'; const catsHTML = p.categories.map(c => `<span class="category-badge">${c}</span>`).join(''); div.innerHTML = ` <h2 class="post-title">${p.title}</h2> <div class="post-meta"> <span>📅 ${formatDate(p.pubDate)}</span> <span>🏷️ ${catsHTML || 'Sem categoria'}</span> </div> <div class="post-content">${p.content}</div> `; container.appendChild(div); }); // 5. Renderizar Controles de Paginação if (totalPages > 1) { const prevDisabled = currentPage === 1 ? 'disabled' : ''; const nextDisabled = currentPage === totalPages ? 'disabled' : ''; paginationDiv.innerHTML = ` <button class="btn btn-outline" onclick="changePage(-1)" ${prevDisabled}>« Anterior</button> <span class="page-info">Página ${currentPage} de ${totalPages}</span> <button class="btn btn-outline" onclick="changePage(1)" ${nextDisabled}>Próxima »</button> `; } } // Troca de Página e Rolagem automática pro topo dos posts window.changePage = function(direction) { currentPage += direction; renderPosts(); // Rola suavemente de volta para o topo da lista de posts document.getElementById('filters-top').scrollIntoView({ behavior: 'smooth', block: 'start' }); }; // Listeners document.getElementById('sortBtn').addEventListener('click', () => { sortDesc = !sortDesc; document.getElementById('sortText').textContent = sortDesc ? "Mais Recente" : "Mais Antigo"; document.getElementById('sortIcon').textContent = sortDesc ? "⬇️" : "⬆️"; onFilterChange(); }); // Modificado para chamar onFilterChange (reseta página para 1) document.getElementById('searchInput').addEventListener('input', onFilterChange); document.getElementById('categorySelect').addEventListener('change', onFilterChange); document.getElementById('dateStart').addEventListener('change', onFilterChange); document.getElementById('dateEnd').addEventListener('change', onFilterChange); </script> </body> </html>