aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-07-29 16:17:17 +0200
committerJasper Van der Jeugt2020-07-29 16:17:17 +0200
commit780527946548c68bfcfc4d8a99abf06b66cf23c1 (patch)
tree1479ab0ceb1de8016dff7ff462cd565c452a4243
parent72b1de1a28c23cf694ff5f982f0f637afd4ba5bc (diff)
Stub client
-rw-r--r--.gitignore2
-rw-r--r--Makefile22
-rw-r--r--client/elm.json24
-rw-r--r--client/index.html9
-rw-r--r--client/src/Client.elm13
-rw-r--r--server/lib/Cafp/Main/Server.hs3
6 files changed, 67 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index e463d23..a38e4dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
/server/.stack-work/
+/server/assets/
+/client/elm-stuff/
diff --git a/Makefile b/Makefile
index 677f1b6..5c05542 100644
--- a/Makefile
+++ b/Makefile
@@ -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"