teste upload
Deploy / Deploy (push) Successful in 3m4s Details

This commit is contained in:
JotaChina 2025-12-02 19:54:04 -03:00
parent 5e2e3d04c9
commit edc6497a06
16 changed files with 378150 additions and 369915 deletions

341038
_data/all.yml

File diff suppressed because it is too large Load Diff

1941
_data/compMus1.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,14 @@
<ul>
<li>
<a href="{{ '/mmp_pages/' | relative_url }}"
<a href="{{ '/projetos/' | relative_url }}"
><span class="icon is-small"><i class="fa-solid fa-folder-open"></i></span
><span>Projetos Disponíveis</span></a
><span>Projetos</span></a
>
</li>
<li class="is-active">
<a href="{{ '/projetosPorTrack/' | relative_url }}"
><span class="icon is-small"
><i class="fa-solid fa-magnifying-glass"></i></span
><span>Buscas</span></a
<li>
<a href="{{ '/samples/' | relative_url }}"
><span class="icon is-small"><i class="fa-solid fa-plus-circle"></i></span
><span>Samples</span></a
>
</li>
<li>
@ -18,10 +17,25 @@
><span>Beats</span></a
>
</li>
<li class="is-active">
<a href="{{ '/buscas/' | relative_url }}"
><span class="icon is-small"
><i class="fa-solid fa-magnifying-glass"></i></span
><span>Buscas</span></a
>
</li>
<li>
<a href="{{ './creation.html' | relative_url }}" class="has-text-primary"
><span class="icon is-small"><i class="fa-solid fa-plus-circle"></i></span
><span>Crie seu projeto</span></a
>
</li>
<li>
<a
href="{{ '/envie_seu_projeto/' | relative_url }}"
class="has-text-primary"
><span class="icon is-small"><i class="fa-solid fa-plus-circle"></i></span
><span>Envie seu projeto</span></a
>
</li>
</ul>

View File

@ -0,0 +1,31 @@
const express = require("express");
const multer = require("multer");
const path = require("path");
const app = express();
// Configura onde salvar (Pasta 'uploads')
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "../../public/projects/"); // <--- PASTA ONDE FICARÃO OS PROJETOS
},
filename: function (req, file, cb) {
// Mantém o nome original ou cria um novo para evitar duplicatas
const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
cb(null, uniqueSuffix + "-" + file.originalname);
},
});
const upload = multer({ storage: storage });
// A Rota que o HTML vai chamar
app.post(
"/api/upload",
upload.fields([{ name: "project_file" }, { name: "audio_preview" }]),
(req, res) => {
// Aqui você pode salvar os dados de Título/BPM em um banco de dados ou arquivo JSON
console.log("Projeto recebido:", req.body.project_name);
console.log("Arquivo salvo:", req.files["project_file"][0].path);
res.send("Arquivo recebido com sucesso");
}
);

File diff suppressed because it is too large Load Diff

2074
metadata/compMus1.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
---
layout: default
title: Projetos por tipo de track
permalink: /projetosPorTrack/
title: MMPSearch - Buscas
permalink: /buscas/
---
<meta charset="utf-8">

320
pages/enviaProjeto.md Normal file
View File

