about summary refs log tree commit diff
path: root/piosenki/index.typ
diff options
context:
space:
mode:
Diffstat (limited to 'piosenki/index.typ')
-rw-r--r--piosenki/index.typ101
1 files changed, 98 insertions, 3 deletions
diff --git a/piosenki/index.typ b/piosenki/index.typ
index 428b803..eefff4a 100644
--- a/piosenki/index.typ
+++ b/piosenki/index.typ
@@ -1,4 +1,4 @@
-#let lista_piosenek = (
+/*#let lista_piosenek = (
   "1-juz-rozpalilo-sie-ognisko.txt",
   "2-plonie-ognisko-i-szumia-knieje.txt",
   "3-wspominajka.txt",
@@ -58,7 +58,7 @@
   b
 }
 
-#for piosenka in lista_piosenek {
+#for (nr_piosenki, piosenka) in lista_piosenek.enumerate() {
   let tekst = read(piosenka).split("\n\n").map(it =>
     it.trim(regex("[\n]"))).filter(it =>
     it != "")
@@ -77,6 +77,30 @@
     header, 
     []//block(breakable: false)[#tekst.remove(0)]
   )
+
+//
+  let chords_list = ()
+  let chords_map = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
+
+  for (nr_wersu, wers) in tekst.enumerate() {
+    let wers_chords = ""
+    for par in wers.split("\n") {
+        let podzielony = par.split("| ")
+        let chords = if podzielony.len() > 1 {
+          podzielony.at(1)
+        } else { "" }
+        wers_chords += chords
+    }
+    if wers_chords == "" { continue }
+    if wers_chords in chords_list {
+
+    } else {
+      chords_list.push(wers_chords)
+      chords_map.insert(nr_wersu, chords_list.len()-1)
+    }
+  }
+//
+
   for wers in tekst {
     block()[
       #for par in wers.split("\n") {
@@ -96,4 +120,75 @@
   }
   parbreak()
   v(0.5em)
-}
\ No newline at end of file
+}
+*/
+
+#let piosenki = (
+  json("a-my-nie-chcemy-uciekac-stad.json"),
+  json("czuwajcie.json"),
+  json("zwiewnosc.json"),
+  json("zrodlo.json"),
+)
+
+#let show_chords(chords_label, chords) = context { 
+  let show_chords = true
+  let here_i_am = here()
+  let found_chords = query(selector(chords_label).before(here_i_am))
+  if found_chords.len() > 0 {
+    let refren_page = found_chords.last().location().page()
+    let on_the_same_page = refren_page == here_i_am.page()
+    let on_adjacent_page = (refren_page+1 == here_i_am.page() and calc.even(refren_page) )
+    show_chords = not (on_the_same_page or on_adjacent_page)
+
+  }
+  if show_chords {
+    return block[
+      #chords
+      #chords_label
+    ]
+  }
+}
+
+#let show_verse(verse_label, verse, chords) = {
+  grid(
+    columns: 2,
+    gutter: 10pt,
+    block[#verse],
+    show_chords(verse_label, chords)
+  )
+}
+
+#for (nr_piosenki, piosenka) in piosenki.enumerate() [
+
+#context [
+  #if here().position().y > 300pt {
+    pagebreak(weak: true)
+  }
+  = #piosenka.title
+]
+
+#if piosenka.text_authors.len() > 0 [
+  #text(size: 0.8em)[sł.: #piosenka.text_authors.first()]
+] else [
+  #text(size: 0.8em)[autor nieznany]
+]
+
+#let chords_list = ()
+
+#for (key, part) in piosenka.parts.enumerate() {
+  if "refren" in part {
+    part = piosenka.refren
+  }
+
+  let verse_text = part.text
+  let verse_chords = part.chords
+  
+  if verse_chords not in chords_list {
+    chords_list.push(verse_chords)
+  }
+  let idx = chords_list.find(ch => ch == verse_chords)
+  let lbl = label(str(nr_piosenki)+"-"+str(idx))
+
+  show_verse(lbl, verse_text, verse_chords)
+}
+]
\ No newline at end of file