diff options
author | Jasper Van der Jeugt | 2020-07-29 16:17:17 +0200 |
---|---|---|
committer | Jasper Van der Jeugt | 2020-07-29 16:17:17 +0200 |
commit | 780527946548c68bfcfc4d8a99abf06b66cf23c1 (patch) | |
tree | 1479ab0ceb1de8016dff7ff462cd565c452a4243 | |
parent | 72b1de1a28c23cf694ff5f982f0f637afd4ba5bc (diff) |
Stub client
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 22 | ||||
-rw-r--r-- | client/elm.json | 24 | ||||
-rw-r--r-- | client/index.html | 9 | ||||
-rw-r--r-- | client/src/Client.elm | 13 | ||||
-rw-r--r-- | server/lib/Cafp/Main/Server.hs | 3 |
6 files changed, 67 insertions, 6 deletions
@@ -1 +1,3 @@ /server/.stack-work/ +/server/assets/ +/client/elm-stuff/ @@ -1,12 +1,24 @@ HS_SOURCES=$(shell find server/lib/ server/src -name '*.hs') -ELM_MESSAGES_MODULE=client/src/Messages.elm +ELM_SOURCES=$(shell find client/src -name '*.elm') +ELM_MESSAGES_SOURCE=client/src/Messages.elm .PHONY: build -build: - cd server && stack build +build: server/assets/client.js server/assets/client.html server: build cd server && stack exec cafp-server -$(ELM_MESSAGES_MODULE): $(HS_SOURCES) - (cd server && stack exec cafp-generate-elm-types) >$(ELM_MESSAGES_MODULE) +.PHONY: stack_build +stack_build: $(HS_SOURCES) + (cd server && stack build) + +$(ELM_MESSAGES_SOURCE): stack_build + (cd server && stack exec cafp-generate-elm-types) >$(ELM_MESSAGES_SOURCE) + +server/assets/client.js: $(ELM_MESSAGES_SOURCE) $(ELM_SOURCES) + mkdir -p server/assets + cd client && elm make src/Client.elm --output=../server/assets/client.js + +server/assets/client.html: client/index.html + mkdir -p server/assets + cp client/index.html $@ diff --git a/client/elm.json b/client/elm.json new file mode 100644 index 0000000..dea3450 --- /dev/null +++ b/client/elm.json @@ -0,0 +1,24 @@ +{ + "type": "application", + "source-directories": [ + "src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0" + }, + "indirect": { + "elm/json": "1.1.3", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.2" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..8ac103a --- /dev/null +++ b/client/index.html @@ -0,0 +1,9 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="UTF-8"> + <title>Client</title> +</head> + <body> + </body> +</html> diff --git a/client/src/Client.elm b/client/src/Client.elm new file mode 100644 index 0000000..1db70c7 --- /dev/null +++ b/client/src/Client.elm @@ -0,0 +1,13 @@ +module Client exposing (main) + +import Browser +import Html + +main : Program () () msg +main = Browser.element + { init = \() -> ((), Cmd.none) + , update = \_ model -> (model, Cmd.none) + , subscriptions = \_ -> Sub.none + , view = \model -> Html.h1 [] [Html.text "Hi"] + } + diff --git a/server/lib/Cafp/Main/Server.hs b/server/lib/Cafp/Main/Server.hs index a2561a3..5de7403 100644 --- a/server/lib/Cafp/Main/Server.hs +++ b/server/lib/Cafp/Main/Server.hs @@ -26,4 +26,5 @@ main = Scotty.scotty 3000 $ do roomId <- Scotty.param "id" when (T.length roomId < 6) $ Scotty.raise "Room ID should be at least 6 characters" - Scotty.html $ "<h1>Scotty, " <> TL.fromStrict roomId <> " me up!</h1>" + Scotty.setHeader "Content-Type" "text/html" + Scotty.file "assets/client.html" |