aboutsummaryrefslogtreecommitdiff
path: root/src/View
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-04-11 11:50:48 +0200
committerJoris Guyonvarch2015-04-11 12:03:22 +0200
commit5977e1454d7738ddb086d37b20337e350e380790 (patch)
treee03261144e3d534434242c1dd037c2a4e4db5a9f /src/View
Fetch first page ads of a given leboncoin url, fetch also the description page of each item.
Diffstat (limited to 'src/View')
-rw-r--r--src/View/Ad.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/View/Ad.hs b/src/View/Ad.hs
new file mode 100644
index 0000000..445ef3a
--- /dev/null
+++ b/src/View/Ad.hs
@@ -0,0 +1,28 @@
+module View.Ad
+ ( renderAd
+ ) where
+
+import Data.List (intersperse)
+import Data.Maybe (fromMaybe)
+
+import Model.Ad (Ad(..))
+import qualified Model.Ad as Ad
+import Model.Resume (Resume(..))
+import qualified Model.Resume as Resume
+import Model.Detail (Detail(..))
+import qualified Model.Detail as Detail
+
+renderAd :: Ad -> String
+renderAd ad =
+ (renderResume (Ad.resume ad)) ++ "\n\n" ++ (renderDetail (Ad.detail ad)) ++ "\n"
+
+renderResume :: Resume -> String
+renderResume resume =
+ let formatPrice price = " - " ++ price
+ price = fromMaybe "" . fmap formatPrice . Resume.price $ resume
+ titleLine = (Resume.name resume) ++ price
+ in concat . intersperse "\n" $ [titleLine, Resume.url resume]
+
+renderDetail :: Detail -> String
+renderDetail detail =
+ fromMaybe "−" (Detail.description detail)