Fix building and add configurability
This commit is contained in:
parent
ae81c39db6
commit
717bbaf3bc
3 changed files with 13 additions and 9 deletions
|
@ -16,7 +16,9 @@ config :flag_quiz, FlagQuizWeb.Endpoint,
|
||||||
]
|
]
|
||||||
|
|
||||||
config :flag_quiz,
|
config :flag_quiz,
|
||||||
secret_msg: get_env("SECRET_MSG", "NOT_SET")
|
secret_msg: get_env("SECRET_MSG", "NOT_SET"),
|
||||||
|
q_amount: get_env("Q_AMOUNT", 10, :int),
|
||||||
|
q_time: get_env("Q_TIME", 10, :int)
|
||||||
|
|
||||||
case Config.config_env() do
|
case Config.config_env() do
|
||||||
# PROD ENV CONFIG
|
# PROD ENV CONFIG
|
||||||
|
@ -29,7 +31,7 @@ case Config.config_env() do
|
||||||
config :flag_quiz, FlagQuizWeb.Endpoint,
|
config :flag_quiz, FlagQuizWeb.Endpoint,
|
||||||
cache_static_manifest: "priv/static/cache_manifest.json",
|
cache_static_manifest: "priv/static/cache_manifest.json",
|
||||||
secret_key_base: get_env("SECRET_KEY_BASE"),
|
secret_key_base: get_env("SECRET_KEY_BASE"),
|
||||||
live_view: [signing_salt: get_env("LV_SIGNING_SALT")]
|
live_view: [signing_salt: get_env("LV_SIGNING_SALT")],
|
||||||
|
|
||||||
# Required when using releases
|
# Required when using releases
|
||||||
server: true
|
server: true
|
||||||
|
|
|
@ -3,19 +3,21 @@ defmodule FlagQuizWeb.PageLive do
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@q_amount 10
|
|
||||||
@seconds 10
|
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, _session, socket) do
|
def mount(_params, _session, socket) do
|
||||||
{:ok, assign(socket, in_game?: false, tick_timer: nil, total: @q_amount)}
|
{:ok,
|
||||||
|
assign(socket,
|
||||||
|
in_game?: false,
|
||||||
|
tick_timer: nil,
|
||||||
|
total: Application.get_env(:flag_quiz, :q_amount)
|
||||||
|
)}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_event(event, params, socket)
|
def handle_event(event, params, socket)
|
||||||
|
|
||||||
def handle_event("start-game", _, socket) do
|
def handle_event("start-game", _, socket) do
|
||||||
quiz_set = FlagQuiz.Flags.get_quiz_set(@q_amount)
|
quiz_set = FlagQuiz.Flags.get_quiz_set(Application.get_env(:flag_quiz, :q_amount))
|
||||||
{:noreply, assign(socket, in_game?: true) |> init_flag(quiz_set)}
|
{:noreply, assign(socket, in_game?: true) |> init_flag(quiz_set)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ defmodule FlagQuizWeb.PageLive do
|
||||||
assign(socket,
|
assign(socket,
|
||||||
flag_code: String.downcase(flag_code),
|
flag_code: String.downcase(flag_code),
|
||||||
flag_names: Enum.map(flag_names, &process_name/1),
|
flag_names: Enum.map(flag_names, &process_name/1),
|
||||||
time: @seconds,
|
time: Application.get_env(:flag_quiz, :q_time),
|
||||||
valid?: false,
|
valid?: false,
|
||||||
failed?: false,
|
failed?: false,
|
||||||
victory?: false,
|
victory?: false,
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -7,7 +7,7 @@ defmodule FlagQuiz.MixProject do
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
elixir: "~> 1.11",
|
elixir: "~> 1.11",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
|
compilers: [:phoenix] ++ Mix.compilers(),
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
aliases: aliases(),
|
aliases: aliases(),
|
||||||
deps: deps()
|
deps: deps()
|
||||||
|
|
Loading…
Reference in a new issue