From 5ea3ad0110901036bc9b538abe7d5af152366a81 Mon Sep 17 00:00:00 2001 From: JotaChina Date: Tue, 16 Dec 2025 20:35:56 -0300 Subject: [PATCH] reformula buscas --- pages/projetos.md | 241 +++++++++++++++++++++------------------------- 1 file changed, 109 insertions(+), 132 deletions(-) diff --git a/pages/projetos.md b/pages/projetos.md index 8032862a..fbca73f0 100755 --- a/pages/projetos.md +++ b/pages/projetos.md @@ -12,7 +12,11 @@ permalink: /projetos/ {% assign list_automation = "" %} {% for p in site.data.all %} - {% if p.bpm %}{% assign list_bpm = list_bpm | append: p.bpm | append: "|||" %}{% endif %} + {% assign raw_bpm = p.bpm | append: "" %} + {% if raw_bpm != "" and raw_bpm != "N/A" and raw_bpm != "nil" %} + {% assign list_bpm = list_bpm | append: raw_bpm | append: "|||" %} + {% endif %} + {% for item in p.tags.plugin %}{% if item != "" %}{% assign list_plugins = list_plugins | append: item | append: "|||" %}{% endif %}{% endfor %} {% if p.tags.bassline %}{% for item in p.tags.bassline %}{% if item != "" %}{% assign list_bassline = list_bassline | append: item | append: "|||" %}{% endif %}{% endfor %}{% endif %} {% if p.tags.automation %}{% for item in p.tags.automation %}{% if item != "" %}{% assign list_automation = list_automation | append: item | append: "|||" %}{% endif %}{% endfor %}{% endif %} @@ -35,8 +39,8 @@ permalink: /projetos/ {% assign min_limit = 0 %} {% assign max_limit = 300 %} {% if unique_bpm_array.size > 0 %} - {% assign min_limit = unique_bpm_array | first | minus: 0 %} - {% assign max_limit = unique_bpm_array | last | plus: 0 %} + {% assign last_bpm = unique_bpm_array | last | plus: 0 %} + {% if last_bpm > max_limit %}{% assign max_limit = last_bpm %}{% endif %} {% endif %}
@@ -165,66 +169,37 @@ permalink: /projetos/
-
- Instrumentos -
- -
-
- {% for item in unique_instruments %}{% if item != "" %} - - {% endif %}{% endfor %} -
-
-
+ {% assign filter_groups = "instruments|Instrumentos,plugins|Plugins,bassline|Bassline,automation|Automação,samples|Samples" | split: "," %} + {% for group in filter_groups %} + {% assign parts = group | split: "|" %} + {% assign cat_key = parts[0] %} + {% assign cat_label = parts[1] %} + +
+ {{ cat_label }} +
+ +
+
+ {% assign current_list = "" %} + {% if cat_key == 'instruments' %}{% assign current_list = unique_instruments %} + {% elsif cat_key == 'plugins' %}{% assign current_list = unique_plugins %} + {% elsif cat_key == 'bassline' %}{% assign current_list = unique_bassline %} + {% elsif cat_key == 'automation' %}{% assign current_list = unique_automation %} + {% elsif cat_key == 'samples' %}{% assign current_list = unique_samples %} + {% endif %} -
- Plugins -
- -
-
- {% for item in unique_plugins %}{% if item != "" %} - - {% endif %}{% endfor %} -
-
-
- -
Bassline -
- -
-
- {% for item in unique_bassline %}{% if item != "" %}{% endif %}{% endfor %} -
-
-
-
Automação -
- -
-
- {% for item in unique_automation %}{% if item != "" %}{% endif %}{% endfor %} -
-
-
-
Samples -
- -
-
- {% for item in unique_samples %}{% if item != "" %}{% endif %}{% endfor %} -
-
+ {% for item in current_list %}{% if item != "" %} + + {% endif %}{% endfor %} +
+
+
+ {% endfor %}
@@ -240,13 +215,20 @@ permalink: /projetos/ {% for page in project_pages %} {% if page.url != '/projetos/' %} + {% assign raw_bpm = page.bpm | append: "" %} + {% if raw_bpm == "" or raw_bpm == "N/A" or raw_bpm == "nil" %} + {% assign p_bpm = 0 %} + {% else %} + {% assign p_bpm = raw_bpm | plus: 0 %} + {% endif %} + {% assign p_insts_array = "" | split: "," %} {% for track in page.tracks %} {% if track.instruments %}{% for inst in track.instruments %}{% if inst.instrument_name %}{% assign p_insts_array = p_insts_array | push: inst.instrument_name %}{% endif %}{% endfor %} {% elsif track.instrument_name %}{% assign p_insts_array = p_insts_array | push: track.instrument_name %}{% endif %} {% endfor %} {% assign p_instruments_str = p_insts_array | uniq | join: ',' %} - {% assign p_bpm = page.bpm | default: 0 %} + {% assign p_plugins = page.tags.plugin | join: ',' %} {% assign p_bassline = page.tags.bassline | join: ',' %} {% assign p_automation = page.tags.automation | join: ',' %} @@ -279,9 +261,13 @@ permalink: /projetos/