@ -0,0 +1,320 @@
---
layout: default
title: MMPSearch - Envie seu projeto
permalink: /envie_seu_projeto/
---
<meta charset="utf-8" />
<main class="main-content">
<div class="publication">
<div class="container">
<br />
<!-- 1. MENU DE ABAS (Padrão) -->
<div class="tabs is-centered is-boxed is-medium mb-6">
{% include sidebar.html %}
</div>
<!-- 2. CABEÇALHO -->
<div class="columns is-centered">
<div class="column is-8 has-text-centered">
<h1 class="title is-3 has-text-grey-dark mb-3">
<span class="icon has-text-info mr-2"><i class="fa-solid fa-cloud-arrow-up"></i></span>
Enviar Projeto
</h1>
<p class="subtitle is-6 has-text-grey">
Contribua com a comunidade! Envie seus arquivos <code>.mmp</code> ou <code>.mmpz</code> para que outros possam estudar e remixar.
</p>
<div style="width: 60px; height: 4px; background-color: #3273dc; margin: 1rem auto; border-radius: 2px;"></div>
</div>
</div>
<!-- 3. FORMULÁRIO DE UPLOAD -->
<div class="columns is-centered">
<div class="column is-8">
<div class="box p-5" style="background-color: #f0f8ff; border: 1px solid #cfe8fc; border-radius: 12px;">
<form id="upload-project-form">
<!-- ÁREA DE ARQUIVO (DROPZONE) -->
<div class="field mb-5">
<label class="label has-text-grey-dark">Arquivo do Projeto (LMMS)</label>
<div class="file-upload-wrapper" id="drop-zone">
<input class="file-upload-input" type="file" name="project_file" id="project_file" accept=".mmp, .mmpz" required>
<div class="drag-text has-text-centered">
<span class="icon is-large has-text-info mb-2"><i class="fa-solid fa-file-audio fa-3x"></i></span>
<h3 class="title is-5 has-text-grey-dark mb-1">Arraste e solte o arquivo aqui</h3>
<p class="is-size-7 has-text-grey">ou clique para selecionar (.mmp, .mmpz)</p>
<p id="file-name-display" class="tag is-info is-light mt-3 is-hidden"></p>
</div>
</div>
</div>
<!-- INFORMAÇÕES BÁSICAS -->
<div class="columns">
<div class="column is-6">
<div class="field">
<label class="label has-text-grey-dark">Nome do Projeto</label>
<div class="control has-icons-left">
<input class="input" type="text" placeholder="Ex: Manda a maladeza" required>
<span class="icon is-small is-left">
<i class="fa-solid fa-music"></i>
</span>
</div>
</div>
</div>
<div class="column is-6">
<div class="field">
<label class="label has-text-grey-dark">Qual o seu vulgo?</label>
<div class="control has-icons-left">
<input class="input" type="text" placeholder="Seu nome ou nick" required>
<span class="icon is-small is-left">
<i class="fa-solid fa-user"></i>
</span>
</div>
</div>
</div>
</div>
<div class="columns">
<div class="column is-4">
<div class="field">
<label class="label has-text-grey-dark">BPM</label>
<div class="control has-icons-left">
<input class="input" type="number" placeholder="128" min="1" max="999">
<span class="icon is-small is-left">
<i class="fa-solid fa-gauge-high"></i>
</span>
</div>
</div>
</div>
<div class="column is-8">
<div class="field">
<label class="label has-text-grey-dark">Tags (Opcional)</label>
<div class="control has-icons-left">
<input class="input" type="text" placeholder="Ex: rap, hip hop, boom bap, remix">
<span class="icon is-small is-left">
<i class="fa-solid fa-tags"></i>
</span>
</div>
<p class="help">Separe por vírgulas.</p>
</div>
</div>
</div>
<div class="field">
<label class="label has-text-grey-dark">Descrição</label>
<div class="control">
<textarea class="textarea" placeholder="Conte um pouco sobre como você criou esse projeto, plugins usados, etc." rows="3"></textarea>
</div>
</div>
<!-- PREVIEW DE ÁUDIO (OPCIONAL) -->
<div class="field mb-5">
<label class="label has-text-grey-dark">Preview de Áudio (Opcional)</label>
<div class="file has-name is-fullwidth">
<label class="file-label">
<input class="file-input" type="file" name="audio_preview" accept=".wav, .mp3, .ogg">
<span class="file-cta">
<span class="file-icon">
<i class="fa-solid fa-upload"></i>
</span>
<span class="file-label">
Escolher arquivo de áudio...
</span>
</span>
<span class="file-name has-text-grey-light">
Nenhum arquivo selecionado
</span>
</label>
</div>
<p class="help">Envie um .mp3 ou .wav para que as pessoas possam ouvir antes de baixar.</p>
</div>
<!-- BOTÃO DE ENVIO -->
<div class="field mt-5">
<div class="control">
<button type="submit" class="button is-info is-fullwidth is-medium shadow-sm" id="submit-btn">
<span class="icon"><i class="fa-solid fa-paper-plane"></i></span>
<span>Enviar Projeto</span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- MODAL DE SUCESSO -->
<div id="success-modal" class="modal">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head has-background-success-light">
<p class="modal-card-title has-text-success-dark">Sucesso!</p>
<button class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body has-text-centered p-5">
<span class="icon is-large has-text-success mb-3">
<i class="fa-solid fa-circle-check fa-4x"></i>
</span>
<h3 class="title is-4">Projeto Enviado!</h3>
<p>Obrigado por contribuir. Seu projeto está sendo processado e em breve aparecerá na lista.</p>
</section>
<footer class="modal-card-foot is-justify-content-center has-background-white">
<a href="{{ '/mmp_pages/' | relative_url }}" class="button is-success">Ver Projetos</a>
<button class="button" id="close-success-modal">Enviar Outro</button>
</footer>
</div>
</div>
<style>
/* Estilo do Dropzone */
.file-upload-wrapper {
position: relative;
width: 100%;
height: 200px;
border: 2px dashed #3273dc;
border-radius: 8px;
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
cursor: pointer;
}
.file-upload-wrapper:hover, .file-upload-wrapper.dragover {
background-color: #eef6fc;
border-color: #205081;
}
.file-upload-input {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
opacity: 0;
cursor: pointer;
}
.drag-text {
pointer-events: none; /* Deixa o clique passar para o input */
}
/* Inputs customizados */
.input:focus, .textarea:focus {
border-color: #3273dc;
box-shadow: 0 0 0 0.125em rgba(50, 115, 220, 0.25);
}
</style>
<script>
document.addEventListener('DOMContentLoaded', () => {
// 1. Lógica do Dropzone (Visual)
const dropZone = document.getElementById('drop-zone');
const fileInput = document.getElementById('project_file');
const fileNameDisplay = document.getElementById('file-name-display');
const dragTextTitle = dropZone.querySelector('.title');
// Efeito visual ao arrastar
['dragenter', 'dragover'].forEach(eventName => {
dropZone.addEventListener(eventName, (e) => {
e.preventDefault();
dropZone.classList.add('dragover');
});
});
['dragleave', 'drop'].forEach(eventName => {
dropZone.addEventListener(eventName, (e) => {
dropZone.classList.remove('dragover');
});
});
// Mostrar nome do arquivo selecionado
fileInput.addEventListener('change', () => {
if (fileInput.files.length > 0) {
const name = fileInput.files[0].name;
fileNameDisplay.textContent = name;
fileNameDisplay.classList.remove('is-hidden');
dragTextTitle.textContent = "Arquivo Selecionado!";
dropZone.style.borderColor = "#4caf50";
dropZone.style.backgroundColor = "#f0fff4";
}
});
// 2. Lógica do Input de Áudio (padrão Bulma)
const audioInput = document.querySelector('.file-input');
const audioName = document.querySelector('.file-name');
if(audioInput) {
audioInput.addEventListener('change', () => {
if (audioInput.files.length > 0) {
audioName.textContent = audioInput.files[0].name;
}
});
}
// 3. Simulação de Envio (Modal)
const form = document.getElementById('upload-project-form');
const modal = document.getElementById('success-modal');
const submitBtn = document.getElementById('submit-btn');
const closeBtns = document.querySelectorAll('.delete, #close-success-modal, .modal-background');
form.addEventListener('submit', async (e) => {
e.preventDefault();
submitBtn.classList.add('is-loading');
const formData = new FormData(form);
try {
// APONTA PARA O SEU SERVIDOR PYTHON
// Se estiver rodando localmente, geralmente é localhost:5000
// Se for no servidor de produção, coloque o IP ou domínio correto
const response = await fetch('https://alice.ufsj.edu.br:33002/api/upload', {
method: 'POST',
body: formData
});
const result = await response.json();
if (response.ok) {
// Sucesso!
submitBtn.classList.remove('is-loading');
// Atualiza a mensagem do modal se quiser
const modalTitle = modal.querySelector('.title');
modalTitle.textContent = "Projeto Processado!";
modal.classList.add('is-active');
document.documentElement.classList.add('is-clipped');
form.reset();
document.getElementById('file-name-display').classList.add('is-hidden');
document.querySelector('.drag-text .title').textContent = "Arraste e solte o arquivo aqui";
document.getElementById('drop-zone').style.borderColor = "#3273dc";
document.getElementById('drop-zone').style.backgroundColor = "#fff";
} else {
alert('Erro: ' + (result.error || 'Falha desconhecida'));
submitBtn.classList.remove('is-loading');
}
} catch (error) {
console.error('Erro:', error);
alert('Erro de conexão com o servidor de processamento.');
submitBtn.classList.remove('is-loading');
}
});
// Fechar Modal
closeBtns.forEach(btn => {
btn.addEventListener('click', () => {
modal.classList.remove('is-active');
document.documentElement.classList.remove('is-clipped');
});
});
});
</script>

