Project restructure for better login
Restructure project into client / server to support a "pure javascript" gleam project to work before the having enough info to launch the server components.
This commit is contained in:
parent
e6851255dc
commit
5663b61906
7 changed files with 198 additions and 76 deletions
|
|
@ -121,6 +121,12 @@ body {
|
|||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.participant-login {
|
||||
border: 2px dashed #005500;
|
||||
padding: 1rem;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.participant-hidden {
|
||||
border: 0px dashed #005500;
|
||||
padding: 1rem;
|
||||
|
|
@ -139,6 +145,12 @@ body {
|
|||
box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
|
||||
}
|
||||
|
||||
.participant-login:hover {
|
||||
border: 2px solid #00ff00;
|
||||
background: rgba(0, 255, 0, 0.05);
|
||||
box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
|
||||
}
|
||||
|
||||
.participant-name {
|
||||
color: #00ff00;
|
||||
font-weight: bold;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,26 @@
|
|||
<script src="/client.js" type="module"></script>
|
||||
<script id="model" type="application/json">
|
||||
[
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
{
|
||||
"id": "abt",
|
||||
"name": "Billettering",
|
||||
"key": "T5X6"
|
||||
},
|
||||
{
|
||||
"id": "slg",
|
||||
"name": "Salg",
|
||||
"key": "6B4T"
|
||||
},
|
||||
{
|
||||
"id": "prs",
|
||||
"name": "Personalisering",
|
||||
"key": "P2Q5"
|
||||
},
|
||||
{
|
||||
"id": "srp",
|
||||
"name": "Support",
|
||||
"key": "P2Q5"
|
||||
}
|
||||
]
|
||||
</script>
|
||||
<link href="/static/layout.css" rel="stylesheet" type="text/css">
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ import backend/statehandler
|
|||
import gleam/bytes_tree
|
||||
import gleam/erlang/application
|
||||
import gleam/erlang/process
|
||||
import gleam/http
|
||||
import gleam/http/request
|
||||
import gleam/http/response.{type Response}
|
||||
import gleam/list
|
||||
import gleam/option.{None}
|
||||
import gleam/result
|
||||
import gleam/string
|
||||
import mist.{type ResponseData, File}
|
||||
import mist.{type ResponseData}
|
||||
import web/components/answerlist
|
||||
import web/components/card
|
||||
import web/components/control
|
||||
|
|
@ -25,29 +26,36 @@ pub fn main() {
|
|||
let assert Ok(room_handler) = roomhandler.initialize(state_handler)
|
||||
|
||||
let assert Ok(_) =
|
||||
fn(req) {
|
||||
case request.path_segments(req) {
|
||||
["lustre", "runtime.mjs"] -> serve_runtime()
|
||||
[] | ["index.html"]-> serve_static("root.html")
|
||||
["client.js"] -> serve_static("client.js")
|
||||
["static", file] -> serve_static(file)
|
||||
["socket", "card", id] ->
|
||||
sockethandler.serve(req, card.component(), id, room_handler)
|
||||
["socket", "control", id] ->
|
||||
sockethandler.serve(req, control.component(), id, room_handler)
|
||||
["socket", "slow", id] ->
|
||||
sockethandler.serve_slow(
|
||||
req,
|
||||
answerlist.component(),
|
||||
id,
|
||||
room_handler,
|
||||
state_handler,
|
||||
)
|
||||
fn(req: request.Request(mist.Connection)) {
|
||||
case req.method {
|
||||
// Filter out Head requests,
|
||||
http.Head ->
|
||||
response.new(200)
|
||||
|> response.set_body(mist.Bytes(bytes_tree.new()))
|
||||
_ ->
|
||||
wisp_mist.handler(
|
||||
router.handle_request(room_handler, state_handler, _),
|
||||
"very_secret",
|
||||
)(req)
|
||||
case request.path_segments(req) {
|
||||
["lustre", "runtime.mjs"] -> serve_runtime()
|
||||
[] | ["index.html"] -> serve_static("root.html")
|
||||
["client.js"] -> serve_static("client.js")
|
||||
["static", file] -> serve_static(file)
|
||||
["socket", "card", id] ->
|
||||
sockethandler.serve(req, card.component(), id, room_handler)
|
||||
["socket", "control", id] ->
|
||||
sockethandler.serve(req, control.component(), id, room_handler)
|
||||
["socket", "slow", id] ->
|
||||
sockethandler.serve_slow(
|
||||
req,
|
||||
answerlist.component(),
|
||||
id,
|
||||
room_handler,
|
||||
state_handler,
|
||||
)
|
||||
_ ->
|
||||
wisp_mist.handler(
|
||||
router.handle_request(room_handler, state_handler, _),
|
||||
"very_secret",
|
||||
)(req)
|
||||
}
|
||||
}
|
||||
}
|
||||
|> mist.new
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue