From: Amélia P. H. Coutard <amy@ameliathe1st.gay>
Date: Sun, 16 Jun 2024 00:41:00 +0000 (+0200)
Subject: Simplification de l'usage de lilypond, via hakyll-process
X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=6ff96ab57b10c71bd87f11184e2b7139d5145968;p=site-web.git

Simplification de l'usage de lilypond, via hakyll-process
---

diff --git a/docs/Ma'oz Tzur.ly b/docs/Ma'oz Tzur.ly
index d5ac0fb..b7f69be 100644
--- a/docs/Ma'oz Tzur.ly	
+++ b/docs/Ma'oz Tzur.ly	
@@ -1,9 +1,3 @@
----
-title: Ma'oz Tzur
-tags: musique, partition, Judaïsme
-date: 2024-06-16
-description: Une partition pour accordéon de mon arrangement de Ma'oz Tzur.
----
 \version "2.24.1"
 \header {
   title = "Ma'oz Tzur"
diff --git a/docs/Ma'oz Tzur.ly.metadata b/docs/Ma'oz Tzur.ly.metadata
new file mode 100644
index 0000000..a028037
--- /dev/null
+++ b/docs/Ma'oz Tzur.ly.metadata	
@@ -0,0 +1,4 @@
+title: Ma'oz Tzur
+tags: musique, partition, Judaïsme
+date: 2024-06-16
+description: Une partition pour accordéon de mon arrangement de Ma'oz Tzur.
diff --git a/lilypond-unix.sh b/lilypond-unix.sh
deleted file mode 100755
index 2a2c609..0000000
--- a/lilypond-unix.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-F=$(mktemp 'tmp.XXXXXXXXXX')
-lilypond -o "$F" -
-cat "$F".pdf
-rm "$F" "$F".pdf
diff --git a/main.hs b/main.hs
index 9d7bc8e..db04329 100644
--- a/main.hs
+++ b/main.hs
@@ -16,6 +16,16 @@ import Data.ByteString.Lazy.UTF8 (ByteString, fromString)
 import Data.Monoid ((<>))
 import Data.Time.Format (formatTime, defaultTimeLocale)
 import Hakyll
+import Hakyll.Process
+
+mapHead :: (a -> a) -> [a] -> [a]
+mapHead _ [] = []
+mapHead f (h:t) = f h:t
+
+split :: Eq a => a -> [a] -> [[a]]
+split _ [] = [[]]
+split v (h:t) | v == h = []:split v t
+split v (h:t) = mapHead (h:) (split v t)
 
 main :: IO ()
 main = hakyll $ do
@@ -32,7 +42,7 @@ main = hakyll $ do
 
 	match "docs/*.ly" $ do
 		route $ setExtension "pdf"
-		compile $ getResourceBody >>= withItemBody (unixFilterLBS "./lilypond-unix.sh" [] . fromString)
+		compile $ execCompilerWith (execName "lilypond") [HakFilePath] (COutFile (RelativePath (newExtension "pdf" . last . split '/')))
 
 	match "html/atom.xml" $ do
 		route $ gsubRoute "html/" (const "")