Add basic code to serve Elm page.

This commit is contained in:
Danila Fedorin 2018-05-25 12:43:30 -07:00
parent d05ce87808
commit 00d5d19407
4 changed files with 32 additions and 1 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
generate-elm :
cd external/GoUI && elm make Go.elm --output ../../public/js/Go.js

2
external/GoUI vendored

@ -1 +1 @@
Subproject commit 74d844b60f81ef4c4428f577d6b3c960a20f4bb6
Subproject commit e56560bccea5d321e6afec83f0e702478b5270e1

View File

@ -1,6 +1,18 @@
require "./Go/*"
require "kemal"
# TODO: Write documentation for `Go`
module Go
# TODO: Put your code here
end
URL = "localhost"
get "/" do |env|
black = true
id = 1
size = 9
render "src/Go/views/game.ecr"
end
Kemal.run

17
src/Go/views/game.ecr Normal file
View File

@ -0,0 +1,17 @@
<html>
<head>
</head>
<body>
<div id="elm-root"></div>
<script src="/js/Go.js"></script>
<script>
var node = document.getElementById('elm-root')
var app = Elm.Main.embed(node, {
'black' : <%= black %>,
'url' : "<%= "ws://" + URL + ":" + Kemal.config.port.to_s %>",
'id' : <%= id %>,
'size' : <%= size %>
})
</script>
</body>
</html>