fix build with stackage LTS 22

This commit is contained in:
Michele Guerini Rocco 2024-06-30 22:06:08 +02:00
parent dd3bc74708
commit 70d029c24c
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
4 changed files with 12 additions and 10 deletions

View File

@ -34,7 +34,7 @@ executable breve
DataKinds, KindSignatures, TypeOperators DataKinds, KindSignatures, TypeOperators
build-depends: base >=4.8 && <5.0, build-depends: base >=4.8 && <5.0,
warp, warp-tls, tls, blaze-html, 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, wai, wai-extra, streaming-commons, http-api-data,
mtl, text, aeson, bytestring, binary, mtl, text, aeson, bytestring, binary,

View File

@ -31,8 +31,8 @@ import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
-- API definition -- API definition
import Servant import Servant
import Servant.HTML.Blaze (HTML) import Servant.HTML.Blaze (HTML)
import Servant.RawM as R
import Web.FormUrlEncoded (FromForm(..), parseUnique) import Web.FormUrlEncoded (FromForm(..), parseUnique)
import qualified Servant.RawM.Server as R
-- * Types -- * Types
@ -96,7 +96,7 @@ type Breve = API :<|> App
-- +----------+------+----------------------+ -- +----------+------+----------------------+
type App = type App =
Get '[HTML] Html Get '[HTML] Html
:<|> "static" :> RawM :<|> "static" :> R.RawM
:<|> Capture "name" Name :> Redirect :<|> Capture "name" Name :> Redirect
:<|> ReqBody '[FormUrlEncoded] UrlForm :> Post '[HTML] Html :<|> ReqBody '[FormUrlEncoded] UrlForm :> Post '[HTML] Html

View File

@ -9,6 +9,7 @@ module Breve.Generator
, intHash , intHash
) where ) where
import Control.Monad (replicateM)
import Control.Monad.State import Control.Monad.State
import System.Random import System.Random
import Crypto.Hash.SHA256 (hash) import Crypto.Hash.SHA256 (hash)

View File

@ -11,7 +11,7 @@ import Text.Blaze.Html5.Attributes as A
-- | The homepage -- | The homepage
index :: Html index :: Html
index = template $ do index = breveTemplate $ do
H.form ! method "POST" $ do H.form ! method "POST" $ do
"your url:" "your url:"
input ! type_ "text" ! name "url" input ! type_ "text" ! name "url"
@ -21,20 +21,20 @@ index = template $ do
-- submitted successfully. Takes the resulting -- submitted successfully. Takes the resulting
-- url as an argument. -- url as an argument.
done :: Text -> Html done :: Text -> Html
done url = template $ do done url = breveTemplate $ do
"here's your new link: " "here's your new link: "
a ! href (toValue url) $ (toHtml url) a ! href (toValue url) $ (toHtml url)
-- | Displays a text message in the page center -- | Displays a text message in the page center
message :: Text -> Html message :: Text -> Html
message = template . toHtml message = breveTemplate . toHtml
-- | The main Breve template -- | The main Breve template
-- --
-- Takes HTML code and embeds it in the -- Takes HTML code and embeds it in the
-- inner page container. -- inner page container.
template :: Html -> Html breveTemplate :: Html -> Html
template fill = breveTemplate fill =
docTypeHtml $ do docTypeHtml $ do
H.head $ do H.head $ do
H.title "breve: url shortener" H.title "breve: url shortener"
@ -42,6 +42,7 @@ template fill =
meta ! name "keywords" ! content "url, shortener" meta ! name "keywords" ! content "url, shortener"
meta ! name "author" ! content "Michele Guerini Rocco" meta ! name "author" ! content "Michele Guerini Rocco"
meta ! charset "utf-8" meta ! charset "utf-8"
meta ! name "color-scheme" ! content "dark"
link ! rel "stylesheet" ! href "/static/main.css" ! type_ "text/css" link ! rel "stylesheet" ! href "/static/main.css" ! type_ "text/css"
link ! rel "apple-touch-icon" ! href "static/icon-big.png" link ! rel "apple-touch-icon" ! href "static/icon-big.png"
link ! rel "icon" ! type_ "image/png" ! href "/static/icon-medium.png" ! sizes "96x96" link ! rel "icon" ! type_ "image/png" ! href "/static/icon-medium.png" ! sizes "96x96"