Compare commits

..

3 Commits

Author SHA1 Message Date
ff8d9c80e6 Filter artist names as well
All checks were successful
Build / build (push) Successful in 2m37s
2024-12-30 13:59:42 +01:00
842b66def0 Improve filtering 2024-12-30 13:54:28 +01:00
bfc158c6cb Build complete songbook 2024-12-30 13:35:41 +01:00
4 changed files with 22 additions and 7 deletions

View File

@ -22,7 +22,7 @@ jobs:
run: git clone https://git.0x45.cz/em/mixtape.git /workspace/em/mixtape run: git clone https://git.0x45.cz/em/mixtape.git /workspace/em/mixtape
- name: Build Chordpro - name: Build Chordpro
run: make pdf html run: make pdf html songbook
- name: Build Zola - name: Build Zola
run: zola build run: zola build

View File

@ -10,7 +10,7 @@ SRC_EXTENSION := .cho
SONG_CHO := $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*$(SRC_EXTENSION))) SONG_CHO := $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*$(SRC_EXTENSION)))
SONG_PDF := $(patsubst %$(SRC_EXTENSION),%.pdf,$(SONG_CHO)) SONG_PDF := $(patsubst %$(SRC_EXTENSION),%.pdf,$(SONG_CHO))
SONG_HTML := $(patsubst %$(SRC_EXTENSION),%.html,$(SONG_CHO)) SONG_HTML := $(patsubst %$(SRC_EXTENSION),%.html,$(SONG_CHO))
SONGBOOK := songbook.pdf SONGBOOK := content/songbook.pdf
.DEFAULT_GOAL := pdf .DEFAULT_GOAL := pdf

View File

@ -20,15 +20,21 @@ function buttonToggle(clickedButton) {
} }
function filterSongs() { function filterSongs() {
const searchTerm = search.value.trim().toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, ""); const searchTerm = sanitizeString(search.value);
const songs = Array.from(songList.children); const songs = Array.from(songList.children);
songs.forEach(song => { songs.forEach(song => {
const title = song.dataset.title.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, ""); const matching = (
const matching = title.includes(searchTerm) && (!selectedCategory || song.dataset.category === selectedCategory); (song.dataset.title.includes(searchTerm) || (song.dataset.artist && song.dataset.artist.includes(searchTerm))) &&
(!selectedCategory || song.dataset.category === selectedCategory)
);
song.classList.toggle("hidden", !matching); song.classList.toggle("hidden", !matching);
}); });
} }
function sanitizeString(string) {
return string.trim().toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "")
}
// Event listeners // Event listeners
search.addEventListener("input", filterSongs); search.addEventListener("input", filterSongs);
// Filtering happens before the reset itself without this timeout // Filtering happens before the reset itself without this timeout
@ -37,7 +43,10 @@ buttons.forEach(button => button.addEventListener("click", () => buttonToggle(bu
// Normalize song titles // Normalize song titles
Array.from(songList.children).forEach(song => { Array.from(songList.children).forEach(song => {
song.dataset.title = song.dataset.title.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, ""); song.dataset.title = sanitizeString(song.dataset.title);
if (song.dataset.artist) {
song.dataset.artist = sanitizeString(song.dataset.artist);
}
}); });
// Display the filter section on JS-enabled browsers // Display the filter section on JS-enabled browsers

View File

@ -21,7 +21,13 @@
</section> </section>
<section class="song-list"> <section class="song-list">
{% for song in section.pages %} {% for song in section.pages %}
<div class="{{ macros::primary_category(song=song) }}" data-title="{{ song.title }}" data-category="{{ macros::primary_category(song=song) }}"> <div class="{{ macros::primary_category(song=song) }}"
data-title="{{ song.title }}"
data-category="{{ macros::primary_category(song=song) }}"
{% if song.taxonomies["artist"] %}
data-artist="{{ song.taxonomies["artist"][0] }}"
{% endif %}
>
<div class="meta"> <div class="meta">
<div class="title">{{ song.title }}</div> <div class="title">{{ song.title }}</div>
{% if song.taxonomies["artist"] %} {% if song.taxonomies["artist"] %}