View File

@ -19,7 +19,7 @@ permalink: /pattern/
<div class="column is-8">
<div
class="box has-background-white-ter has-text-centered shadow-sm"
style="border: 1px solid #cfe8fc"
style="border: 1px solid #cfe8fc; height: fit-content !important; min-height: unset;"
>
<h2 class="title is-5 has-text-grey-dark mb-3">
<span class="icon has-text-info"

View File

@ -1,7 +1,7 @@
---
layout: default
title: Arquivos MMP
permalink: /mmp_pages/
title: MMPSearch - Projetos
permalink: /projetos/
---
<div class="publication">

306
pages/samples.md Normal file
View File

@ -0,0 +1,306 @@
---
layout: default
title: MMPSearch - Samples Disponíveis
permalink: /samples/
---
<meta charset="utf-8" />
<main class="main-content">
<div class="publication">
<div class="container">
<br />
<div class="tabs is-centered is-boxed is-medium mb-6">
{% include sidebar.html %}
</div>
<details class="box mb-5 p-0 collapse-card" open
style="border: 1px solid #cfe8fc; overflow: hidden; background-color: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.05); height: fit-content !important; min-height: unset;">
<summary class="p-4 is-flex is-justify-content-space-between is-align-items-center"
style="cursor: pointer; background-color: #f0f8ff; transition: background-color 0.2s; user-select: none;">
<div class="is-flex is-align-items-center">
<span class="icon has-text-info mr-2"><i class="fa-solid fa-guitar"></i></span>
<span class="has-text-grey-dark has-text-weight-bold">Todos os Samples Disponíveis</span>
<span id="filter-counter" class="tag is-info is-light ml-3 is-hidden">0 selecionados</span>
</div>
<span class="icon has-text-grey-light chevron-icon"><i class="fa-solid fa-chevron-down"></i></span>
</summary>
<div class="p-4" style="background-color: #fff; border-top: 1px solid #cfe8fc;">
<div class="tags is-centered are-medium mb-0">
{% assign all_sample_string = "" %}
{% for p in site.data.all %}
{% for track in p.tracks %}
{% if track.sample %}
{% for inst in track.sample %}
{% if inst.sample_name and inst.sample_name != "" %}
{% unless all_sample_string contains inst.sample_name %}
{% assign all_sample_string = all_sample_string | append: inst.sample_name | append: "|||" %}
{% endunless %}
{% endif %}
{% endfor %}
{% elsif track.sample_name and track.sample_name != "" %}
{% unless all_sample_string contains track.sample_name %}
{% assign all_sample_string = all_sample_string | append: track.sample_name | append: "|||" %}
{% endunless %}
{% endif %}
{% endfor %}
{% endfor %}
{% assign unique_sample = all_sample_string | split: "|||" | sort %}
{% for item in unique_sample %}
{% if item != "" %}
<a href="#" class="tag is-white filter-item clickable-tag"
data-value="{{ item }}"
style="border: 1px solid #deeaf6; color: #5b7da3; margin-bottom: 0.5rem; transition: all 0.2s;">
{{ item }}
</a>
{% endif %}
{% endfor %}
</div>
<div class="has-text-centered mt-3">
<p class="help has-text-grey">Clique para filtrar.</p>
</div>
</div>
</details>
<div class="columns is-mobile is-vcentered mb-5">
<div class="column is-auto">
<h2 class="title is-4 has-text-grey-dark">
<span class="icon has-text-info mr-2"><i class="fa-solid fa-filter"></i></span>
Filtro: <code id="filter-display-name" style="color: #d63384;">(todos)</code>
</h2>
</div>
<div class="column is-narrow">
<button id="clearFilterButton" class="button is-small is-danger is-light">
<span class="icon is-small"><i class="fa-solid fa-xmark"></i></span>
<span>Limpar Tudo</span>
</button>
</div>
</div>
<div id="project-list" class="columns is-multiline">
{% for projeto in site.data.all %}
{% assign project_insts = "" %}
{% for track in projeto.tracks %}
{% if track.sample %}
{% for inst in track.sample %}
{% assign project_insts = project_insts | append: inst.sample_name | append: "," %}
{% endfor %}
{% elsif track.sample_name %}
{% assign project_insts = project_insts | append: track.sample_name | append: "," %}
{% endif %}
{% endfor %}
<div class="column is-12-mobile is-6-tablet is-4-desktop is-3-widescreen project-item"
data-sample="{{ project_insts }}">
<div class="card project-card" style="height: 100%; background-color: #f0f8ff; border: 1px solid #cfe8fc; border-radius: 12px; display: flex; flex-direction: column;">
{% assign file_url = projeto.file | downcase | replace: ' ', '-' | replace: 'ç', 'c' | replace: 'ã', 'a' | replace: 'á', 'a' | replace: 'â', 'a' | replace: 'é', 'e' | replace: 'ê', 'e' | replace: 'í', 'i' | replace: 'ó', 'o' | replace: 'ô', 'o' | replace: 'õ', 'o' | replace: 'ú', 'u' %}
{% assign page_url = '../mmp_pages/' | append: file_url | append: '.html' %}
<a href="{{ page_url }}" style="text-decoration: none; flex: 1; display: flex; flex-direction: column;">
<div class="card-content has-text-centered p-4" style="flex: 1; display: flex; flex-direction: column;">
<div style="width: 50px; height: 50px; background-color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 0.5rem auto; box-shadow: 0 2px 5px rgba(0,0,0,0.05);">
<span class="icon" style="color: #3273dc;"><i class="fa-solid fa-music fa-lg"></i></span>
</div>
<p class="title is-6 mb-2" style="color: #205081; word-break: break-word; font-weight: 700; line-height: 1.2;">
{{ projeto.file }}
</p>
{% if projeto.bpm %}
<div class="mb-3">
<span class="tag is-dark is-rounded is-light" style="font-size: 0.7rem; font-weight: bold; border: 1px solid #ccc;">
🎵 {{ projeto.bpm }} BPM
</span>
</div>
{% else %}
<div class="mb-3" style="height: 24px;"></div>
{% endif %}
<div style="flex: 1;"></div>
{% assign unique_proj_insts = project_insts | split: "," | uniq %}
{% if unique_proj_insts.size > 0 %}
<div class="tags is-centered is-gapless mb-0 mt-2" style="gap: 4px; justify-content: center;">
{% for item in unique_proj_insts %}
{% if item != "" %}
<span class="tag is-white filter-item clickable-tag" data-value="{{ item }}"
style="font-size: 0.65rem; border: 1px solid #deeaf6; color: #5b7da3; padding: 0 6px; height: 1.5em; text-decoration: none; cursor: pointer;">
{{ item | truncate: 15 }}
</span>
{% endif %}
{% endfor %}
</div>
{% endif %}
</div>
</a>
<footer class="card-footer" style="border-top: 1px solid #cfe8fc; background-color: #fff; border-radius: 0 0 12px 12px; overflow: hidden;">
<a href="#" class="card-footer-item js-open-modal" data-target-url="{{ page_url }}" data-modal-title="Detalhes: {{ projeto.file }}" data-full-btn-text="Ir para Página" data-full-btn-link="{{ page_url }}" style="color: #5b7da3; font-size: 0.8rem; font-weight: 600; border-right: 1px solid #eee; transition: background 0.2s;">Ver</a>
{% assign creation_url = '/mmpSearch/creation.html?project=' | append: projeto.file %}
{% assign embed_url = creation_url | append: '&embed=true' %}
<a href="#" class="card-footer-item js-open-modal" data-target-url="{{ embed_url }}" data-modal-title="Editor: {{ projeto.file }}" data-full-btn-text="Abrir Editor" data-full-btn-link="{{ creation_url }}" style="color: #3273dc; font-size: 0.8rem; font-weight: 600;">Editar</a>
</footer>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</main>
<div id="preview-modal" class="modal">
<div class="modal-background"></div>
<div class="modal-card" style="width: 90%; max-width: 800px;">
<header class="modal-card-head" style="background-color: #f0f8ff; border-bottom: 1px solid #cfe8fc;">
<p class="modal-card-title" id="modal-title" style="color: #205081; font-weight: bold;">Preview</p>
<button class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body p-0" style="height: 500px; background-color: #fff;">
<iframe id="preview-iframe" src="" style="width: 100%; height: 100%; border: none;"></iframe>
</section>
<footer class="modal-card-foot" style="justify-content: flex-end; background-color: #fff; border-top: 1px solid #cfe8fc;">
<button class="button" id="close-modal-btn">Fechar</button>
<a href="#" id="full-edit-btn" target="_blank" class="button is-info">Abrir</a>
</footer>
</div>
</div>
<style>
.project-card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(50, 115, 220, 0.15); border-color: #3273dc !important; background-color: #fff !important; }
.clickable-tag:hover { background-color: #e3effd !important; color: #3273dc !important; border-color: #3273dc !important; transform: scale(1.05); }
.tag.is-active-filter { background-color: #3273dc !important; color: #fff !important; border-color: #3273dc !important; font-weight: bold; box-shadow: 0 2px 5px rgba(50, 115, 220, 0.3); }
.collapse-card summary { list-style: none; transition: background 0.2s; }
.collapse-card summary::-webkit-details-marker { display: none; }
.collapse-card[open] summary .chevron-icon { transform: rotate(180deg); }
.chevron-icon { transition: transform 0.3s ease; }
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
const projects = document.querySelectorAll('.project-item');
const filterDisplayName = document.getElementById('filter-display-name');
const filterCounter = document.getElementById('filter-counter');
let activeFilters = [];
function applyFilters() {
if (activeFilters.length > 0) {
filterDisplayName.textContent = activeFilters.join(" + ");
filterCounter.textContent = activeFilters.length + " selecionados";
filterCounter.classList.remove('is-hidden');
} else {
filterDisplayName.textContent = "(todos)";
filterCounter.classList.add('is-hidden');
}
// Atualiza visual das tags
document.querySelectorAll('.filter-item').forEach(tag => {
const val = tag.getAttribute('data-value');
if (activeFilters.includes(val)) {
tag.classList.add('is-active-filter');
} else {
tag.classList.remove('is-active-filter');
}
});
projects.forEach(project => {
const projectInstStr = project.getAttribute('data-sample');
// Cria array de automações deste projeto
const projectInsts = projectInstStr.split(',').map(s => s.trim());
if (activeFilters.length === 0) {
project.style.display = 'block';
} else {
// Lógica OR: Se tiver pelo menos uma das automações filtradas, exibe
const hasMatch = activeFilters.some(filter => projectInsts.includes(filter));
project.style.display = hasMatch ? 'block' : 'none';
}
});
const newUrl = new URL(window.location.href);
if (activeFilters.length > 0) {
newUrl.searchParams.set('sample', activeFilters.join(','));
} else {
newUrl.searchParams.delete('sample');
}
window.history.replaceState({}, '', newUrl);
}
function toggleFilter(val) {
const index = activeFilters.indexOf(val);
if (index > -1) activeFilters.splice(index, 1);
else activeFilters.push(val);
applyFilters();
}
// Inicializa
const urlParams = new URLSearchParams(window.location.search);
const instParam = urlParams.get('sample');
if (instParam) {
activeFilters = instParam.split(',').map(s => s.trim()).filter(s => s !== "");
applyFilters();
}
// Eventos
document.querySelectorAll('.filter-item').forEach(tag => {
tag.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation(); // Evita clique no card se for dentro dele
const val = this.getAttribute('data-value');
toggleFilter(val);
});
});
document.querySelector('#clearFilterButton').addEventListener('click', function () {
activeFilters = [];
applyFilters();
});
// Modal
const modal = document.getElementById('preview-modal');
const iframe = document.getElementById('preview-iframe');
const modalTitle = document.getElementById('modal-title');
const fullEditBtn = document.getElementById('full-edit-btn');
const closeButtons = document.querySelectorAll('.modal-background, .modal-card-head .delete, #close-modal-btn');
function openModal(url, title, btnText, btnLink) {
modalTitle.textContent = title;
iframe.src = url;
fullEditBtn.textContent = btnText;
fullEditBtn.href = btnLink;
modal.classList.add('is-active');
document.documentElement.classList.add('is-clipped');
}
function closeModal() {
modal.classList.remove('is-active');
document.documentElement.classList.remove('is-clipped');
iframe.src = "";
}
document.querySelectorAll('.js-open-modal').forEach(btn => {
btn.addEventListener('click', (e) => {
e.preventDefault();
openModal(btn.dataset.targetUrl, btn.dataset.modalTitle, btn.dataset.fullBtnText, btn.dataset.fullBtnLink);
});
});
iframe.addEventListener('load', () => { try {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
const style = iframeDoc.createElement('style');
style.textContent = `.tabs, .navbar, .sidebar-wrapper, .main-header { display: none !important; } .publication { padding-top: 0 !important; } body { background-color: #fff !important; }`;
iframeDoc.head.appendChild(style);
} catch(e){} });
closeButtons.forEach(el => el.addEventListener('click', closeModal));
document.addEventListener('keydown', (e) => { if (e.key === "Escape") closeModal(); });
});
</script>

