|
|
@@ -1,22 +1,17 @@
|
|
|
module LinkedIn.ArtDecoCardAlt where
|
|
|
|
|
|
-import Control.Monad.Except.Trans
|
|
|
import Prelude
|
|
|
|
|
|
-import Data.Either (Either(..), note)
|
|
|
import Data.Foldable (class Foldable, foldMap, foldlDefault, foldrDefault)
|
|
|
import Data.Generic.Rep (class Generic)
|
|
|
import Data.List.Types (NonEmptyList)
|
|
|
-import Data.Maybe (Maybe(..))
|
|
|
+import Data.Maybe (Maybe)
|
|
|
import Data.Show.Generic (genericShow)
|
|
|
import Data.Traversable (class Traversable, sequence, traverseDefault)
|
|
|
-import Effect (Effect)
|
|
|
-import LinkedIn.Types (QueryError(..), QueryRunner)
|
|
|
-import LinkedIn.Utils (queryAll, queryOne)
|
|
|
+import LinkedIn.QueryRunner (QueryRunner, ignoreNotFound, queryAll, queryOne)
|
|
|
import Web.DOM (Node)
|
|
|
import Web.DOM.Node (nodeName)
|
|
|
|
|
|
-
|
|
|
data ArtDecoCenterHeaderAlt a = ArtDecoCenterHeaderAlt {
|
|
|
bold :: a,
|
|
|
normal :: Maybe a,
|
|
|
@@ -74,40 +69,19 @@ instance Traversable ArtDecoCardAltElement where
|
|
|
|
|
|
queryArtDecoCenterHeaderAlt ∷ QueryRunner (ArtDecoCenterHeaderAlt Node)
|
|
|
queryArtDecoCenterHeaderAlt n = do
|
|
|
- bold <- runOne ":scope div.t-bold > span[aria-hidden=true]" n
|
|
|
+ bold <- queryOne ":scope div.t-bold > span[aria-hidden=true]" n
|
|
|
normal <-
|
|
|
ignoreNotFound $
|
|
|
- runOne ":scope span.t-normal:not(t-black--light) > span[aria-hidden=true]" n
|
|
|
+ queryOne ":scope span.t-normal:not(t-black--light) > span[aria-hidden=true]" n
|
|
|
light <-
|
|
|
ignoreNotFound $
|
|
|
- runAll ":scope span.t-black--light > span[aria-hidden=true]" n
|
|
|
+ queryAll ":scope span.t-black--light > span[aria-hidden=true]" n
|
|
|
|
|
|
pure $ ArtDecoCenterHeaderAlt {bold, normal, light}
|
|
|
|
|
|
queryArtDecoCardAlt ∷ QueryRunner (ArtDecoCardAltElement Node)
|
|
|
queryArtDecoCardAlt n = do
|
|
|
- pvs <- runOne ":scope div.pvs-entity--padded" n
|
|
|
+ pvs <- queryOne ":scope div.pvs-entity--padded" n
|
|
|
header <- queryArtDecoCenterHeaderAlt pvs
|
|
|
|
|
|
pure $ ArtDecoCardAltElement { pvs_entity: header }
|
|
|
-
|
|
|
-runQuery ∷ ∀ a. ExceptT QueryError Effect a → Effect (Either QueryError a)
|
|
|
-runQuery = runExceptT
|
|
|
-
|
|
|
-ignoreNotFound ∷ ∀ a f. Functor f ⇒ ExceptT QueryError f a → ExceptT QueryError f (Maybe a)
|
|
|
-ignoreNotFound = mapExceptT (map ignoreNotFound')
|
|
|
- where
|
|
|
- ignoreNotFound' = case _ of
|
|
|
- (Left (QNodeNotFoundError _ )) -> Right Nothing
|
|
|
- (Left q) -> Left q
|
|
|
- (Right n') -> Right (Just n')
|
|
|
-
|
|
|
-runOne ∷ String → QueryRunner Node
|
|
|
-runOne selector node = ExceptT $ do
|
|
|
- maybeNode <- queryOne selector node
|
|
|
- pure $ note (QNodeNotFoundError selector) maybeNode
|
|
|
-
|
|
|
-runAll ∷ String → QueryRunner (NonEmptyList Node)
|
|
|
-runAll selector node = ExceptT $ do
|
|
|
- maybeNodes <- queryAll selector node
|
|
|
- pure $ note (QNodeListNotFoundError selector) maybeNodes
|