From 9d25bbc56ff1d3fe92c6ce596bff0cfc3adbf60e Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 3 Jan 2024 16:15:04 +0100 Subject: Generate index automatically --- src/main.lisp | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'src/main.lisp') 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*))))))) -- cgit v1.2.3