From 007a40cdb2be4aaf269c166435aee14ea6f0f7b6 Mon Sep 17 00:00:00 2001 From: JotaChina Date: Tue, 16 Dec 2025 17:51:01 -0300 Subject: [PATCH] reformula buscas --- pages/projetos.md | 123 +++++++++++++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 35 deletions(-) diff --git a/pages/projetos.md b/pages/projetos.md index 81cb0180..3f533e89 100755 --- a/pages/projetos.md +++ b/pages/projetos.md @@ -12,26 +12,45 @@ permalink: /projetos/ {% assign list_automation = "" %} {% for p in site.data.all %} - {% if p.bpm %}{% assign list_bpm = list_bpm | append: p.bpm | append: "|||" %}{% endif %} + {% if p.bpm %} + {% assign list_bpm = list_bpm | append: p.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 %} {% for track in p.tracks %} - {% if track.instruments %}{% for inst in track.instruments %}{% assign list_instruments = list_instruments | append: inst.instrument_name | append: "|||" %}{% endfor %} - {% elsif track.instrument_name %}{% assign list_instruments = list_instruments | append: track.instrument_name | append: "|||" %}{% endif %} + {% if track.instruments %} + {% for inst in track.instruments %} + {% if inst.instrument_name and inst.instrument_name != "" %} + {% assign list_instruments = list_instruments | append: inst.instrument_name | append: "|||" %} + {% endif %} + {% endfor %} + {% elsif track.instrument_name and track.instrument_name != "" %} + {% assign list_instruments = list_instruments | append: track.instrument_name | append: "|||" %} + {% endif %} + {% if track.sample %}{% for smp in track.sample %}{% assign list_samples = list_samples | append: smp.sample_name | append: "|||" %}{% endfor %} {% elsif track.sample_name %}{% assign list_samples = list_samples | append: track.sample_name | append: "|||" %}{% endif %} {% endfor %} {% endfor %} -{% assign unique_bpm = list_bpm | split: "|||" | uniq | sort %} +{% assign unique_bpm_array = list_bpm | split: "|||" | uniq | sort %} {% assign unique_plugins = list_plugins | split: "|||" | uniq | sort %} {% assign unique_instruments = list_instruments | split: "|||" | uniq | sort %} {% assign unique_samples = list_samples | split: "|||" | uniq | sort %} {% assign unique_bassline = list_bassline | split: "|||" | uniq | sort %} {% assign unique_automation = list_automation | split: "|||" | uniq | sort %} +{% assign min_bpm_val = 0 %} +{% assign max_bpm_val = 300 %} +{% if unique_bpm_array.size > 0 %} + {% assign min_bpm_val = unique_bpm_array | first %} + {% assign max_bpm_val = unique_bpm_array | last %} +{% endif %} + +

@@ -44,7 +63,7 @@ permalink: /projetos/

📁 Projetos Disponíveis

- Busca avançada: Digite termos ou selecione filtros para refinar. + Busca avançada: Use o slicer de BPM ou filtros de tag para encontrar o projeto ideal.

@@ -72,19 +91,18 @@ permalink: /projetos/
- -
- {% for item in unique_bpm %} - {% if item != "" %} -
- -
- {% endif %} - {% endfor %} + +
+
+ + +
+
+ + +
+

Projetos entre esses valores.


