jherve 1 год назад
Родитель
Сommit
b85b950bd1

+ 3 - 3
src/LinkedIn/Page/JobOffer.purs

@@ -6,12 +6,12 @@ import Data.Foldable (class Foldable, foldMap, foldlDefault, foldrDefault)
 import Data.Generic.Rep (class Generic)
 import Data.Generic.Rep (class Generic)
 import Data.Show.Generic (genericShow)
 import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
-import LinkedIn.CanBeQueried (class CanBeQueried)
+import LinkedIn.CanBeQueried (class CanBeQueried, query)
 import LinkedIn.Extractible (class Extractible)
 import LinkedIn.Extractible (class Extractible)
 import LinkedIn.Jobs.JobOffer as JJO
 import LinkedIn.Jobs.JobOffer as JJO
 import LinkedIn.Output.Types (Output(..))
 import LinkedIn.Output.Types (Output(..))
 import LinkedIn.QueryRunner (subQueryOne)
 import LinkedIn.QueryRunner (subQueryOne)
-import LinkedIn.UI.Components.JobsUnifiedTopCard (JobsUnifiedTopCardElement, queryJobsUnifiedTopCardElement)
+import LinkedIn.UI.Components.JobsUnifiedTopCard (JobsUnifiedTopCardElement)
 import Web.DOM (Document)
 import Web.DOM (Document)
 
 
 data JobOfferPage a = JobOfferPage (JobsUnifiedTopCardElement a)
 data JobOfferPage a = JobOfferPage (JobsUnifiedTopCardElement a)
@@ -37,7 +37,7 @@ instance Traversable JobOfferPage where
 
 
 instance CanBeQueried Document JobOfferPage where
 instance CanBeQueried Document JobOfferPage where
   query n = do
   query n = do
-    card <- subQueryOne queryJobsUnifiedTopCardElement "div.jobs-unified-top-card" n
+    card <- subQueryOne query "div.jobs-unified-top-card" n
     pure $ JobOfferPage card
     pure $ JobOfferPage card
 
 
 instance Extractible JobOfferPage where
 instance Extractible JobOfferPage where

+ 1 - 2
src/LinkedIn/UI/Components/ArtDeco.purs

@@ -12,10 +12,9 @@ import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Tuple (Tuple(..))
 import Data.Tuple (Tuple(..))
 import LinkedIn.CanBeQueried (class CanBeQueried, query)
 import LinkedIn.CanBeQueried (class CanBeQueried, query)
