aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Model/Resume.hs1
-rw-r--r--src/Parser/Resume.hs6
-rw-r--r--src/Time.hs9
-rw-r--r--src/View/Html/Ad.hs16
-rw-r--r--src/View/Html/Design.hs24
-rw-r--r--src/View/Plain/Ad.hs3
6 files changed, 37 insertions, 22 deletions
diff --git a/src/Model/Resume.hs b/src/Model/Resume.hs
index 3e3cd82..59f6698 100644
--- a/src/Model/Resume.hs
+++ b/src/Model/Resume.hs
@@ -13,6 +13,7 @@ data Resume = Resume
{ name :: Text
, price :: Maybe Text
, url :: URL
+ , isPro :: Bool
} deriving (Eq, Read, Show)
getNewResumes :: [URL] -> [Resume] -> ([URL], [Resume])
diff --git a/src/Parser/Resume.hs b/src/Parser/Resume.hs
index f300ec3..8940be7 100644
--- a/src/Parser/Resume.hs
+++ b/src/Parser/Resume.hs
@@ -2,7 +2,8 @@ module Parser.Resume
( parse
) where
-import Data.Maybe (catMaybes)
+import Data.Maybe (catMaybes, isJust)
+import Data.List (find)
import Data.Text (Text)
import qualified Data.Text as T
@@ -26,4 +27,5 @@ parseResume item = do
name <- getTagTextAfter "<h2 class=item_title>" item
let price = getTagTextAfter "<h3 class=item_price>" item
url <- getTagAttribute "<a>" (T.pack "href") item
- return (Resume name price (T.concat [T.pack "https:", url]))
+ let isPro = isJust . find (~== "<span class=ispro>") $ item
+ return (Resume name price (T.concat [T.pack "https:", url]) isPro)
diff --git a/src/Time.hs b/src/Time.hs
index a7fb418..99d47d0 100644
--- a/src/Time.hs
+++ b/src/Time.hs
@@ -5,13 +5,10 @@ module Time
import Data.Text (Text)
import qualified Data.Text as T
-import Data.Time.Clock (getCurrentTime)
-import Data.Time.LocalTime (getCurrentTimeZone, utcToLocalTime)
+import Data.Time.LocalTime (getZonedTime)
import Data.Time.Format (formatTime, defaultTimeLocale)
getCurrentFormattedTime :: IO Text
getCurrentFormattedTime = do
- currentTime <- getCurrentTime
- timeZone <- getCurrentTimeZone
- let localTime = utcToLocalTime timeZone currentTime
- return (T.pack $ formatTime defaultTimeLocale "%Hh%M" localTime)
+ zonedTime <- getZonedTime
+ return (T.pack $ formatTime defaultTimeLocale "%Hh%M" zonedTime)
diff --git a/src/View/Html/Ad.hs b/src/View/Html/Ad.hs
index d8a3bae..53e63bf 100644
--- a/src/View/Html/Ad.hs
+++ b/src/View/Html/Ad.hs
@@ -32,7 +32,7 @@ import Model.URL
import Conf (Conf)
import qualified Conf
-import View.Html.Design
+import qualified View.Html.Design as Design
renderAds :: Conf -> [Ad] -> Text
renderAds conf = toStrict . renderHtml . (adsHtml conf)
@@ -56,10 +56,18 @@ resumeHtml resume = do
Just price ->
H.span
! A.class_ "price"
- ! A.style (textValue . toStrict $ priceDesign)
+ ! A.style (textValue . toStrict $ Design.price)
$ toHtml price
Nothing ->
H.span ""
+ if Resume.isPro resume
+ then
+ H.span
+ ! A.class_ "pro"
+ ! A.style (textValue . toStrict $ Design.pro)
+ $ "PRO"
+ else
+ ""
linkHtml (Resume.url resume)
detailHtml :: Conf -> Detail -> Html
@@ -75,7 +83,7 @@ detailHtml conf detail = do
propertiesHtml :: [Text] -> Map Text Text -> Html
propertiesHtml keys properties =
H.dl
- ! A.style (textValue . toStrict $ dlDesign)
+ ! A.style (textValue . toStrict $ Design.definitionList)
$ sequence_ (catMaybes $ map (propertyHtml properties) keys)
propertyHtml :: Map Text Text -> Text -> Maybe Html
@@ -83,7 +91,7 @@ propertyHtml properties key =
fmap
(\value -> do
H.dt $ (toHtml key)
- H.dd ! A.style (textValue . toStrict $ ddDesign) $ (toHtml value)
+ H.dd ! A.style (textValue . toStrict $ Design.definitionDescription) $ (toHtml value)
)
(M.lookup key properties)
diff --git a/src/View/Html/Design.hs b/src/View/Html/Design.hs
index 6ef5659..71fa09d 100644
--- a/src/View/Html/Design.hs
+++ b/src/View/Html/Design.hs
@@ -1,9 +1,10 @@
{-# LANGUAGE OverloadedStrings #-}
module View.Html.Design
- ( dlDesign
- , ddDesign
- , priceDesign
+ ( definitionList
+ , definitionDescription
+ , price
+ , pro
) where
import Data.Text.Lazy (Text)
@@ -11,19 +12,24 @@ import qualified Data.Text.Lazy as T
import Clay
-dlDesign :: Text
-dlDesign = inlineRender $ do
+definitionList :: Text
+definitionList = inlineRender $ do
fontWeight bold
fontSize (px 16)
-ddDesign :: Text
-ddDesign = inlineRender $ do
+definitionDescription :: Text
+definitionDescription = inlineRender $ do
marginLeft (px 0)
marginBottom (px 10)
color orangered
-priceDesign :: Text
-priceDesign = inlineRender $ do
+pro :: Text
+pro = inlineRender $ do
+ marginLeft (px 10)
+ color blue
+
+price :: Text
+price = inlineRender $ do
marginLeft (px 10)
color orangered
diff --git a/src/View/Plain/Ad.hs b/src/View/Plain/Ad.hs
index 75e35e2..b9e980e 100644
--- a/src/View/Plain/Ad.hs
+++ b/src/View/Plain/Ad.hs
@@ -75,7 +75,8 @@ renderResume :: Resume -> Text
renderResume resume =
let formatPrice price = T.concat [" - ", price]
getPrice = fromMaybe "" . fmap formatPrice . Resume.price $ resume
- titleLine = T.concat [Resume.name resume, getPrice]
+ isPro = if Resume.isPro resume then " - PRO" else ""
+ titleLine = T.concat [Resume.name resume, getPrice, isPro]
in T.intercalate "\n" [titleLine, Resume.url resume]
renderDetail :: Conf -> Detail -> Text