@@ -161,12 +179,26 @@ permalink: /projetos/ {% for page in project_pages %} {% if page.url != '/projetos/' %} - {% assign p_bpm = page.bpm | append: "" %} + {% 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: ',' %} {% assign p_samples = page.tags.sample | join: ',' %} - {% assign p_instruments = page.tags.instruments | default: page.tags.instrument | join: ',' %} {% assign p_name = page.title | default: page.name | downcase %} @@ -176,7 +208,7 @@ permalink: /projetos/ data-plugins="{{ p_plugins }}" data-bassline="{{ p_bassline }}" data-automation="{{ p_automation }}" - data-instruments="{{ p_instruments }}" + data-instruments="{{ p_instruments_str }}" data-samples="{{ p_samples }}">
- {% assign inst_tags = page.tags.instruments | default: page.tags.instrument %} - {% if inst_tags and inst_tags.size > 0 %} + {% assign unique_insts_page = p_insts_array | uniq | sort %} + {% if unique_insts_page.size > 0 %}
🎾 INSTRUMENTS
- {% for tag in inst_tags %}{% if tag != "" %} - {{ tag | truncate: 18 }} - {% endif %}{% endfor %} + {% for tag in unique_insts_page %} + {% if tag != "" %} + {{ tag | truncate: 18 }} + {% endif %} + {% endfor %}
{% endif %} @@ -370,6 +404,10 @@ permalink: /projetos/ document.addEventListener('DOMContentLoaded', function () { const checkboxes = document.querySelectorAll('.filter-checkbox'); const searchInput = document.getElementById('search-input'); + // Inputs de BPM + const bpmMinInput = document.getElementById('bpm-min'); + const bpmMaxInput = document.getElementById('bpm-max'); + const projects = document.querySelectorAll('.project-item'); const resetBtn = document.getElementById('reset-all-filters'); const countBar = document.getElementById('results-count-bar'); @@ -377,17 +415,22 @@ document.addEventListener('DOMContentLoaded', function () { const noResults = document.getElementById('no-results'); // Estado do Filtro - let activeFilters = { bpm: [], instruments: [], plugins: [], samples: [], bassline: [], automation: [] }; + let activeFilters = { instruments: [], plugins: [], samples: [], bassline: [], automation: [] }; let searchText = ""; + + // Valores Iniciais de BPM + let initialMinBpm = parseInt(bpmMinInput.value) || 0; + let initialMaxBpm = parseInt(bpmMaxInput.value) || 999; function updateState() { - // Reseta Arrays - activeFilters = { bpm: [], instruments: [], plugins: [], samples: [], bassline: [], automation: [] }; + // Reseta Arrays (menos BPM que Ă© tratado separado) + activeFilters = { instruments: [], plugins: [], samples: [], bassline: [], automation: [] }; // LĂȘ Checkboxes checkboxes.forEach(cb => { if (cb.checked) { const category = cb.getAttribute('data-category'); + // BPM nĂŁo usa checkbox mais, mas mantive a segurança if (activeFilters[category]) activeFilters[category].push(cb.value); if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.add('is-checked'); } else { @@ -403,28 +446,33 @@ document.addEventListener('DOMContentLoaded', function () { function applyFilters() { let visibleCount = 0; + + // LĂȘ valores atuais do Slicer de BPM + const currentMinBpm = parseInt(bpmMinInput.value) || 0; + const currentMaxBpm = parseInt(bpmMaxInput.value) || 999; projects.forEach(project => { // LĂȘ dados do elemento const pName = project.getAttribute('data-name') || ""; - const pBpm = project.getAttribute('data-bpm') || ""; + const pBpm = parseInt(project.getAttribute('data-bpm')) || 0; const pInsts = (project.getAttribute('data-instruments') || "").split(','); const pPlugins = (project.getAttribute('data-plugins') || "").split(','); const pSamples = (project.getAttribute('data-samples') || "").split(','); const pBassline = (project.getAttribute('data-bassline') || "").split(','); const pAutomation = (project.getAttribute('data-automation') || "").split(','); - // 1. Checa Filtros de Categoria (Checkbox) - const matchBpm = activeFilters.bpm.length === 0 || activeFilters.bpm.includes(pBpm); + // 1. Checa SLICER DE BPM (LĂłgica de Intervalo) + const matchBpm = (pBpm >= currentMinBpm && pBpm <= currentMaxBpm); + + // 2. Checa Filtros de Categoria (Checkbox) const matchInst = activeFilters.instruments.length === 0 || activeFilters.instruments.some(f => pInsts.includes(f)); const matchPlugin = activeFilters.plugins.length === 0 || activeFilters.plugins.some(f => pPlugins.includes(f)); const matchSample = activeFilters.samples.length === 0 || activeFilters.samples.some(f => pSamples.includes(f)); const matchBassline = activeFilters.bassline.length === 0 || activeFilters.bassline.some(f => pBassline.includes(f)); const matchAutomation = activeFilters.automation.length === 0 || activeFilters.automation.some(f => pAutomation.includes(f)); - // 2. Checa Busca de Texto (IA Filter) - // Concatena tudo para buscar em qualquer campo - const fullMeta = [pName, pBpm, pInsts.join(' '), pPlugins.join(' '), pSamples.join(' '), pBassline.join(' '), pAutomation.join(' ')].join(' ').toLowerCase(); + // 3. Checa Busca de Texto (IA Filter) + const fullMeta = [pName, pBpm.toString(), pInsts.join(' '), pPlugins.join(' '), pSamples.join(' '), pBassline.join(' '), pAutomation.join(' ')].join(' ').toLowerCase(); const matchText = searchText === "" || fullMeta.includes(searchText); if (matchBpm && matchInst && matchPlugin && matchSample && matchBassline && matchAutomation && matchText) { @@ -443,6 +491,8 @@ document.addEventListener('DOMContentLoaded', function () { // Eventos checkboxes.forEach(cb => cb.addEventListener('change', updateState)); searchInput.addEventListener('input', updateState); + bpmMinInput.addEventListener('input', updateState); + bpmMaxInput.addEventListener('input', updateState); // Suporte para parĂąmetros de URL (q=...) const urlParams = new URLSearchParams(window.location.search); @@ -458,10 +508,13 @@ document.addEventListener('DOMContentLoaded', function () { if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.remove('is-checked'); }); searchInput.value = ""; + // Reseta BPM para os valores iniciais da pĂĄgina + bpmMinInput.value = initialMinBpm; + bpmMaxInput.value = initialMaxBpm; updateState(); }); - // --- Modal Logic --- + // --- Modal Logic (Preview) --- const modal = document.getElementById('preview-modal'); const iframe = document.getElementById('preview-iframe'); const modalTitle = document.getElementById('modal-title');