diff options
Diffstat (limited to 'ibb/Main.hs')
-rw-r--r-- | ibb/Main.hs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/ibb/Main.hs b/ibb/Main.hs index b24c822..4940396 100644 --- a/ibb/Main.hs +++ b/ibb/Main.hs @@ -3,18 +3,21 @@ module Main where -import Data.Maybe (fromMaybe) +import Control.Monad.IO.Class (liftIO) import Data.ByteString.Lazy (ByteString) +import Data.Maybe (fromMaybe) import Data.Text.Lazy (Text) import Data.Text.Lazy.Encoding (encodeUtf8) +import Influencers (Person(..), Book(..), allPeople) +import System.Environment (lookupEnv) +import System.Random (newStdGen) +import System.Random.Shuffle (shuffle') import Text.Blaze (Markup) import Text.Blaze.Html (Html) import Text.Blaze.Html.Renderer.Text (renderHtml) import Text.Hamlet (shamlet) import Text.Lucius (lucius, renderCss) -import Web.Scotty (ActionM, scotty, get, html, raw, setHeader) -import Influencers -import System.Environment (lookupEnv) +import Web.Scotty (ActionM, ScottyM, scotty, get, html, raw, setHeader) render :: Html -> ActionM () render = html . renderHtml @@ -27,11 +30,14 @@ main = do port <- read <$> fromMaybe "3000" <$> lookupEnv "PORT" :: IO Int scotty port routes +routes :: ScottyM () routes = do - get "/" $ render homepage + get "/" $ do + r <- liftIO newStdGen + let peopleList = shuffle' allPeople (length allPeople) r + render (homepage peopleList) get "/custom.css" $ css stylesheet - displayPerson :: Person -> Markup displayPerson person = [shamlet| <div .card> @@ -51,11 +57,11 @@ displayPerson person = [shamlet| |] title, subtitle :: Text -title = "Influenced by books" +title = "Influenced By Books" subtitle = "Influential people and the books that made them." -homepage :: Markup -homepage = [shamlet| +homepage :: [Person] -> Markup +homepage peopleList = [shamlet| <!doctype html> <head> <meta charset="utf-8"> @@ -83,7 +89,7 @@ homepage = [shamlet| Get new book recommendations from the world's influencers in your email. <div .card-columns> - $forall person <- allPeople + $forall person <- peopleList #{displayPerson person} |] @@ -93,4 +99,7 @@ stylesheet = encodeUtf8 . renderCss $ [lucius| { background: #fff ; text-align: center } +h1.display-4 +{ font-family: 'Times New Roman', times, serif +} |] undefined |