aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xbin/build3
-rw-r--r--public/index.html17
-rw-r--r--public/main.js51
-rw-r--r--src/main.lisp48
5 files changed, 63 insertions, 57 deletions
diff --git a/.gitignore b/.gitignore
index 7e54d92..94ddc02 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
+public/index.html
public/songs
diff --git a/bin/build b/bin/build
index 3230144..fad51e3 100755
--- a/bin/build
+++ b/bin/build
@@ -3,5 +3,6 @@ set -euo pipefail
cd "$(dirname "$0")/.."
echo "Building…"
-sbcl --script src/main.lisp
+SONGS=$(find songs -name '*.lisp' | sort)
+sbcl --script src/main.lisp $SONGS
echo "Done."
diff --git a/public/index.html b/public/index.html
deleted file mode 100644
index df494a8..0000000
--- a/public/index.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!doctype html>
-<html lang="fr">
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width">
-<title>Music</title>
-<link rel="stylesheet" href="/main.css">
-<link rel="icon" href="/icon.png">
-
-<h1 class="g-Title">Music</h1>
-
-<ul class="g-Songs">
- <li>
- <a href="songs/ben-e-king/stand-by-me.html">Ben E. King – Stand by Me</a>
- <li>
- <a href="songs/graeme-allwright/petit-garcon.html">Graeme Allwright – Petit Garçon</a>
- <li>
- <a href="songs/tri-yann/pelot-d-hennebont.html">Tri Yann – Pelot d’Hennebont</a>
diff --git a/public/main.js b/public/main.js
index 97f11f4..3b9e6fc 100644
--- a/public/main.js
+++ b/public/main.js
@@ -12,6 +12,8 @@ function appendText(parentElement, text) {
return element
}
+// Select tonality
+
tonalities_b = ['C', 'D♭', 'D', 'E♭', 'E', 'F', 'G♭', 'G', 'A♭', 'A', 'B♭', 'B']
tonalities_s = ['C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'A♯', 'B']
@@ -35,33 +37,30 @@ function applyShift(tonalities, t1, s) {
return `${root}${mode}`
}
+const node = document.getElementById('g-Tonality')
+if (node !== null) {
+ let tonality = node.innerText
+ mode = tonality[tonality.length - 1] == 'm' ? 'm' : ''
-const node = document.querySelector('[data-tonality]')
-let tonality = node.dataset.tonality
-mode = tonality[tonality.length - 1] == 'm' ? 'm' : ''
-
-label = appendElement(node, 'label')
-label['className'] = 'g-Chords__Tonality'
-label.onchange = (e) => {
- const shift = getShift(tonality, e.target.value)
- tonality = e.target.value
- tonalities = tonality === 'F' || tonality.indexOf('♭') > -1 ? tonalities_b : tonalities_s
- document.querySelectorAll('.g-Chords__Chord').forEach(chord => {
- if (chord.innerText !== '%') {
- chord.innerText = applyShift(tonalities, chord.innerText, shift)
+ select = document.createElement('select')
+ select['name'] = 'tonality'
+ tonalities_b.forEach(t => {
+ option = appendElement(select, 'option')
+ option['value'] = t
+ if (tonality == `${t}${mode}`) {
+ option['selected'] = true
}
+ appendText(option, `${t}${mode}`)
})
-}
-
-appendText(label, 'Tonalité :')
-
-select = appendElement(label, 'select')
-select['name'] = 'tonality'
-tonalities_b.forEach(t => {
- option = appendElement(select, 'option')
- option['value'] = t
- if (tonality == `${t}${mode}`) {
- option['selected'] = true
+ select.onchange = (e) => {
+ const shift = getShift(tonality, e.target.value)
+ tonality = e.target.value
+ tonalities = tonality === 'F' || tonality.indexOf('♭') > -1 ? tonalities_b : tonalities_s
+ document.querySelectorAll('.g-Chords__Chord').forEach(chord => {
+ if (chord.innerText !== '%') {
+ chord.innerText = applyShift(tonalities, chord.innerText, shift)
+ }
+ })
}
- appendText(option, `${t}${mode}`)
-})
+ node.parentNode.replaceChild(select, node)
+}
diff --git a/src/main.lisp b/src/main.lisp
index f03bd1a..f3bd32e 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -61,6 +61,7 @@
('verse "Couplet")
('chorus "Refrain")
('interlude "Interlude")
+ ('bridge "Pont")
('outro "Outro")))
(defun part-tags (key children)
@@ -113,7 +114,10 @@
(h "h2" '(("class" "g-Subtitle")) '("Accords"))
(h "div" '(("class" "g-Parts"))
(cons
- (h "div" (list (list "data-tonality" tonality)) nil)
+ (h "label" '(("class" "g-Chords__Tonality"))
+ (list
+ "Tonalité :"
+ (h "span" '(("id" "g-Tonality")) (list (string tonality)))))
(chord-tables chords))))))
; Lyrics
@@ -140,16 +144,16 @@
(h "h2" '(("class" "g-Subtitle")) '("Paroles"))
(h "div" '(("class" "g-Parts")) (mapcar #'lyrics-section lyrics)))))
-; Main
+; Export songs
(defun export-song (path)
- (let ((data (with-open-file (in path) (read in))))
- (let ((output (concatenate 'string "public/" (car (split path #\.)) ".html"))
- (title (car (song-key 'title (cdr data))))
- (from (car (song-key 'from (cdr data))))
- (tonality (car (song-key 'tonality (cdr data))))
- (chords (song-key 'chords (cdr data)))
- (lyrics (song-key 'lyrics (cdr data))))
+ (let* ((data (with-open-file (in path) (read in)))
+ (output (concatenate 'string "public/" (car (split path #\.)) ".html"))
+ (title (car (song-key 'title (cdr data))))
+ (from (car (song-key 'from (cdr data))))
+ (tonality (car (song-key 'tonality (cdr data))))
+ (chords (song-key 'chords (cdr data)))
+ (lyrics (song-key 'lyrics (cdr data))))
(write-file output (page
(format nil "~A – ~A" title from)
(h
@@ -159,8 +163,26 @@
(h "a" '(("class" "g-Back") ("href" "/")) '("Retour à l’accueil"))
(title-tags title from)
(chord-tags chords tonality)
- (lyrics-tags lyrics))))))))
+ (lyrics-tags lyrics)))))))
-(export-song "songs/graeme-allwright/petit-garcon.lisp")
-(export-song "songs/ben-e-king/stand-by-me.lisp")
-(export-song "songs/tri-yann/pelot-d-hennebont.lisp")
+(dolist (path (cdr *posix-argv*))
+ (export-song path))
+
+; Export index
+
+(write-file "public/index.html" (page
+ "Music"
+ (h
+ "body"
+ nil
+ (list
+ (h "h1" '(("class" "g-Title")) '("Music"))
+ (h "ul" '(("class" "g-Songs"))
+ (mapcar
+ (lambda (path)
+ (let* ((data (with-open-file (in path) (read in)))
+ (href (concatenate 'string (car (split path #\.)) ".html"))
+ (title (car (song-key 'title (cdr data))))
+ (from (car (song-key 'from (cdr data)))))
+ (h "li" nil (list (h "a" (list (list "href" href)) (list (format nil "~A – ~A" from title)))))))
+ (cdr *posix-argv*)))))))