- {% if page.bpm %} + {% if p_bpm > 0 %} - 🎵 {{ page.bpm }} BPM + 🎵 {{ p_bpm }} BPM + + {% else %} + + ⚠️ BPM N/A {% endif %}
@@ -289,7 +275,10 @@ permalink: /projetos/
+ + {% assign tags_list = "" %} {% assign unique_insts_page = p_insts_array | uniq | sort %} + {% if unique_insts_page.size > 0 %}
@@ -298,9 +287,7 @@ permalink: /projetos/
{% for tag in unique_insts_page %}{% if tag != "" %} - + {{ tag | truncate: 18 }} {% endif %}{% endfor %} @@ -308,7 +295,7 @@ permalink: /projetos/
{% endif %} - {% if page.tags.plugin and page.tags.plugin.size > 0 %} + {% if page.tags.plugin.size > 0 %}
🔌 PLUGINS
@@ -316,9 +303,7 @@ permalink: /projetos/
{% for tag in page.tags.plugin %}{% if tag != "" %} - + {{ tag | truncate: 18 }} {% endif %}{% endfor %} @@ -326,7 +311,7 @@ permalink: /projetos/
{% endif %} - {% if page.tags.bassline and page.tags.bassline.size > 0 %} + {% if page.tags.bassline.size > 0 %}
🎹 BASSLINE
@@ -334,9 +319,7 @@ permalink: /projetos/
{% for tag in page.tags.bassline %}{% if tag != "" %} - + {{ tag | truncate: 18 }} {% endif %}{% endfor %} @@ -344,7 +327,7 @@ permalink: /projetos/
{% endif %} - {% if page.tags.automation and page.tags.automation.size > 0 %} + {% if page.tags.automation.size > 0 %}
🎚️ AUTOMATION
@@ -352,9 +335,7 @@ permalink: /projetos/
{% for tag in page.tags.automation %}{% if tag != "" %} - + {{ tag | truncate: 18 }} {% endif %}{% endfor %} @@ -362,7 +343,7 @@ permalink: /projetos/
{% endif %} - {% if page.tags.sample and page.tags.sample.size > 0 %} + {% if page.tags.sample.size > 0 %}
🎤 SAMPLES
@@ -370,9 +351,7 @@ permalink: /projetos/
{% for tag in page.tags.sample %}{% if tag != "" %} - + {{ tag | truncate: 18 }} {% endif %}{% endfor %} @@ -517,7 +496,7 @@ document.addEventListener('DOMContentLoaded', function () { let currentMinStars = 'all'; let searchText = ""; - // Definição Inicial BPM + // Definição Inicial BPM (Do HTML) let defMin = parseInt(inputMin.value), defMax = parseInt(inputMax.value); // --- 2. LÓGICA DO SLIDER DE BPM (Dual) --- @@ -555,6 +534,18 @@ document.addEventListener('DOMContentLoaded', function () { .then(data => { enrichCards(data); createGenreCheckboxes(data); + + // Recalcula limites de BPM com base nos dados reais (Opcional, mas ajusta o maximo) + const bpms = data.map(i => parseFloat(i.analise_tecnica?.bpm || 0)).filter(b => b > 0); + if(bpms.length > 0) { + const maxData = Math.ceil(Math.max(...bpms)); + if(maxData > parseInt(sliderMax.max)) { + sliderMax.max = maxData; + inputMax.max = maxData; + sliderMin.max = maxData; + inputMin.max = maxData; + } + } applyGlobalFilters(); }) .catch(console.warn); @@ -585,7 +576,6 @@ document.addEventListener('DOMContentLoaded', function () { const titleKey = normalizarChaveJS(item.getAttribute('data-title')); const info = mapDados[titleKey]; - // Padrões let genero = "Unknown", subgeneros = [], estrelas = 0, intensidade = -100, bpm = 0, tomHtml = "", tomRaw = "all", subTagsHTML = ""; if (info) { @@ -611,18 +601,33 @@ document.addEventListener('DOMContentLoaded', function () { } } - // Atributos item.setAttribute('data-genre', genero); item.setAttribute('data-subgenres', subgeneros.join(',').toLowerCase()); item.setAttribute('data-stars', estrelas); item.setAttribute('data-intensity', intensidade); item.setAttribute('data-key', tomRaw); - if(bpm > 0) item.setAttribute('data-bpm-real', bpm); + + // Se o JSON tiver um BPM real, usamos ele (sobrescrevendo o do Liquid se precisar) + // Se o projeto for 0, mas o JSON tiver valor, atualizamos. + if(bpm > 0) { + item.setAttribute('data-bpm-real', bpm); + // Atualiza o atributo usado no filtro se o liquid falhou + if(item.getAttribute('data-bpm') == "0") item.setAttribute('data-bpm', Math.round(bpm)); + } - // Visual const bpmContainer = card.querySelector('.bpm-container'); if(bpmContainer) { - const existingBpm = bpmContainer.innerHTML; + // Mantém o BPM original se existir, ou o novo do JSON + let bpmDisplay = ""; + if(bpm > 0) { + bpmDisplay = `🎵 ${Math.round(bpm)} BPM`; + } else if (item.getAttribute('data-bpm') != "0") { + // Mantém o que veio do Liquid se for válido + bpmDisplay = bpmContainer.innerHTML; + } else { + bpmDisplay = `⚠️ BPM N/A`; + } + let newHtml = `
`; newHtml += `
${renderizarDificuldade(estrelas)}
`; newHtml += `
`; @@ -637,7 +642,8 @@ document.addEventListener('DOMContentLoaded', function () { newHtml += `
`; if(subTagsHTML) newHtml += `
${subTagsHTML}
`; newHtml += `
`; - bpmContainer.innerHTML = existingBpm + newHtml; + + bpmContainer.innerHTML = bpmDisplay + newHtml; } }); } @@ -649,7 +655,7 @@ document.addEventListener('DOMContentLoaded', function () { if(Array.isArray(i.analise_ia?.nuvem_tags)) i.analise_ia.nuvem_tags.forEach(t => genres.add(t.tag)); }); - sidebarGenreContainer.innerHTML = ""; // Clear loader + sidebarGenreContainer.innerHTML = ""; Array.from(genres).sort().forEach(g => { const label = document.createElement('label'); label.className = "checkbox is-block mb-1 is-size-7"; @@ -657,13 +663,11 @@ document.addEventListener('DOMContentLoaded', function () { sidebarGenreContainer.appendChild(label); }); - // Re-attach listeners to new checkboxes document.querySelectorAll('#sidebar-genres .filter-checkbox').forEach(cb => { cb.addEventListener('change', updateActiveSidebar); }); } - // --- 4. GESTÃO DE FILTROS --- function updateActiveSidebar() { activeSidebar = { instruments: [], plugins: [], samples: [], bassline: [], automation: [], keys: [], genres: [] }; document.querySelectorAll('.filter-checkbox').forEach(bx => { @@ -677,15 +681,12 @@ document.addEventListener('DOMContentLoaded', function () { applyGlobalFilters(); } - // --- MAIN FILTER LOGIC WITH HIGHLIGHTING --- function applyGlobalFilters() { let visibleCount = 0; let minBpm = parseInt(inputMin.value); let maxBpm = parseInt(inputMax.value); if(minBpm > maxBpm) { let t = minBpm; minBpm = maxBpm; maxBpm = t; } - // Coleta todos os termos de busca para o highlight - // (Junta todos os filtros de texto ativos em um único set para performance) const allActiveTags = new Set([ ...activeSidebar.instruments, ...activeSidebar.plugins, @@ -696,27 +697,26 @@ document.addEventListener('DOMContentLoaded', function () { ...activeSidebar.keys ].map(s => s.toLowerCase())); - // Check if any filter (except stars/bpm) is active to trigger auto-open const hasActiveTypeFilter = allActiveTags.size > 0 || (searchText.length > 2); document.querySelectorAll('.project-item').forEach(item => { - // Leitura const pName = item.getAttribute('data-name') || ""; - const pBpm = parseInt(item.getAttribute('data-bpm')) || 0; + // Garante que é número. Se "0" ou "NaN", vira 0. + let pBpm = parseInt(item.getAttribute('data-bpm')); + if(isNaN(pBpm)) pBpm = 0; + const pInsts = (item.getAttribute('data-instruments') || "").split(','); const pPlugins = (item.getAttribute('data-plugins') || "").split(','); const pSamples = (item.getAttribute('data-samples') || "").split(','); const pBassline = (item.getAttribute('data-bassline') || "").split(','); const pAutomation = (item.getAttribute('data-automation') || "").split(','); - // Novos (IA/Sidebar) const pGenre = (item.getAttribute('data-genre') || "").toLowerCase(); const pSubs = (item.getAttribute('data-subgenres') || "").toLowerCase(); const pTagsIA = pGenre + "," + pSubs; const pKey = item.getAttribute('data-key') || 'all'; const pStars = parseInt(item.getAttribute('data-stars') || 0); - // Matches const matchInst = activeSidebar.instruments.length === 0 || activeSidebar.instruments.some(f => pInsts.includes(f)); const matchPlugin = activeSidebar.plugins.length === 0 || activeSidebar.plugins.some(f => pPlugins.includes(f)); const matchSample = activeSidebar.samples.length === 0 || activeSidebar.samples.some(f => pSamples.includes(f)); @@ -736,34 +736,26 @@ document.addEventListener('DOMContentLoaded', function () { item.style.display = 'block'; visibleCount++; - // --- HIGHLIGHT LOGIC --- - // 1. Reset highlights + // Highlight const clickableTags = item.querySelectorAll('.clickable-tag'); clickableTags.forEach(t => t.classList.remove('is-matched-tag')); - // 2. Apply matches & Auto-open if(hasActiveTypeFilter) { - // Close all details first to reduce noise (optional strategy) item.querySelectorAll('details').forEach(d => d.open = false); - clickableTags.forEach(tagEl => { const tagVal = (tagEl.dataset.tagValue || "").trim().toLowerCase(); - // Check exact match from filters OR text search partial match const isFilterMatch = allActiveTags.has(tagVal); const isTextMatch = searchText.length > 2 && tagVal.includes(searchText); if (isFilterMatch || isTextMatch) { tagEl.classList.add('is-matched-tag'); const parentDetails = tagEl.closest('details'); - if(parentDetails) parentDetails.open = true; // Auto-open! + if(parentDetails) parentDetails.open = true; } }); - } - // If no filters active, maybe leave default open state (usually instruments open) - else { - // Reset to default (Instruments open, others closed) + } else { item.querySelectorAll('details').forEach(d => d.open = false); - const instDetail = item.querySelector('details:first-of-type'); // Assuming instruments is first + const instDetail = item.querySelector('details:first-of-type'); if(instDetail) instDetail.open = true; } @@ -777,15 +769,11 @@ document.addEventListener('DOMContentLoaded', function () { noResults.classList.toggle('is-hidden', visibleCount > 0); } - // --- 5. EVENT LISTENERS GERAIS --- checkboxes.forEach(cb => cb.addEventListener('change', updateActiveSidebar)); - searchInput.addEventListener('input', (e) => { searchText = e.target.value.toLowerCase().trim(); applyGlobalFilters(); }); clearInputBtn.addEventListener('click', () => { searchInput.value = ""; searchText = ""; applyGlobalFilters(); }); - if(starFilterSelect) starFilterSelect.addEventListener('change', (e) => { currentMinStars = e.target.value; applyGlobalFilters(); }); - // Sort if(sortSelect) sortSelect.addEventListener('change', (e) => { const crit = e.target.value; const cols = Array.from(projectsContainer.children); @@ -801,19 +789,13 @@ document.addEventListener('DOMContentLoaded', function () { cols.forEach(c => projectsContainer.appendChild(c)); }); - // Limpeza Individual de Grupos clearGroupBtns.forEach(btn => { btn.addEventListener('click', (e) => { - e.preventDefault(); - e.stopPropagation(); // Não fechar o details + e.preventDefault(); e.stopPropagation(); const target = btn.dataset.target; - - // Reseta BPM especificamente ou checkboxes if(target === 'bpm') { - sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; - updateSlider(); + sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; updateSlider(); } else { - // Desmarca checkboxes daquela categoria document.querySelectorAll(`.filter-checkbox[data-category="${target}"]`).forEach(cb => { cb.checked = false; if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.remove('is-checked'); @@ -823,19 +805,14 @@ document.addEventListener('DOMContentLoaded', function () { }); }); - // Reset Total resetBtn.addEventListener('click', () => { document.querySelectorAll('.filter-checkbox').forEach(cb => { cb.checked = false; cb.parentElement.classList.remove('is-checked'); }); searchInput.value = ""; searchText = ""; - sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; updateSlider(); - starFilterSelect.value = 'all'; currentMinStars = 'all'; - sortSelect.value = 'default'; - + starFilterSelect.value = 'all'; currentMinStars = 'all'; sortSelect.value = 'default'; updateActiveSidebar(); }); - // Modal const modal = document.getElementById('preview-modal'); const iframe = document.getElementById('preview-iframe'); const modalTitle = document.getElementById('modal-title');