-
Notifications
You must be signed in to change notification settings - Fork 3
/
liveview_playground.ex
37 lines (28 loc) · 1.04 KB
/
liveview_playground.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
defmodule LiveviewPlayground do
@moduledoc """
Documentation for `LiveviewPlayground`.
"""
@doc """
Starts liveview playground
All options are optional. They are:
* `:router` - the Phoenix.Router module
* `:endpoint` - the Phoenix.Endpoint module
* `:script` - list of binaries that will be included as scripts on the layout <head>
"""
def start(opts \\ []) do
router = Keyword.get(opts, :router, LiveviewPlayground.Router)
endpoint = Keyword.get(opts, :endpoint, LiveviewPlayground.Endpoint)
scripts = Keyword.get(opts, :scripts, [])
Application.put_env(:liveview_playground, endpoint,
http: [ip: {127, 0, 0, 1}, port: 4000],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64),
router: router
)
Application.put_env(:liveview_playground, :router, router)
Application.put_env(:liveview_playground, :scripts, scripts)
{:ok, _} = Supervisor.start_link([endpoint], strategy: :one_for_one)
Process.sleep(:infinity)
end
end