ArtDecoTab.purs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module LinkedIn.ArtDecoTab where
  2. import Prelude
  3. import Data.Generic.Rep (class Generic)
  4. import Data.List (List)
  5. import Data.List.Types (NonEmptyList)
  6. import Data.Maybe (Maybe)
  7. import Data.Show.Generic (genericShow)
  8. import LinkedIn (DetachedNode)
  9. import LinkedIn.ArtDeco (ArtDecoPvsEntity, parseArtDecoPvsEntity)
  10. import LinkedIn.ArtDeco as AD
  11. import LinkedIn.Types (Parser)
  12. import LinkedIn.Utils (queryOneAndParse)
  13. data ArtDecoTabElement a = ArtDecoTabElement {
  14. pvs_entity :: ArtDecoPvsEntity a
  15. }
  16. derive instance Generic (ArtDecoTabElement a) _
  17. derive instance Eq a => Eq (ArtDecoTabElement a)
  18. instance Show a => Show (ArtDecoTabElement a) where
  19. show = genericShow
  20. instance Functor ArtDecoTabElement where
  21. map f (ArtDecoTabElement {pvs_entity}) =
  22. ArtDecoTabElement ({pvs_entity: map f pvs_entity})
  23. parseArtDecoTab :: Parser (ArtDecoTabElement DetachedNode)
  24. parseArtDecoTab n = do
  25. pvs <- queryOneAndParse ":scope div.pvs-entity--padded" parseArtDecoPvsEntity n
  26. pure $ ado
  27. p <- pvs
  28. in ArtDecoTabElement {pvs_entity: p}
  29. toCenterContent ∷ forall a. ArtDecoTabElement a → List a
  30. toCenterContent = toPvsEntity >>> AD.toCenterContent
  31. toHeaderBold ∷ forall a. ArtDecoTabElement a → a
  32. toHeaderBold = toPvsEntity >>> AD.toHeaderBold
  33. toHeaderLight ∷ forall a. ArtDecoTabElement a → Maybe (NonEmptyList a)
  34. toHeaderLight = toPvsEntity >>> AD.toHeaderLight
  35. toHeaderNormal ∷ forall a. ArtDecoTabElement a → Maybe a
  36. toHeaderNormal = toPvsEntity >>> AD.toHeaderNormal
  37. toPvsEntity ∷ forall a. ArtDecoTabElement a → ArtDecoPvsEntity a
  38. toPvsEntity (ArtDecoTabElement { pvs_entity }) = pvs_entity