From d6265dd7f44538858989c1fe6837e1cafc489455 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 29 Jul 2020 16:33:53 +0200 Subject: Further client stub --- client/index.html | 5 +++++ client/src/Client.elm | 16 ++++++++++++---- server/lib/Cafp/Main/Server.hs | 6 +++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/client/index.html b/client/index.html index 8ac103a..3803738 100644 --- a/client/index.html +++ b/client/index.html @@ -5,5 +5,10 @@ Client +
+ + diff --git a/client/src/Client.elm b/client/src/Client.elm index 1db70c7..77168c1 100644 --- a/client/src/Client.elm +++ b/client/src/Client.elm @@ -3,11 +3,19 @@ module Client exposing (main) import Browser import Html -main : Program () () msg -main = Browser.element - { init = \() -> ((), Cmd.none) +type Message + = Ignore + +main : Program () () Message +main = Browser.application + { init = \() url key -> ((), Cmd.none) , update = \_ model -> (model, Cmd.none) , subscriptions = \_ -> Sub.none - , view = \model -> Html.h1 [] [Html.text "Hi"] + , view = \model -> + { title = "Client" + , body = [Html.h1 [] [Html.text "Hi"]] + } + , onUrlChange = \url -> Ignore + , onUrlRequest = \urlRequest -> Ignore } diff --git a/server/lib/Cafp/Main/Server.hs b/server/lib/Cafp/Main/Server.hs index 5de7403..fdace52 100644 --- a/server/lib/Cafp/Main/Server.hs +++ b/server/lib/Cafp/Main/Server.hs @@ -22,9 +22,13 @@ newServer = Server <$> newTVar HMS.empty main :: IO () main = Scotty.scotty 3000 $ do - Scotty.get "/rooms/:id" $ do + Scotty.get "/rooms/:id/" $ do roomId <- Scotty.param "id" when (T.length roomId < 6) $ Scotty.raise "Room ID should be at least 6 characters" Scotty.setHeader "Content-Type" "text/html" Scotty.file "assets/client.html" + + Scotty.get "/assets/client.js" $ do + Scotty.setHeader "Content-Type" "application/JavaScript" + Scotty.file "assets/client.js" -- cgit v1.2.3