Binary file not shown.

View File

@ -1,6 +1,7 @@
# main.py
import os
import json
import shutil
import subprocess
import multiprocessing
@ -274,5 +275,43 @@ def main_parallel():
pass # Erro já logado na função ou irrelevante se arquivos não existirem
def rebuild_indexes():
"""
Função auxiliar para regerar all.json e all.yml baseada nos arquivos processados.
Pode ser chamada pela API após um upload.
"""
logging.info("Regerando índices globais (all.json / all.yml)...")
# Lista todos os JSONs individuais na pasta metadata (exceto os manifestos e o all.json)
all_data = []
ignored_files = [
"all.json",
"samples-manifest.json",
"mmp-manifest.json",
"dependency_report.json",
]
if os.path.exists(METADATA_FOLDER):
for f in os.listdir(METADATA_FOLDER):
if f.endswith(".json") and f not in ignored_files:
try:
with open(
os.path.join(METADATA_FOLDER, f), "r", encoding="utf-8"
) as json_file:
data = json.load(
json_file
) # Precisa importar json no topo se não tiver
all_data.append(data)
except Exception as e:
logging.error(f"Erro ao ler {f} para índice global: {e}")
if all_data:
save_to_json(all_data, os.path.join(METADATA_FOLDER, "all.json"))
save_to_yaml(all_data, os.path.join(DATA_FOLDER, "all.yml"))
logging.info("Índices globais atualizados com sucesso.")
return len(all_data)
if __name__ == "__main__":
main_parallel()

