From 07a0488dd95595c27d0d6dcb8051bba0fbe613e5 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Tue, 27 Jun 2023 13:07:43 +1200 Subject: [PATCH] Improve Rhapsode's build with newer tools, fix crashes in history infrastructure. --- about/welcome | 2 +- rhapsode.cabal | 2 +- src/CExports.hs | 6 +++--- src/SSML.hs | 2 +- src/SpeechStyle.hs | 6 +++--- src/Types.hs | 7 ++----- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/about/welcome b/about/welcome index a31efb5..14b9010 100644 --- a/about/welcome +++ b/about/welcome @@ -4,7 +4,7 @@ Welcome -

Welcome to Rhapsode!

+

Welcome to Rhapsode!

Hear the vast breadth of knowledge & entertainment diff --git a/rhapsode.cabal b/rhapsode.cabal index 2b2d63b..f7faf74 100644 --- a/rhapsode.cabal +++ b/rhapsode.cabal @@ -67,7 +67,7 @@ library -- Networking network-uri, async, hurl >= 2, filepath, temporary, -- CSS - stylist >= 2.4 && <3, stylist-traits >= 0.1.1, css-syntax, scientific, + stylist >= 2.7.0.1 && <3, stylist-traits >= 0.1.3.1, css-syntax, scientific, xml-conduit-stylist >= 3 && <3.1, -- Voice2Json input process, aeson >= 1.5 && <1.6, unordered-containers diff --git a/src/CExports.hs b/src/CExports.hs index 0f1c8af..7c84be3 100644 --- a/src/CExports.hs +++ b/src/CExports.hs @@ -16,7 +16,7 @@ import qualified Data.ByteString.Lazy as B import Network.URI import Network.URI.Fetch -import Network.URI.Fetch.XML (fetchDocument, loadVisited) +import Network.URI.Fetch.XML (fetchDocument, loadVisited, readStrict) import System.IO import System.Directory @@ -147,7 +147,7 @@ c_lastVisited def = do path <- ( "history.gmni") <$> getXdgDirectory XdgData "rhapsode" exists <- doesFileExist path if not exists then return def else do - file <- readFile path - case map words $ lines file of + file <- readStrict path + case map words $ reverse $ lines file of (_:url:_):_ -> newCString url _ -> return def diff --git a/src/SSML.hs b/src/SSML.hs index 9472dfc..abebf8e 100644 --- a/src/SSML.hs +++ b/src/SSML.hs @@ -23,7 +23,7 @@ styleToNodes = Prelude.map style . postorder styleToSSML' styleToSSML' SpeechStyle { speak = False } _ = [] styleToSSML' self@SpeechStyle {content = ""} children = el "prosody" [ ("xml:lang", lang self), - ("rhapsode:pseudo", pseudoEl self), + ("rhapsode:pseudo", pseudoEl' self), ("volume", volume self), ("rate", rate self), ("pitch", pitch2txt <$> pitch self), diff --git a/src/SpeechStyle.hs b/src/SpeechStyle.hs index c608d52..86f1ccd 100644 --- a/src/SpeechStyle.hs +++ b/src/SpeechStyle.hs @@ -38,7 +38,7 @@ data SpeechStyle = SpeechStyle { content :: Text, lang :: Maybe Text, - pseudoEl :: Maybe Text + pseudoEl' :: Maybe Text } volumes = Txt.words "silent x-soft soft medium loud x-loud" @@ -70,7 +70,7 @@ instance PropertyParser SpeechStyle where content = "", lang = Nothing, - pseudoEl = Nothing + pseudoEl' = Nothing } inherit _ = temp -- Text synthesizers handle inheritance. @@ -116,7 +116,7 @@ instance PropertyParser SpeechStyle where longhand _ self "content" [Ident "initial"] = Just self {content = ""} longhand _ self "content" toks = (\v -> self {content = v}) <$> parseStrings toks - longhand _ self "::" [Ident pseudo] = Just self {pseudoEl = Just pseudo} -- To make sure content doesn't override :before & :after + longhand _ self "::" [Ident pseudo] = Just self {pseudoEl' = Just pseudo} -- To make sure content doesn't override :before & :after longhand _ self "-rhaps-lang" [String v] = Just self {lang = Just v} longhand _ _ _ _ = Nothing diff --git a/src/Types.hs b/src/Types.hs index e8b197b..49cc9c3 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -1,17 +1,14 @@ -module Types(CArray, Page(..), Application(..), RhapsodeCSS, buildDirFile, readStrict) where +module Types(CArray, Page(..), Application(..), RhapsodeCSS, readStrict) where import SpeechStyle (SpeechStyle) import Data.CSS.Preprocessor.Conditions (ConditionalStyles, conditionalStyles) import Data.CSS.Preprocessor.Text (TextStyle) import Network.URI.Fetch (Application(..), url) -import Network.URI.Fetch.XML (Page(..), loadVisited, readStrict) +import Network.URI.Fetch.XML (Page(..), readStrict) import System.FilePath (()) import Foreign.Ptr -buildDir = "." -buildDirFile = (buildDir ) - type CArray a = Ptr a type RhapsodeCSS = ConditionalStyles (TextStyle SpeechStyle) -- 2.30.2