~alcinnz/rhapsode

2e70c6feff0d188625841912a068e64ae8ca1dc0 — Adrian Cochrane 1 year, 7 months ago df26d59
Extract logic into dependency!
2 files changed, 3 insertions(+), 13 deletions(-)

M rhapsode.cabal
M src/Render.hs
M rhapsode.cabal => rhapsode.cabal +2 -1
@@ 67,7 67,8 @@ library
        -- Networking
        network-uri, async, hurl >= 2, filepath, temporary,
        -- CSS
        stylist >= 2.4 && <3, stylist-traits, css-syntax, scientific, xml-conduit-stylist >= 3 && <3.1,
        stylist >= 2.4 && <3, stylist-traits >= 0.1.1, css-syntax, scientific,
        xml-conduit-stylist >= 3 && <3.1,
        -- Voice2Json input
        process, aeson >= 1.5 && <1.6, unordered-containers
  

M src/Render.hs => src/Render.hs +1 -12
@@ 23,6 23,7 @@ import           Data.CSS.Preprocessor.Assets
import qualified Data.CSS.Preprocessor.PsuedoClasses as CSSPseudo
import qualified Data.CSS.Preprocessor.Text as CSSTxt
import           Stylist (cssPriorityAgent, cssPriorityUser, attrTest, elementPath)
import           Stylist.Tree (treeFind)
import           Data.HTML2CSS (el2stylist)

import           Network.URI


@@ 146,18 147,6 @@ rhapsodePseudoFilter url hist tree =
    CSSPseudo.addContains "target-within" (targetWithinSel tree $ uriFragment url) $
    CSSPseudo.htmlPsuedoFilter Style.queryableStyleSheet

-- Apparantly I forgot to export this API...
treeFind :: StyleTree p -> (p -> Bool) -> [p]
treeFind p test = filter test $ treeFlattenAll p

-- And forgot to export this too...
treeFlattenAll :: StyleTree p -> [p]
treeFlattenAll = treeFlattenAll' . children
treeFlattenAll' :: [StyleTree p] -> [p]
treeFlattenAll' (StyleTree p []:ps) = p : treeFlattenAll' ps
treeFlattenAll' (StyleTree p childs:sibs) = p : treeFlattenAll' childs ++ treeFlattenAll' sibs
treeFlattenAll' [] = []

--------
---- Download assets
--------