From 945a87b99822a87b2794af4c55bd4af44f09e4e4 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Fri, 5 Jun 2026 14:08:55 +0000 Subject: [PATCH] =?UTF-8?q?Corrigindo=20Est=C3=BAdio=20de=20Poesia:=20PDF,?= =?UTF-8?q?=20Intelig=C3=AAncia=20de=20Idade=20e=20Bot=C3=A3o=20Lixeira?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/app.js | 65 ++++++++++++++++++++++++++++++++++++++------------- server.js | 12 +++++++++- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/public/app.js b/public/app.js index a696d6d..d5a5a1c 100644 --- a/public/app.js +++ b/public/app.js @@ -5294,19 +5294,34 @@ const initApp = () => { if (btnDownloadPoesiaPdf) { btnDownloadPoesiaPdf.addEventListener('click', () => { if (!currentPoesia) return; - const element = document.createElement('div'); - element.innerHTML = window.marked ? marked.parse(currentPoesia) : currentPoesia; - element.style.padding = '20px'; - element.style.fontFamily = 'Arial, sans-serif'; - element.style.color = '#333'; - - html2pdf().set({ - margin: 15, - filename: 'poesia_pedagogica.pdf', - image: { type: 'jpeg', quality: 0.98 }, - html2canvas: { scale: 2 }, - jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } - }).from(element).save(); + const printWindow = window.open('', '_blank'); + printWindow.document.write(` + + + Poesia - Assistente PedaGog + + + +
+
+

📜 Poesia Pedagógica

+ +
+
+ ${window.marked ? marked.parse(currentPoesia) : currentPoesia} +
+
+ + + `); + printWindow.document.close(); }); } @@ -5327,16 +5342,34 @@ const initApp = () => { const date = new Date(item.created_at).toLocaleString('pt-BR'); const div = document.createElement('div'); div.className = 'history-item-card'; - div.style.cssText = 'background: rgba(255,255,255,0.02); padding: 14px; border-radius: 8px; border: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 8px; cursor: pointer;'; + div.style.cssText = 'background: rgba(255,255,255,0.02); padding: 14px; border-radius: 8px; border: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 8px; cursor: pointer; position: relative;'; div.innerHTML = ` -
+
${item.faixa_etaria} (${item.estrofes} Estrofes) ${date}

Tema: ${item.tema}

+ `; - div.addEventListener('click', async () => { + div.addEventListener('click', async (e) => { + if (e.target.closest('.btn-delete-poesia')) { + e.stopPropagation(); + if (confirm('Tem certeza que deseja excluir esta poesia?')) { + try { + const delRes = await fetch(`/api/poesias/${item.id}`, { method: 'DELETE' }); + if (delRes.ok) { + showToast('Poesia excluĂ­da.', 'success'); + loadPoesiaHistory(); + } else { + showToast('Erro ao excluir.', 'error'); + } + } catch (err) { + showToast('Erro de conexĂŁo.', 'error'); + } + } + return; + } try { const res = await fetch(`/api/poesias/${item.id}`); const detail = await res.json(); diff --git a/server.js b/server.js index 1d5ea43..d7a6639 100644 --- a/server.js +++ b/server.js @@ -1157,12 +1157,22 @@ app.post('/api/poesias/generate', requireAuth, async (req, res) => { try { let poesiaText = ''; + let idadeInstrucao = ''; + if (faixaEtaria.includes('BebĂȘs') || faixaEtaria.includes('bem pequenas')) { + idadeInstrucao = '- NÍVEL FÁCIL: Use palavras EXTREMAMENTE simples, do cotidiano infantil. As estrofes devem ser MUITO curtas, contendo poucas palavras por verso, pois sĂŁo crianças de colo ou maternal. Elas precisam conseguir memorizar e repetir facilmente.'; + } else if (faixaEtaria.includes('pequenas')) { + idadeInstrucao = '- NÍVEL MÉDIO: Use palavras fĂĄceis e lĂșdicas, focando em sonoridade. As estrofes podem ter tamanho normal de versos infantis (4 a 5 palavras por verso).'; + } else { + idadeInstrucao = '- NÍVEL AVANÇADO: Use vocabulĂĄrio um pouco mais rico, com metĂĄforas leves. Para crianças do Fundamental I, os versos podem ser mais elaborados e trazer reflexĂ”es sobre o tema.'; + } + const systemInstruction = `VocĂȘ Ă© um poeta pedagĂłgico infantil especializado em criar poesias ritmadas, sonoras e adequadas para o desenvolvimento infantil no Brasil. REGRAS RÍGIDAS: - Escreva a poesia para a faixa etĂĄria: ${faixaEtaria} +${idadeInstrucao} - A poesia DEVE ter EXATAMENTE ${estrofes} estrofes. - O tema da poesia Ă©: "${tema}" -- Use rimas claras e vocabulĂĄrio apropriado para a idade. +- Use rimas claras, ritmo marcante (musicalidade) e seja criativo. - Sua resposta deve conter APENAS a poesia formatada em Markdown, sem NENHUM comentĂĄrio adicional, explicação, ou blocos de pensamento. - Responda EXCLUSIVAMENTE em PortuguĂȘs do Brasil.`;