reformula buscas
Deploy / Deploy (push) Successful in 1m27s Details

This commit is contained in:
JotaChina 2025-12-16 17:51:01 -03:00
parent a6c0802069
commit 007a40cdb2
1 changed files with 88 additions and 35 deletions

View File

@ -12,26 +12,45 @@ permalink: /projetos/
{% assign list_automation = "" %} {% assign list_automation = "" %}
{% for p in site.data.all %} {% 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 %} {% 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.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 %} {% 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 %} {% for track in p.tracks %}
{% if track.instruments %}{% for inst in track.instruments %}{% assign list_instruments = list_instruments | append: inst.instrument_name | append: "|||" %}{% endfor %} {% if track.instruments %}
{% elsif track.instrument_name %}{% assign list_instruments = list_instruments | append: track.instrument_name | append: "|||" %}{% endif %} {% 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 %} {% 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 %} {% elsif track.sample_name %}{% assign list_samples = list_samples | append: track.sample_name | append: "|||" %}{% endif %}
{% endfor %} {% endfor %}
{% 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_plugins = list_plugins | split: "|||" | uniq | sort %}
{% assign unique_instruments = list_instruments | split: "|||" | uniq | sort %} {% assign unique_instruments = list_instruments | split: "|||" | uniq | sort %}
{% assign unique_samples = list_samples | split: "|||" | uniq | sort %} {% assign unique_samples = list_samples | split: "|||" | uniq | sort %}
{% assign unique_bassline = list_bassline | split: "|||" | uniq | sort %} {% assign unique_bassline = list_bassline | split: "|||" | uniq | sort %}
{% assign unique_automation = list_automation | 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 %}
<div class="publication"> <div class="publication">
<div class="container is-fluid"> <div class="container is-fluid">
<br /> <br />
@ -44,7 +63,7 @@ permalink: /projetos/
<div class="column"> <div class="column">
<h1 class="title is-3 has-text-grey-dark">📁 Projetos Disponíveis</h1> <h1 class="title is-3 has-text-grey-dark">📁 Projetos Disponíveis</h1>
<p class="subtitle is-6 has-text-grey"> <p class="subtitle is-6 has-text-grey">
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.
</p> </p>
</div> </div>
<div class="column is-narrow"> <div class="column is-narrow">
@ -72,20 +91,19 @@ permalink: /projetos/
<hr class="my-3"> <hr class="my-3">
<div class="filter-group mb-4"> <div class="filter-group mb-4">
<p class="menu-label has-text-weight-bold mb-2">BPM</p> <p class="menu-label has-text-weight-bold mb-2">Faixa de BPM</p>
<div class="field is-grouped is-grouped-multiline"> <div class="columns is-mobile is-variable is-1">
{% for item in unique_bpm %} <div class="column">
{% if item != "" %} <label class="is-size-7 has-text-grey">Mín</label>
<div class="control"> <input class="input is-small" type="number" id="bpm-min" value="{{ min_bpm_val }}" min="0" max="999">
<label class="checkbox tag is-white" style="border: 1px solid #dbdbdb; cursor: pointer;">
<input type="checkbox" class="filter-checkbox" data-category="bpm" value="{{ item }}">
{{ item }}
</label>
</div> </div>
{% endif %} <div class="column">
{% endfor %} <label class="is-size-7 has-text-grey">Máx</label>
<input class="input is-small" type="number" id="bpm-max" value="{{ max_bpm_val }}" min="0" max="999">
</div> </div>
</div> </div>
<p class="help has-text-centered is-size-7" style="margin-top: -5px;">Projetos entre esses valores.</p>
</div>
<hr class="my-3"> <hr class="my-3">
<details open> <details open>
@ -161,12 +179,26 @@ permalink: /projetos/
{% for page in project_pages %} {% for page in project_pages %}
{% if page.url != '/projetos/' %} {% 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_plugins = page.tags.plugin | join: ',' %}
{% assign p_bassline = page.tags.bassline | join: ',' %} {% assign p_bassline = page.tags.bassline | join: ',' %}
{% assign p_automation = page.tags.automation | join: ',' %} {% assign p_automation = page.tags.automation | join: ',' %}
{% assign p_samples = page.tags.sample | 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 %} {% assign p_name = page.title | default: page.name | downcase %}
@ -176,7 +208,7 @@ permalink: /projetos/
data-plugins="{{ p_plugins }}" data-plugins="{{ p_plugins }}"
data-bassline="{{ p_bassline }}" data-bassline="{{ p_bassline }}"
data-automation="{{ p_automation }}" data-automation="{{ p_automation }}"
data-instruments="{{ p_instruments }}" data-instruments="{{ p_instruments_str }}"
data-samples="{{ p_samples }}"> data-samples="{{ p_samples }}">
<div class="card project-card" <div class="card project-card"
@ -209,17 +241,19 @@ permalink: /projetos/
<div class="mt-auto pt-2" style="width: 100%; border-top: 1px dashed #eef6fc;"> <div class="mt-auto pt-2" style="width: 100%; border-top: 1px dashed #eef6fc;">
{% assign inst_tags = page.tags.instruments | default: page.tags.instrument %} {% assign unique_insts_page = p_insts_array | uniq | sort %}
{% if inst_tags and inst_tags.size > 0 %} {% if unique_insts_page.size > 0 %}
<details class="category-reveal mb-1" style="width: 100%;"> <details class="category-reveal mb-1" style="width: 100%;">
<summary class="tag is-white summary-btn"> <summary class="tag is-white summary-btn">
<div class="tag-label"><span>🎸</span> <span class="tag-text">INSTRUMENTS</span></div> <div class="tag-label"><span>🎸</span> <span class="tag-text">INSTRUMENTS</span></div>
<span class="icon is-small chevron"><i class="fa-solid fa-chevron-down"></i></span> <span class="icon is-small chevron"><i class="fa-solid fa-chevron-down"></i></span>
</summary> </summary>
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;"> <div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
{% for tag in inst_tags %}{% if tag != "" %} {% for tag in unique_insts_page %}
{% if tag != "" %}
<a href="{{ '/instruments/?instrument=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag">{{ tag | truncate: 18 }}</a> <a href="{{ '/instruments/?instrument=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag">{{ tag | truncate: 18 }}</a>
{% endif %}{% endfor %} {% endif %}
{% endfor %}
</div> </div>
</details> </details>
{% endif %} {% endif %}
@ -370,6 +404,10 @@ permalink: /projetos/
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const checkboxes = document.querySelectorAll('.filter-checkbox'); const checkboxes = document.querySelectorAll('.filter-checkbox');
const searchInput = document.getElementById('search-input'); 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 projects = document.querySelectorAll('.project-item');
const resetBtn = document.getElementById('reset-all-filters'); const resetBtn = document.getElementById('reset-all-filters');
const countBar = document.getElementById('results-count-bar'); const countBar = document.getElementById('results-count-bar');
@ -377,17 +415,22 @@ document.addEventListener('DOMContentLoaded', function () {
const noResults = document.getElementById('no-results'); const noResults = document.getElementById('no-results');
// Estado do Filtro // Estado do Filtro
let activeFilters = { bpm: [], instruments: [], plugins: [], samples: [], bassline: [], automation: [] }; let activeFilters = { instruments: [], plugins: [], samples: [], bassline: [], automation: [] };
let searchText = ""; let searchText = "";
// Valores Iniciais de BPM
let initialMinBpm = parseInt(bpmMinInput.value) || 0;
let initialMaxBpm = parseInt(bpmMaxInput.value) || 999;
function updateState() { function updateState() {
// Reseta Arrays // Reseta Arrays (menos BPM que é tratado separado)
activeFilters = { bpm: [], instruments: [], plugins: [], samples: [], bassline: [], automation: [] }; activeFilters = { instruments: [], plugins: [], samples: [], bassline: [], automation: [] };
// Lê Checkboxes // Lê Checkboxes
checkboxes.forEach(cb => { checkboxes.forEach(cb => {
if (cb.checked) { if (cb.checked) {
const category = cb.getAttribute('data-category'); 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 (activeFilters[category]) activeFilters[category].push(cb.value);
if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.add('is-checked'); if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.add('is-checked');
} else { } else {
@ -404,27 +447,32 @@ document.addEventListener('DOMContentLoaded', function () {
function applyFilters() { function applyFilters() {
let visibleCount = 0; 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 => { projects.forEach(project => {
// Lê dados do elemento // Lê dados do elemento
const pName = project.getAttribute('data-name') || ""; 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 pInsts = (project.getAttribute('data-instruments') || "").split(',');
const pPlugins = (project.getAttribute('data-plugins') || "").split(','); const pPlugins = (project.getAttribute('data-plugins') || "").split(',');
const pSamples = (project.getAttribute('data-samples') || "").split(','); const pSamples = (project.getAttribute('data-samples') || "").split(',');
const pBassline = (project.getAttribute('data-bassline') || "").split(','); const pBassline = (project.getAttribute('data-bassline') || "").split(',');
const pAutomation = (project.getAttribute('data-automation') || "").split(','); const pAutomation = (project.getAttribute('data-automation') || "").split(',');
// 1. Checa Filtros de Categoria (Checkbox) // 1. Checa SLICER DE BPM (Lógica de Intervalo)
const matchBpm = activeFilters.bpm.length === 0 || activeFilters.bpm.includes(pBpm); 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 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 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 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 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)); const matchAutomation = activeFilters.automation.length === 0 || activeFilters.automation.some(f => pAutomation.includes(f));
// 2. Checa Busca de Texto (IA Filter) // 3. Checa Busca de Texto (IA Filter)
// Concatena tudo para buscar em qualquer campo const fullMeta = [pName, pBpm.toString(), pInsts.join(' '), pPlugins.join(' '), pSamples.join(' '), pBassline.join(' '), pAutomation.join(' ')].join(' ').toLowerCase();
const fullMeta = [pName, pBpm, pInsts.join(' '), pPlugins.join(' '), pSamples.join(' '), pBassline.join(' '), pAutomation.join(' ')].join(' ').toLowerCase();
const matchText = searchText === "" || fullMeta.includes(searchText); const matchText = searchText === "" || fullMeta.includes(searchText);
if (matchBpm && matchInst && matchPlugin && matchSample && matchBassline && matchAutomation && matchText) { if (matchBpm && matchInst && matchPlugin && matchSample && matchBassline && matchAutomation && matchText) {
@ -443,6 +491,8 @@ document.addEventListener('DOMContentLoaded', function () {
// Eventos // Eventos
checkboxes.forEach(cb => cb.addEventListener('change', updateState)); checkboxes.forEach(cb => cb.addEventListener('change', updateState));
searchInput.addEventListener('input', updateState); searchInput.addEventListener('input', updateState);
bpmMinInput.addEventListener('input', updateState);
bpmMaxInput.addEventListener('input', updateState);
// Suporte para parâmetros de URL (q=...) // Suporte para parâmetros de URL (q=...)
const urlParams = new URLSearchParams(window.location.search); 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'); if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.remove('is-checked');
}); });
searchInput.value = ""; searchInput.value = "";
// Reseta BPM para os valores iniciais da página
bpmMinInput.value = initialMinBpm;
bpmMaxInput.value = initialMaxBpm;
updateState(); updateState();
}); });
// --- Modal Logic --- // --- Modal Logic (Preview) ---
const modal = document.getElementById('preview-modal'); const modal = document.getElementById('preview-modal');
const iframe = document.getElementById('preview-iframe'); const iframe = document.getElementById('preview-iframe');
const modalTitle = document.getElementById('modal-title'); const modalTitle = document.getElementById('modal-title');