From 2dc5e4d3e62531c5915ee0bc8dca6068be8faff0 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Tue, 20 Jun 2023 13:50:51 +1200 Subject: [PATCH] Fix embedding of data files to be more lenient towards build systems. --- rhapsode.cabal | 2 +- src/CExports.hs | 4 +++- src/Render.hs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rhapsode.cabal b/rhapsode.cabal index 16df9eb..2b2d63b 100644 --- a/rhapsode.cabal +++ b/rhapsode.cabal @@ -61,7 +61,7 @@ library -- Other library packages from which modules are imported. build-depends: base >=4.9 && <5, directory >= 1.3.2, bytestring, - file-embed >= 0.0.9 && < 0.1, time, parallel >= 1, + file-embed >= 0.0.10 && < 0.1, time, parallel >= 1, -- HTML parsing, SSML output xml-conduit, text, containers, hurl-xml >= 0.2, -- Networking diff --git a/src/CExports.hs b/src/CExports.hs index f8eef9b..0f1c8af 100644 --- a/src/CExports.hs +++ b/src/CExports.hs @@ -111,7 +111,9 @@ foreign export ccall c_freeSession :: StablePtr Session -> IO () c_newSession = do sess <- newSession - newStablePtr $ sess {aboutPages = map lazify $(embedDir $ buildDirFile "about")} + newStablePtr $ sess { + aboutPages = map lazify $(makeRelativeToProject "about" >>= embedDir) + } where lazify (a, b) = (a, B.fromStrict b) c_freeSession = freeStablePtr diff --git a/src/Render.hs b/src/Render.hs index 5e5a245..5d2781b 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -74,7 +74,8 @@ renderElLBS el = XML.renderLBS XML.def $ XML.Document { retreiveStyles :: Session -> CSSCond.ConditionalStyles (CSSTxt.TextStyle SpeechStyle) -> IO (CSSCond.ConditionalStyles (CSSTxt.TextStyle SpeechStyle)) retreiveStyles manager authorStyle = do - let agentStyle = cssPriorityAgent authorStyle `CSS.parse` $(embedStringFile $ buildDirFile "useragent.css") + let agentStyle = cssPriorityAgent authorStyle `CSS.parse` + $(makeRelativeToProject "useragent.css" >>= embedStringFile) userStyle <- loadUserStyles agentStyle CSSCond.loadImports loadURL lowerVars lowerToks userStyle [] where -- 2.30.2