View File

@ -0,0 +1,94 @@
import os
from flask import Flask, request, jsonify
from flask_cors import CORS
from werkzeug.utils import secure_filename
# Importa suas funções e configurações existentes
from main import process_single_file, rebuild_indexes
from utils import MMP_FOLDER, MMPZ_FOLDER
app = Flask(__name__)
CORS(app) # Permite que o HTML converse com o servidor
# Configurações de extensão
ALLOWED_EXTENSIONS = {"mmp", "mmpz"}
def allowed_file(filename):
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route("/api/upload", methods=["POST"])
def upload_file():
# 1. Verificações Básicas
if "project_file" not in request.files:
return jsonify({"error": "Nenhum arquivo enviado"}), 400
file = request.files["project_file"]
if file.filename == "":
return jsonify({"error": "Nome do arquivo vazio"}), 400
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
# 2. Define onde salvar (MMP ou MMPZ)
if filename.endswith(".mmpz"):
save_path = os.path.join(MMPZ_FOLDER, filename)
else:
save_path = os.path.join(MMP_FOLDER, filename)
# Salva o arquivo físico
try:
file.save(save_path)
print(f"Arquivo salvo em: {save_path}")
except Exception as e:
return jsonify({"error": f"Falha ao salvar disco: {str(e)}"}), 500
# 3. DISPARA SEU PIPELINE (Processamento)
# Chama a função do seu main.py para gerar WAV e extrair dados
result = process_single_file(filename)
if result["success"]:
# 4. Atualiza o site.data.all (all.json)
rebuild_indexes()
return jsonify(
{"message": "Projeto processado com sucesso!", "data": result["data"]}
), 200
else:
return jsonify({"error": f"Erro no processamento: {result['error']}"}), 500
return jsonify({"error": "Tipo de arquivo não permitido"}), 400
if __name__ == "__main__":
print("Iniciando Servidor de Upload MMP...")
# Tenta localizar os certificados reais do servidor (Comum em servidores Linux/Apache/Nginx)
# Ajuste esses caminhos se souber onde os certificados do alice.ufsj.edu.br estão
cert_path = "/etc/letsencrypt/live/alice.ufsj.edu.br/fullchain.pem"
key_path = "/etc/letsencrypt/live/alice.ufsj.edu.br/privkey.pem"
# Opção 1: Usar certificado real (O ideal - Navegador aceita de primeira)
if os.path.exists(cert_path) and os.path.exists(key_path):
print("Certificados encontrados! Rodando HTTPS seguro na porta 33002.")
context = (cert_path, key_path)
# Use host='0.0.0.0' para garantir que escute externamente
app.run(host="0.0.0.0", port=33002, ssl_context=context, debug=True)
# Opção 2: Modo 'adhoc' (Certificado temporário gerado na hora)
else:
print(
"Certificados reais não encontrados. Usando modo 'adhoc' (Auto-assinado)."
)
print(
"ATENÇÃO: O navegador vai avisar que 'Não é seguro'. Você precisará autorizar."
)
# Requer: pip install pyopenssl
try:
app.run(host="0.0.0.0", port=33002, ssl_context="adhoc", debug=True)
except Exception as e:
print(f"Erro ao iniciar SSL adhoc: {e}")
print("Tentando rodar em HTTP simples (pode dar erro de Mixed Content)...")
app.run(host="0.0.0.0", port=33002, debug=True)

