From a11ad41b52ed3682d33382f2a378bf3294d688b2 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 23 Mar 2016 00:45:33 +0100 Subject: Sign in token link to / --- src/server/View/Page.hs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/server/View/Page.hs') diff --git a/src/server/View/Page.hs b/src/server/View/Page.hs index 4fc57f9..0f1ff86 100644 --- a/src/server/View/Page.hs +++ b/src/server/View/Page.hs @@ -7,6 +7,7 @@ module View.Page import Data.Text.Internal.Lazy (Text) import Data.Text.Lazy.Encoding (decodeUtf8) import Data.Aeson (encode) +import qualified Data.Aeson.Types as Json import Text.Blaze.Html import Text.Blaze.Html5 @@ -19,22 +20,28 @@ import Design.Global (globalDesign) import Model.Message import Model.Json.Conf -import Model.Message.Key (Key(SharedCost)) +import Model.Message.Key (Key, Key(SharedCost)) -page :: Conf -> Text -page conf = +page :: Conf -> Maybe Key -> Text +page conf mbSignInError = renderHtml . docTypeHtml $ do H.head $ do meta ! charset "UTF-8" - meta ! httpEquiv "X-UA-Compatible" ! content "IE=Edge" -- IE8+ only is valid to use with persona H.title (toHtml $ getMessage SharedCost) - script ! src "https://login.persona.org/include.js" $ "" script ! src "javascripts/client.js" $ "" - script ! A.id "messages" ! type_ "application/json" $ toHtml . decodeUtf8 . encode $ getTranslations - script ! A.id "conf" ! type_ "application/json" $ toHtml . decodeUtf8 . encode $ conf + jsonScript "messages" getTranslations + jsonScript "conf" conf + jsonScript "signInError" mbSignInError link ! rel "stylesheet" ! type_ "text/css" ! href "css/reset.css" link ! rel "stylesheet" ! href "css/font-awesome-4.5.0/css/font-awesome.min.css" link ! rel "icon" ! type_ "image/png" ! href "images/icon.png" H.style $ toHtml globalDesign body $ do script ! src "javascripts/main.js" $ "" + +jsonScript :: Json.ToJSON a => Text -> a -> Html +jsonScript scriptId json = + script + ! A.id (toValue scriptId) + ! type_ "application/json" + $ toHtml . decodeUtf8 . encode $ json -- cgit v1.2.3