~alcinnz/hurl

065e14da910b11bd73ad81ce9f2de58be4acd417 — Adrian Cochrane 1 year, 9 months ago 4df3d28
Broaden dependency bounds.
3 files changed, 12 insertions(+), 12 deletions(-)

M hurl-xml/hurl-xml.cabal
M hurl-xml/src/Network/URI/Fetch/XML/Table.hs
M hurl.cabal
M hurl-xml/hurl-xml.cabal => hurl-xml/hurl-xml.cabal +1 -1
@@ 60,7 60,7 @@ library
  -- other-extensions:

  -- Other library packages from which modules are imported.
  build-depends:       base >=4.12 && <4.13, text, bytestring, containers,
  build-depends:       base >=4.12 && <4.16, text, bytestring, containers,
                       data-default-class,
                       time, directory, filepath, temporary,
                       xml-conduit >= 1.8 && <2, html-conduit >= 1.3 && <2,

M hurl-xml/src/Network/URI/Fetch/XML/Table.hs => hurl-xml/src/Network/URI/Fetch/XML/Table.hs +9 -9
@@ 19,7 19,7 @@ applySortDoc anchor doc@Document {documentRoot = el} = doc {documentRoot = apply

applySort :: String -> Element -> Element
applySort ('#':'-':'a':'r':'g':'o':'-':'%':anchor) el
    | (id', ord:col) <- L.break (`elem` ['<', '>']) anchor, Just col' <- readMaybe col =
    | (id', ord:col) <- L.break (`L.elem` ['<', '>']) anchor, Just col' <- readMaybe col =
        applySort' id' (ord == '<') col' el
applySort _ el = el



@@ 94,14 94,14 @@ tableHeadComparators = Prelude.map (fromMaybe "alphanumeric") . tableHeadCompara
tableHeadComparators' :: [Node] -> [Maybe Text]
tableHeadComparators' (NodeElement el@Element { elementName = Name name _ _, elementNodes = childs}:els)
    | name == "thead" = tableHeadComparators' childs `mergeRight` tableHeadComparators' els
    | name `elem` ["colgroup", "tr"] = tableRowComparators childs `mergeRight` tableHeadComparators' els
    | name `L.elem` ["colgroup", "tr"] = tableRowComparators childs `mergeRight` tableHeadComparators' els
    | otherwise = tableHeadComparators' els
tableHeadComparators' [] = []
tableRowComparators :: [Node] -> [Maybe Text]
tableRowComparators (NodeElement el@(Element (Name "col" _ _) attrs _):els) =
    let colspan = fromMaybe 1 (M.lookup "span" attrs >>= readMaybe . unpack)
    in Prelude.replicate colspan (M.lookup "-argo-sortas" attrs) ++ tableRowComparators els
tableRowComparators (NodeElement el@(Element (Name n _ _) attrs _):els) | n `elem` ["td", "th"] =
tableRowComparators (NodeElement el@(Element (Name n _ _) attrs _):els) | n `L.elem` ["td", "th"] =
    let colspan = fromMaybe 1 (M.lookup "colspan" attrs >>= readMaybe . unpack)
    in Prelude.replicate colspan (M.lookup "-argo-sortas" attrs) ++ tableRowComparators els
tableRowComparators (_:els) = tableRowComparators els


@@ 120,9 120,9 @@ annotateTHead (child:childs) a c = child:annotateTHead childs a c
annotateTHead [] _ _ = []

annotateTR (NodeElement el@Element { elementName = Name n _ _, elementAttributes = attrs }:nodes) asc col count
    | n `elem` ["th", "td"], count >= col =
    | n `L.elem` ["th", "td"], count >= col =
        NodeElement el { elementAttributes = M.insert "aria-sort" asc' attrs }:nodes
    | n `elem` ["th", "td"] = NodeElement el:annotateTR nodes asc col (count + colspan)
    | n `L.elem` ["th", "td"] = NodeElement el:annotateTR nodes asc col (count + colspan)
  where
    colspan = fromMaybe 1 (readMaybe =<< unpack <$> M.lookup "colspan" attrs')
    attrs' = M.mapKeys nameLocalName attrs


@@ 140,9 140,9 @@ trs2sorttable _ = Nothing

tds2keys :: [Element] -> Maybe [Text]
tds2keys (el@Element {elementName = Name n _ _, elementAttributes = attrs, elementNodes = childs }:els)
    | n `elem` ["td", "th"], Just key <- "-argo-sortkey" `M.lookup` attrs, Just rest <- tds2keys els =
    | n `L.elem` ["td", "th"], Just key <- "-argo-sortkey" `M.lookup` attrs, Just rest <- tds2keys els =
        Just (Prelude.replicate colspan key ++ rest)
    | n `elem` ["td", "th"], Just rest <- tds2keys els =
    | n `L.elem` ["td", "th"], Just rest <- tds2keys els =
        Just (Prelude.replicate colspan (nodesText childs) ++ rest)
  where
    colspan | Just n <- "colspan" `M.lookup` M.mapKeys nameLocalName attrs,


@@ 160,7 160,7 @@ groupTrs _ _ = Nothing
rowRowspan n Element {elementName = Name "tr" _ _, elementNodes = childs } =
    Prelude.maximum (n : [n |
            NodeElement (Element (Name name _ _) attrs _) <- childs,
            name `elem` ["td", "th"],
            name `L.elem` ["td", "th"],
            rowspan <- maybeToList ("rowspan" `M.lookup` M.mapKeys nameLocalName attrs),
            n <- maybeToList $ readMaybe $ unpack rowspan])



@@ 204,7 204,7 @@ compareAs as bs "text" = as `compare` bs
compareAs as bs "number" = readInt as `compare` readInt bs
    where
        readInt :: Text -> Maybe Float
        readInt = readMaybe . Prelude.filter (`elem` '-':'.':['0'..'9']) . unpack
        readInt = readMaybe . Prelude.filter (`L.elem` '-':'.':['0'..'9']) . unpack
compareAs as bs fmt = readTime as `compare` readTime bs
    where
        readTime :: Text -> Maybe UTCTime

M hurl.cabal => hurl.cabal +2 -2
@@ 98,8 98,8 @@ library
  -- other-extensions:    
  
  -- Other library packages from which modules are imported.
  build-depends:       base >=4.9 && <5, text >= 1.2 && <1.3,
                       network-uri >=2.6 && <2.7, bytestring >= 0.10 && < 0.11,
  build-depends:       base >=4.9 && <5, text >= 1.2 && <3,
                       network-uri >=2.6 && <2.7, bytestring >= 0.10 && < 0.12,
                       async >= 2.1 && < 2.3, filepath, directory >= 1.3.2,
                       time >= 1.6