View File

@ -1,206 +0,0 @@
import os
import json
import subprocess
import time
from threading import Thread
from flask import Flask, request, jsonify
from werkzeug.utils import secure_filename
from flask_cors import CORS
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import requests
NODE_SERVER_URL = "https://127.0.0.1:33001"
# --- Configurações (sem alterações) ---
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
print(f"Raiz do projeto detectada em: {PROJECT_ROOT}")
CONFIGS = [
{
"source_dir": "src/samples",
"output_file": "metadata/samples-manifest.json",
"scan_type": "tree"
},
{
"source_dir": "mmp",
"output_file": "metadata/mmp-manifest.json",
"scan_type": "list",
"extensions": ['.mmp', '.mmpz']
}
]
UPLOAD_FOLDER_SAMPLE = os.path.join(PROJECT_ROOT, "src", "samples", "samples")
WATCH_FOLDER_SAMPLE = UPLOAD_FOLDER_SAMPLE # Pasta a ser vigiada
UPLOAD_FOLDER_PROJECT = os.path.join(PROJECT_ROOT, "src", "samples", "projects")
WATCH_FOLDER_PROJECT = os.path.join(PROJECT_ROOT, "src", "upload_projects") # Pasta a ser vigiada
ALLOWED_EXTENSIONS = {'wav', 'ogg', 'flac', 'mp3'}
app = Flask(__name__)
CORS(app, origins=["https://alice.ufsj.edu.br", "https://alice.ufsj.edu.br:33002"])
app.config['UPLOAD_FOLDER_SAMPLE'] = UPLOAD_FOLDER_SAMPLE
# --- Funções do Gerador de Manifesto (sem alterações) ---
def scan_directory_tree(path):
tree = {}
if not os.path.isdir(path): return tree
for item in sorted(os.listdir(path)):
full_path = os.path.join(path, item)
if os.path.isdir(full_path):
tree[item] = scan_directory_tree(full_path)
else:
if item.lower().endswith(('.wav', '.ogg', '.flac', '.mp3')):
tree[item] = {"_isFile": True}
return tree
def scan_directory_list(path, allowed_extensions):
file_list = []
if not os.path.isdir(path): return file_list
for item in os.listdir(path):
full_path = os.path.join(path, item)
if os.path.isfile(full_path) and any(item.lower().endswith(ext) for ext in allowed_extensions):
file_list.append(item)
return sorted(file_list)
def run_jekyll_build():
print("\nExecutando o comando de build do Jekyll...")
destination_path = "/nethome/jotachina/public_html/mmpSearch/"
jekyll_args = ["--destination", destination_path, "--force"]
try:
command = ["bundle", "exec", "jekyll", "build"] + jekyll_args
result = subprocess.run(command, cwd=PROJECT_ROOT, capture_output=True, text=True, check=False)
if result.returncode != 0:
print("Falha com 'bundle', tentando 'jekyll build' diretamente...")
command = ["jekyll", "build"] + jekyll_args
result = subprocess.run(command, cwd=PROJECT_ROOT, capture_output=True, text=True, check=False)
if result.returncode == 0:
print("SUCESSO: Jekyll build concluído.")
else:
print(f"ERRO no Jekyll build: {result.stderr}")
except Exception as e:
print(f"ERRO inesperado durante o Jekyll build: {e}")
def notify_node_server(update_type):
"""Envia uma notificação HTTP para o servidor Node.js."""
try:
url = f"{NODE_SERVER_URL}/notify-update"
headers = {'Content-Type': 'application/json'}
payload = {"updateType": update_type}
# O argumento 'verify=False' é geralmente necessário ao usar 127.0.0.1
# com certificados Let's Encrypt (ou autoassinados) para evitar erros de SSL.
response = requests.post(url, json=payload, headers=headers, verify=False)
if response.status_code == 200:
print(f"[Notificação] Sucesso ao notificar Node.js: {update_type}")
else:
print(f"[Notificação] ERRO ao notificar Node.js ({response.status_code}): {response.text}")
except Exception as e:
print(f"[Notificação] ERRO de conexão com o Node.js em {NODE_SERVER_URL}: {e}")
def generate_manifests():
print("\nIniciando geração de arquivos de manifesto...")
for config in CONFIGS:
source_dir_abs = os.path.join(PROJECT_ROOT, config["source_dir"])
output_file_abs = os.path.join(PROJECT_ROOT, config["output_file"])
if not os.path.isdir(source_dir_abs): continue
result_data = None
if config["scan_type"] == "tree": result_data = scan_directory_tree(source_dir_abs)
elif config["scan_type"] == "list": result_data = scan_directory_list(source_dir_abs, config.get("extensions", []))
if result_data is not None:
output_dir = os.path.dirname(output_file_abs)
os.makedirs(output_dir, exist_ok=True)
with open(output_file_abs, 'w', encoding='utf-8') as f:
json.dump(result_data, f, indent=2, ensure_ascii=False)
print(f"SUCESSO: Arquivo '{output_file_abs}' gerado!")
print("\nGeração de manifestos concluída.")
run_jekyll_build()
# 2. NOTIFICA O SERVIDOR NODE.JS (NOVO PASSO)
notify_node_server("samples")
# --- Servidor Flask ---
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/upload-sample', methods=['POST'])
def upload_file():
if 'sampleFile' not in request.files: return jsonify({"error": "Nenhum arquivo enviado"}), 400
file = request.files['sampleFile']
if file.filename == '': return jsonify({"error": "Nenhum arquivo selecionado"}), 400
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
os.makedirs(app.config['UPLOAD_FOLDER_SAMPLE'], exist_ok=True)
save_path = os.path.join(app.config['UPLOAD_FOLDER_SAMPLE'], filename)
try:
file.save(save_path)
return jsonify({"success": True, "message": f"Arquivo '{filename}' salvo!"}), 200
except Exception as e:
return jsonify({"error": str(e)}), 500
return jsonify({"error": "Tipo de arquivo não permitido"}), 400
# --- LÓGICA DO "VIGIA" DE ARQUIVOS (WATCHDOG) ---
class ManifestEventHandler(FileSystemEventHandler):
"""Um manipulador de eventos que gera os manifestos quando um arquivo muda."""
def __init__(self):
# Inicializa o timestamp da última execução
self.last_triggered = 0
# Define o intervalo mínimo entre execuções (5 segundos)
self.debounce_interval = 5
def on_any_event(self, event):
# Ignora eventos em diretórios ou no arquivo de manifesto de saída (evita loop)
if event.is_directory or "manifest" in event.src_path:
return
current_time = time.time()
# Verifica se passou tempo suficiente desde o último acionamento
if current_time - self.last_triggered > self.debounce_interval:
print(f"\n[VIGIA] Mudança detectada: {event.src_path}")
# Executa a geração de manifestos (e o Jekyll build, se descomentado)
# É crucial que generate_manifests() seja rápido ou executado em outra thread separada
# para não bloquear o Watchdog por muito tempo.
Thread(target=generate_manifests).start()
self.last_triggered = current_time
else:
print(f"[VIGIA] Mudança ignorada devido ao debounce (Intervalo de {self.debounce_interval}s).")
def start_file_watcher():
"""Inicia o observador de arquivos para ambas as pastas em uma thread separada."""
event_handler = ManifestEventHandler()
observer = Observer()
# 1. Monitorar a pasta de Samples
print(f"\n[VIGIA] Monitorando Samples: {WATCH_FOLDER_SAMPLE}")
observer.schedule(event_handler, WATCH_FOLDER_SAMPLE, recursive=True)
# 2. Monitorar a pasta de Projetos
print(f"[VIGIA] Monitorando Projetos: {WATCH_FOLDER_PROJECT}")
observer.schedule(event_handler, WATCH_FOLDER_PROJECT, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
# --- ATUALIZAÇÃO: INICIALIZAÇÃO PRINCIPAL ---
if __name__ == '__main__':
# Gera os manifestos uma vez ao iniciar o servidor
generate_manifests()
# Inicia o "vigia" de arquivos em uma thread separada (em segundo plano)
watcher_thread = Thread(target=start_file_watcher, daemon=True)
watcher_thread.start()
# Inicia o servidor Flask (thread principal)
print("\n[FLASK] Iniciando servidor de upload...")
app.run(host='0.0.0.0', port=33002, debug=True) # Debug mode deve ser False para evitar que rode duas vezes