diff --git a/breve.cabal b/breve.cabal index a830e23..a703313 100644 --- a/breve.cabal +++ b/breve.cabal @@ -34,7 +34,7 @@ executable breve DataKinds, KindSignatures, TypeOperators build-depends: base >=4.8 && <5.0, warp, warp-tls, tls, blaze-html, - servant-server, servant-rawm, servant-blaze, + servant-server, servant-rawm-server, servant-blaze, wai, wai-extra, streaming-commons, http-api-data, mtl, text, aeson, bytestring, binary, diff --git a/src/Application.hs b/src/Application.hs index 01e9c72..205ff27 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -30,9 +30,9 @@ import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -- API definition import Servant -import Servant.HTML.Blaze (HTML) -import Servant.RawM as R -import Web.FormUrlEncoded (FromForm(..), parseUnique) +import Servant.HTML.Blaze (HTML) +import Web.FormUrlEncoded (FromForm(..), parseUnique) +import qualified Servant.RawM.Server as R -- * Types @@ -96,7 +96,7 @@ type Breve = API :<|> App -- +----------+------+----------------------+ type App = Get '[HTML] Html - :<|> "static" :> RawM + :<|> "static" :> R.RawM :<|> Capture "name" Name :> Redirect :<|> ReqBody '[FormUrlEncoded] UrlForm :> Post '[HTML] Html diff --git a/src/Breve/Generator.hs b/src/Breve/Generator.hs index b375d23..1e2da04 100644 --- a/src/Breve/Generator.hs +++ b/src/Breve/Generator.hs @@ -9,6 +9,7 @@ module Breve.Generator , intHash ) where +import Control.Monad (replicateM) import Control.Monad.State import System.Random import Crypto.Hash.SHA256 (hash) diff --git a/src/Views.hs b/src/Views.hs index 04d73fb..b796fc4 100644 --- a/src/Views.hs +++ b/src/Views.hs @@ -11,7 +11,7 @@ import Text.Blaze.Html5.Attributes as A -- | The homepage index :: Html -index = template $ do +index = breveTemplate $ do H.form ! method "POST" $ do "your url:" input ! type_ "text" ! name "url" @@ -21,20 +21,20 @@ index = template $ do -- submitted successfully. Takes the resulting -- url as an argument. done :: Text -> Html -done url = template $ do +done url = breveTemplate $ do "here's your new link: " a ! href (toValue url) $ (toHtml url) -- | Displays a text message in the page center message :: Text -> Html -message = template . toHtml +message = breveTemplate . toHtml -- | The main Breve template -- -- Takes HTML code and embeds it in the -- inner page container. -template :: Html -> Html -template fill = +breveTemplate :: Html -> Html +breveTemplate fill = docTypeHtml $ do H.head $ do H.title "breve: url shortener" @@ -42,6 +42,7 @@ template fill = meta ! name "keywords" ! content "url, shortener" meta ! name "author" ! content "Michele Guerini Rocco" meta ! charset "utf-8" + meta ! name "color-scheme" ! content "dark" link ! rel "stylesheet" ! href "/static/main.css" ! type_ "text/css" link ! rel "apple-touch-icon" ! href "static/icon-big.png" link ! rel "icon" ! type_ "image/png" ! href "/static/icon-medium.png" ! sizes "96x96"