-import LinkedIn.QueryRunner (QueryRunner', ignoreNotFound, queryAll, queryOne, subQueryMany, subQueryOne)
+import LinkedIn.QueryRunner (ignoreNotFound, queryAll, queryOne, subQueryMany, subQueryOne)
 import LinkedIn.Queryable (class Queryable)
 import LinkedIn.Queryable (class Queryable)
 import Type.Proxy (Proxy(..))
 import Type.Proxy (Proxy(..))
-import Web.DOM (Node)
 
 
 
 
 data ArtDecoPvsEntity a = ArtDecoPvsEntity {
 data ArtDecoPvsEntity a = ArtDecoPvsEntity {

+ 2 - 3
src/LinkedIn/UI/Components/ArtDecoCard.purs

@@ -14,11 +14,10 @@ import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Tuple (Tuple(..))
 import Data.Tuple (Tuple(..))
 import LinkedIn.CanBeQueried (class CanBeQueried, query)
 import LinkedIn.CanBeQueried (class CanBeQueried, query)
-import LinkedIn.QueryRunner (QueryRunner', subQueryOne)
+import LinkedIn.QueryRunner (subQueryOne)
 import LinkedIn.Queryable (class Queryable)
 import LinkedIn.Queryable (class Queryable)
-import LinkedIn.UI.Components.ArtDeco (ArtDecoPvsEntity, _pvs_to_header_bold, _pvs_to_header_light, _pvs_to_header_normal, _pvs_to_subcomponents, queryArtDecoPvsEntity)
+import LinkedIn.UI.Components.ArtDeco (ArtDecoPvsEntity, _pvs_to_header_bold, _pvs_to_header_light, _pvs_to_header_normal, _pvs_to_subcomponents)
 import Type.Proxy (Proxy(..))
 import Type.Proxy (Proxy(..))
-import Web.DOM (Node)
 
 
 
 
 data ArtDecoCardElement a = ArtDecoCardElement {
 data ArtDecoCardElement a = ArtDecoCardElement {

+ 2 - 3
src/LinkedIn/UI/Components/ArtDecoTab.purs

@@ -14,11 +14,10 @@ import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Tuple (Tuple(..))
 import Data.Tuple (Tuple(..))
 import LinkedIn.CanBeQueried (class CanBeQueried, query)
 import LinkedIn.CanBeQueried (class CanBeQueried, query)
-import LinkedIn.QueryRunner (QueryRunner', subQueryOne)
+import LinkedIn.QueryRunner (subQueryOne)
 import LinkedIn.Queryable (class Queryable)
 import LinkedIn.Queryable (class Queryable)
-import LinkedIn.UI.Components.ArtDeco (ArtDecoPvsEntity, _pvs_to_header_bold, _pvs_to_header_light, _pvs_to_header_normal, _pvs_to_subcomponents, queryArtDecoPvsEntity)
+import LinkedIn.UI.Components.ArtDeco (ArtDecoPvsEntity, _pvs_to_header_bold, _pvs_to_header_light, _pvs_to_header_normal, _pvs_to_subcomponents)
 import Type.Proxy (Proxy(..))
 import Type.Proxy (Proxy(..))
-import Web.DOM (Node)
 
 
 
 
 data ArtDecoTabElement a = ArtDecoTabElement {
 data ArtDecoTabElement a = ArtDecoTabElement {

+ 43 - 50
src/LinkedIn/UI/Components/JobsUnifiedTopCard.purs

@@ -82,7 +82,21 @@ traverseMayNel (Just o) = map pure (sequence (map sequence o))
 traverseMayNel Nothing = pure Nothing
 traverseMayNel Nothing = pure Nothing
 
 
 instance Queryable q => CanBeQueried q JobsUnifiedTopCardElement where
 instance Queryable q => CanBeQueried q JobsUnifiedTopCardElement where
-  query = queryJobsUnifiedTopCardElement
+  query n = do
+    header <- queryOne "h1.job-details-jobs-unified-top-card__job-title" n
+    primaryDescription <- query
+                            =<< queryOne "div.job-details-jobs-unified-top-card__primary-description-container > div" n
+    insights <- ignoreNotFound
+                  <<< traverse query
+                  =<< queryAll "li.job-details-jobs-unified-top-card__job-insight" n
+    actions <- ignoreNotFound <<< traverse query =<< queryAll ".mt5 button" n
+
+    pure $ JobsUnifiedTopCardElement {
+      header,
+      primaryDescription,
+      insights,
+      actions
+    }
 
 
 derive instance Generic (TopCardPrimaryDescription a) _
 derive instance Generic (TopCardPrimaryDescription a) _
 derive instance Eq a => Eq (TopCardPrimaryDescription a)
 derive instance Eq a => Eq (TopCardPrimaryDescription a)
@@ -173,6 +187,26 @@ instance Queryable q => CanBeQueried q TopCardInsightContent where
     <|> queryTopCardInsightContentButton n
     <|> queryTopCardInsightContentButton n
     <|> queryTopCardInsightContentSingle n
     <|> queryTopCardInsightContentSingle n
 
 
+    where
+      queryTopCardInsightContentSingle n = do
+        n' <- querySelf n
+        pure $ TopCardInsightContentSingle n'
+
+      queryTopCardInsightContentButton n =
+        if type_ == "BUTTON"
+        then do
+          n' <- querySelf n
+          pure $ TopCardInsightContentButton n'
+        else throwError (QNodeUnexpectedType "BUTTON" type_)
+
+        where type_ = N.nodeName $ toNode n
+
+      queryTopCardInsightContentSecondary n = do
+        primary <- queryOne ":scope > span:first-child span[aria-hidden=true]" n
+        secondary <- traverse query
+                      =<< queryAll ":scope > span.job-details-jobs-unified-top-card__job-insight-view-model-secondary" n
+        pure $ TopCardInsightContentSecondary {primary, secondary}
+
 derive instance Generic (TopCardSecondaryInsight a) _
 derive instance Generic (TopCardSecondaryInsight a) _
 derive instance Eq a => Eq (TopCardSecondaryInsight a)
 derive instance Eq a => Eq (TopCardSecondaryInsight a)
 instance Show a => Show (TopCardSecondaryInsight a) where
 instance Show a => Show (TopCardSecondaryInsight a) where
@@ -194,6 +228,14 @@ instance Traversable TopCardSecondaryInsight where
 
 
 instance Queryable q => CanBeQueried q TopCardSecondaryInsight where
 instance Queryable q => CanBeQueried q TopCardSecondaryInsight where
   query n = queryTopCardSecondaryInsightNested n <|> queryTopCardSecondaryInsightPlain n
   query n = queryTopCardSecondaryInsightNested n <|> queryTopCardSecondaryInsightPlain n
+    where
+      queryTopCardSecondaryInsightNested n = do
+        nested <- queryOne ":scope span[aria-hidden=true]" n
+        pure $ TopCardSecondaryInsightNested nested
+
+      queryTopCardSecondaryInsightPlain n = do
+        n' <- querySelf n
+        pure $ TopCardSecondaryInsightPlain n'
 
 
 derive instance Generic (TopCardAction a) _
 derive instance Generic (TopCardAction a) _
 derive instance Eq a => Eq (TopCardAction a)
 derive instance Eq a => Eq (TopCardAction a)
@@ -219,55 +261,6 @@ instance Queryable q => CanBeQueried q TopCardAction where
     n' <- querySelf n
     n' <- querySelf n
     pure $ TopCardActionButton n'
     pure $ TopCardActionButton n'
 
 
-queryTopCardSecondaryInsightNested :: forall q. Queryable q => QueryRunner' q (TopCardSecondaryInsight Node)
-queryTopCardSecondaryInsightNested n = do
-  nested <- queryOne ":scope span[aria-hidden=true]" n
-  pure $ TopCardSecondaryInsightNested nested
-
-queryTopCardSecondaryInsightPlain :: forall q. Queryable q => QueryRunner' q (TopCardSecondaryInsight Node)
-queryTopCardSecondaryInsightPlain n = do
-  n' <- querySelf n
-  pure $ TopCardSecondaryInsightPlain n'
-
-queryTopCardInsightContentSingle :: forall q. Queryable q => QueryRunner' q (TopCardInsightContent Node)
-queryTopCardInsightContentSingle n = do
-  n' <- querySelf n
-  pure $ TopCardInsightContentSingle n'
-
-queryTopCardInsightContentButton :: forall q. Queryable q => QueryRunner' q (TopCardInsightContent Node)
-queryTopCardInsightContentButton n =
-  if type_ == "BUTTON"
-  then do
-    n' <- querySelf n
-    pure $ TopCardInsightContentButton n'
-  else throwError (QNodeUnexpectedType "BUTTON" type_)
-
-  where type_ = N.nodeName $ toNode n
-
-queryTopCardInsightContentSecondary :: forall q. Queryable q => QueryRunner' q (TopCardInsightContent Node)
-queryTopCardInsightContentSecondary n = do
-  primary <- queryOne ":scope > span:first-child span[aria-hidden=true]" n
-  secondary <- traverse query
-                =<< queryAll ":scope > span.job-details-jobs-unified-top-card__job-insight-view-model-secondary" n
-  pure $ TopCardInsightContentSecondary {primary, secondary}
-
-queryJobsUnifiedTopCardElement :: forall q. Queryable q => QueryRunner' q (JobsUnifiedTopCardElement Node)
-queryJobsUnifiedTopCardElement n = do
-  header <- queryOne "h1.job-details-jobs-unified-top-card__job-title" n
-  primaryDescription <- query
-                          =<< queryOne "div.job-details-jobs-unified-top-card__primary-description-container > div" n
-  insights <- ignoreNotFound
-                <<< traverse query
-                =<< queryAll "li.job-details-jobs-unified-top-card__job-insight" n
-  actions <- ignoreNotFound <<< traverse query =<< queryAll ".mt5 button" n
-
-  pure $ JobsUnifiedTopCardElement {
-    header,
-    primaryDescription,
-    insights,
-    actions
-  }
-
 toHeader ∷ forall a. JobsUnifiedTopCardElement a → a
 toHeader ∷ forall a. JobsUnifiedTopCardElement a → a
 toHeader = view $ _top_card <<< prop (Proxy :: Proxy "header")
 toHeader = view $ _top_card <<< prop (Proxy :: Proxy "header")