Upgrade interface do MMPSearch
This commit is contained in:
1 parent
7d9d2b0f63
commit
fd52173666
21 files changed
+2438
-1547
No files matched your search
+274
-105
@@ -1,137 +1,306 @@
|
||||
---
|
||||
layout: default
|
||||
title: Projetos com Instrumentos
|
||||
title: Projetos por Instrumento
|
||||
permalink: /instruments/
|
||||
---
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<main class="main-content">
|
||||
<main class="main-content">
|
||||
<div class="publication">
|
||||
{% include sidebar.html %}
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="columns is-mobile is-vcentered" style="margin-bottom: 2rem;">
|
||||
<!-- Título -->
|
||||
<div class="column is-auto">
|
||||
<h2 class="title is-4"><code>Projetos e seus instrumentos:</code></h2>
|
||||
<div class="container">
|
||||
<br />
|
||||
|
||||
<div class="tabs is-centered is-boxed is-medium mb-6">
|
||||
{% include sidebar.html %}
|
||||
</div>
|
||||
<!-- Botão Limpar Filtro -->
|
||||
<div class="column is-auto">
|
||||
<button id="clearFilterButton" class="button is-small is-light">
|
||||
Limpar filtro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Projetos -->
|
||||
<div id="project-list" class="columns is-multiline">
|
||||
{% for projeto in site.data.all %}
|
||||
<div class="column is-6 project-item" data-project-id="{{ projeto.file }}">
|
||||
<div class="box">
|
||||
<!-- Botão do projeto -->
|
||||
{% 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' %}
|
||||
<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;">
|
||||
|
||||
<a href="../mmp_pages/{{ file_url }}.html" class="button is-link is-fullwidth">
|
||||
{{ projeto.file }}
|
||||
</a>
|
||||
<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 Instrumentos 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>
|
||||
|
||||
<!-- Lista de Instrumentos clicáveis -->
|
||||
<div class="instruments">
|
||||
{% assign instruments_exibidos = "" %}
|
||||
{% for track in projeto.tracks %}
|
||||
{% if track.instruments %}
|
||||
{% for instrument in track.instruments %}
|
||||
{% unless instruments_exibidos contains instrument.instrument_name %}
|
||||
{% capture instruments_exibidos %}{{ instruments_exibidos }},{{ instrument.instrument_name }}{% endcapture %}
|
||||
<div class="p-4" style="background-color: #fff; border-top: 1px solid #cfe8fc;">
|
||||
<div class="tags is-centered are-medium mb-0">
|
||||
{% assign all_instruments_string = "" %}
|
||||
|
||||
<!-- Gerar link para o instrumento -->
|
||||
{% assign instrument_slug = instrument.instrument_name %}
|
||||
<a href="{{ '/instruments/?instrument=' | append: instrument_slug | encodeURIComponent | relative_url }}" class="button is-link instrument-button" style="margin: 0.5rem;">
|
||||
{{ instrument.instrument_name }}
|
||||
</a>
|
||||
|
||||
{% endunless %}
|
||||
{% for p in site.data.all %}
|
||||
{% for track in p.tracks %}
|
||||
{% if track.instruments %}
|
||||
{% for inst in track.instruments %}
|
||||
{% if inst.instrument_name and inst.instrument_name != "" %}
|
||||
{% unless all_instruments_string contains inst.instrument_name %}
|
||||
{% assign all_instruments_string = all_instruments_string | append: inst.instrument_name | append: "|||" %}
|
||||
{% endunless %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% elsif track.instrument_name and track.instrument_name != "" %}
|
||||
{% unless all_instruments_string contains track.instrument_name %}
|
||||
{% assign all_instruments_string = all_instruments_string | append: track.instrument_name | append: "|||" %}
|
||||
{% endunless %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% assign unique_instruments = all_instruments_string | split: "|||" | sort %}
|
||||
|
||||
{% for item in unique_instruments %}
|
||||
{% 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>
|
||||
{% endfor %}
|
||||
<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.instruments %}
|
||||
{% for inst in track.instruments %}
|
||||
{% assign project_insts = project_insts | append: inst.instrument_name | append: "," %}
|
||||
{% endfor %}
|
||||
{% elsif track.instrument_name %}
|
||||
{% assign project_insts = project_insts | append: track.instrument_name | append: "," %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<div class="column is-12-mobile is-6-tablet is-4-desktop is-3-widescreen project-item"
|
||||
data-instruments="{{ 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 instrumentButtons = document.querySelectorAll('.instrument-button');
|
||||
const projectItems = document.querySelectorAll('.project-item');
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let instrumentFilter = urlParams.get('instrument'); // Pega o parâmetro 'instrument' da URL, se houver
|
||||
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 = [];
|
||||
|
||||
// Decodificando o valor do instrumento para garantir que espaços e caracteres especiais sejam tratados
|
||||
if (instrumentFilter) {
|
||||
instrumentFilter = decodeURIComponent(instrumentFilter);
|
||||
}
|
||||
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');
|
||||
}
|
||||
|
||||
// Função para aplicar o filtro de instrumento
|
||||
function filterProjects() {
|
||||
projectItems.forEach(project => {
|
||||
const projectId = project.getAttribute('data-project-id');
|
||||
let projectContainsInstrument = false;
|
||||
// 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');
|
||||
}
|
||||
});
|
||||
|
||||
// Verificar se algum instrumento do projeto corresponde ao filtro
|
||||
project.querySelectorAll('.instrument-button').forEach(button => {
|
||||
const instrumentSlug = button.getAttribute('href').split('=')[1]; // Pega o instrumento do link
|
||||
projects.forEach(project => {
|
||||
const projectInstStr = project.getAttribute('data-instruments');
|
||||
// Cria array de instrumentos deste projeto
|
||||
const projectInsts = projectInstStr.split(',').map(s => s.trim());
|
||||
|
||||
// Decodificando o slug do instrumento para comparar corretamente
|
||||
const decodedSlug = decodeURIComponent(instrumentSlug);
|
||||
|
||||
// Se o projeto contém o instrumento desejado, exibe o projeto
|
||||
if (decodedSlug === instrumentFilter) {
|
||||
projectContainsInstrument = true;
|
||||
if (activeFilters.length === 0) {
|
||||
project.style.display = 'block';
|
||||
} else {
|
||||
// Lógica OR: Se tiver pelo menos um dos instrumentos filtrados, exibe
|
||||
const hasMatch = activeFilters.some(filter => projectInsts.includes(filter));
|
||||
project.style.display = hasMatch ? 'block' : 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Ocultar ou exibir o projeto com base no filtro
|
||||
if (instrumentFilter && !projectContainsInstrument) {
|
||||
project.style.display = 'none'; // Oculta o projeto
|
||||
} else {
|
||||
project.style.display = 'block'; // Exibe o projeto
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
filterProjects(); // Aplica o filtro de instrumentos assim que a página é carregada
|
||||
|
||||
// Botão para limpar filtro
|
||||
const clearFilterButton = document.querySelector('#clearFilterButton');
|
||||
if (clearFilterButton) {
|
||||
clearFilterButton.addEventListener('click', function () {
|
||||
// Limpa o filtro e mostra todos os projetos
|
||||
projectItems.forEach(project => {
|
||||
project.style.display = 'block'; // Exibe todos os projetos
|
||||
});
|
||||
|
||||
// Remove o parâmetro 'instrument' da URL
|
||||
const newUrl = new URL(window.location.href);
|
||||
newUrl.searchParams.delete('instrument');
|
||||
if (activeFilters.length > 0) {
|
||||
newUrl.searchParams.set('instrument', activeFilters.join(','));
|
||||
} else {
|
||||
newUrl.searchParams.delete('instrument');
|
||||
}
|
||||
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('instrument');
|
||||
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>
|
||||
Reference in new issue
Block a user