diff --git a/play_web/README.md b/play_web/README.md index 76e2560..2545f8e 100644 --- a/play_web/README.md +++ b/play_web/README.md @@ -3,7 +3,6 @@ To start your Phoenix server: * Install dependencies with `mix deps.get` - * Create and migrate your database with `mix ecto.setup` * Install Node.js dependencies with `cd assets && npm install` * Start Phoenix endpoint with `mix phx.server` diff --git a/play_web/assets/package.json b/play_web/assets/package.json index eaf01c6..a4ba0e7 100644 --- a/play_web/assets/package.json +++ b/play_web/assets/package.json @@ -6,8 +6,8 @@ "watch": "webpack --mode development --watch" }, "dependencies": { - "phoenix": "file:../../../deps/phoenix", - "phoenix_html": "file:../../../deps/phoenix_html" + "phoenix": "file:../deps/phoenix", + "phoenix_html": "file:../deps/phoenix_html" }, "devDependencies": { "@babel/core": "^7.0.0", diff --git a/play_web/config/config.exs b/play_web/config/config.exs new file mode 100644 index 0000000..157e98f --- /dev/null +++ b/play_web/config/config.exs @@ -0,0 +1,27 @@ +# This file is responsible for configuring your application +# and its dependencies with the aid of the Mix.Config module. +# +# This configuration file is loaded before any dependency and +# is restricted to this project. + +# General application configuration +use Mix.Config + +# Configures the endpoint +config :play_web, PlayWeb.Endpoint, + url: [host: "localhost"], + secret_key_base: "4m4EdLqbm138oXxQyvWMUy8CEiksqoNBPjoHZEwvhnGVML9SrFNCXtE57z6x8EV1", + render_errors: [view: PlayWeb.ErrorView, accepts: ~w(html json)], + pubsub: [name: PlayWeb.PubSub, adapter: Phoenix.PubSub.PG2] + +# Configures Elixir's Logger +config :logger, :console, + format: "$time $metadata[$level] $message\n", + metadata: [:request_id] + +# Use Jason for JSON parsing in Phoenix +config :phoenix, :json_library, Jason + +# Import environment specific config. This must remain at the bottom +# of this file so it overrides the configuration defined above. +import_config "#{Mix.env()}.exs" diff --git a/play_web/config/dev.exs b/play_web/config/dev.exs new file mode 100644 index 0000000..ca82cb0 --- /dev/null +++ b/play_web/config/dev.exs @@ -0,0 +1,67 @@ +use Mix.Config + +# For development, we disable any cache and enable +# debugging and code reloading. +# +# The watchers configuration can be used to run external +# watchers to your application. For example, we use it +# with webpack to recompile .js and .css sources. +config :play_web, PlayWeb.Endpoint, + http: [port: 4000], + debug_errors: true, + code_reloader: true, + check_origin: false, + watchers: [ + node: [ + "node_modules/webpack/bin/webpack.js", + "--mode", + "development", + "--watch-stdin", + cd: Path.expand("../assets", __DIR__) + ] + ] + +# ## SSL Support +# +# In order to use HTTPS in development, a self-signed +# certificate can be generated by running the following +# Mix task: +# +# mix phx.gen.cert +# +# Note that this task requires Erlang/OTP 20 or later. +# Run `mix help phx.gen.cert` for more information. +# +# The `http:` config above can be replaced with: +# +# https: [ +# port: 4001, +# cipher_suite: :strong, +# keyfile: "priv/cert/selfsigned_key.pem", +# certfile: "priv/cert/selfsigned.pem" +# ], +# +# If desired, both `http:` and `https:` keys can be +# configured to run both http and https servers on +# different ports. + +# Watch static and templates for browser reloading. +config :play_web, PlayWeb.Endpoint, + live_reload: [ + patterns: [ + ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", + ~r"priv/gettext/.*(po)$", + ~r"lib/play_web_web/{live,views}/.*(ex)$", + ~r"lib/play_web_web/templates/.*(eex)$" + ] + ] + +# Do not include metadata nor timestamps in development logs +config :logger, :console, format: "[$level] $message\n" + +# Set a higher stacktrace during development. Avoid configuring such +# in production as building large stacktraces may be expensive. +config :phoenix, :stacktrace_depth, 20 + +# Initialize plugs at runtime for faster development compilation +config :phoenix, :plug_init_mode, :runtime diff --git a/play_web/config/prod.exs b/play_web/config/prod.exs new file mode 100644 index 0000000..05cdd19 --- /dev/null +++ b/play_web/config/prod.exs @@ -0,0 +1,55 @@ +use Mix.Config + +# For production, don't forget to configure the url host +# to something meaningful, Phoenix uses this information +# when generating URLs. +# +# Note we also include the path to a cache manifest +# containing the digested version of static files. This +# manifest is generated by the `mix phx.digest` task, +# which you should run after static files are built and +# before starting your production server. +config :play_web, PlayWeb.Endpoint, + url: [host: "example.com", port: 80], + cache_static_manifest: "priv/static/cache_manifest.json" + +# Do not print debug messages in production +config :logger, level: :info + +# ## SSL Support +# +# To get SSL working, you will need to add the `https` key +# to the previous section and set your `:url` port to 443: +# +# config :play_web, PlayWeb.Endpoint, +# ... +# url: [host: "example.com", port: 443], +# https: [ +# :inet6, +# port: 443, +# cipher_suite: :strong, +# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), +# certfile: System.get_env("SOME_APP_SSL_CERT_PATH") +# ] +# +# The `cipher_suite` is set to `:strong` to support only the +# latest and more secure SSL ciphers. This means old browsers +# and clients may not be supported. You can set it to +# `:compatible` for wider support. +# +# `:keyfile` and `:certfile` expect an absolute path to the key +# and cert in disk or a relative path inside priv, for example +# "priv/ssl/server.key". For all supported SSL configuration +# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 +# +# We also recommend setting `force_ssl` in your endpoint, ensuring +# no data is ever sent via http, always redirecting to https: +# +# config :play_web, PlayWeb.Endpoint, +# force_ssl: [hsts: true] +# +# Check `Plug.SSL` for all available options in `force_ssl`. + +# Finally import the config/prod.secret.exs which loads secrets +# and configuration from environment variables. +import_config "prod.secret.exs" diff --git a/play_web/config/prod.secret.exs b/play_web/config/prod.secret.exs new file mode 100644 index 0000000..23157d6 --- /dev/null +++ b/play_web/config/prod.secret.exs @@ -0,0 +1,26 @@ +# In this file, we load production configuration and secrets +# from environment variables. You can also hardcode secrets, +# although such is generally not recommended and you have to +# remember to add this file to your .gitignore. +use Mix.Config + +secret_key_base = + System.get_env("SECRET_KEY_BASE") || + raise """ + environment variable SECRET_KEY_BASE is missing. + You can generate one by calling: mix phx.gen.secret + """ + +config :play_web, PlayWeb.Endpoint, + http: [:inet6, port: String.to_integer(System.get_env("PORT") || "4000")], + secret_key_base: secret_key_base + +# ## Using releases (Elixir v1.9+) +# +# If you are doing OTP releases, you need to instruct Phoenix +# to start each relevant endpoint: +# +# config :play_web, PlayWeb.Endpoint, server: true +# +# Then you can assemble a release by calling `mix release`. +# See `mix help release` for more information. diff --git a/play_web/config/test.exs b/play_web/config/test.exs new file mode 100644 index 0000000..24eb9ca --- /dev/null +++ b/play_web/config/test.exs @@ -0,0 +1,10 @@ +use Mix.Config + +# We don't run a server during test. If one is required, +# you can enable the server option below. +config :play_web, PlayWeb.Endpoint, + http: [port: 4002], + server: false + +# Print only warnings and errors during test +config :logger, level: :warn diff --git a/play_web/mix.exs b/play_web/mix.exs index 0c827dd..fc58634 100644 --- a/play_web/mix.exs +++ b/play_web/mix.exs @@ -5,15 +5,10 @@ defmodule PlayWeb.MixProject do [ app: :play_web, version: "0.1.0", - build_path: "../../_build", - config_path: "../../config/config.exs", - deps_path: "../../deps", - lockfile: "../../mix.lock", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, - aliases: aliases(), deps: deps() ] end @@ -39,7 +34,6 @@ defmodule PlayWeb.MixProject do [ {:phoenix, "~> 1.4.9"}, {:phoenix_pubsub, "~> 1.1"}, - {:phoenix_ecto, "~> 4.0"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:gettext, "~> 0.11"}, @@ -47,12 +41,4 @@ defmodule PlayWeb.MixProject do {:plug_cowboy, "~> 2.0"} ] end - - # Aliases are shortcuts or tasks specific to the current project. - # For example, we extend the test task to create and migrate the database. - # - # See the documentation for `Mix` for more info on aliases. - defp aliases do - [test: ["ecto.create --quiet", "ecto.migrate", "test"]] - end end diff --git a/play_web/priv/gettext/en/LC_MESSAGES/errors.po b/play_web/priv/gettext/en/LC_MESSAGES/errors.po index a589998..cdec3a1 100644 --- a/play_web/priv/gettext/en/LC_MESSAGES/errors.po +++ b/play_web/priv/gettext/en/LC_MESSAGES/errors.po @@ -9,89 +9,3 @@ msgid "" msgstr "" "Language: en\n" - -## From Ecto.Changeset.cast/4 -msgid "can't be blank" -msgstr "" - -## From Ecto.Changeset.unique_constraint/3 -msgid "has already been taken" -msgstr "" - -## From Ecto.Changeset.put_change/3 -msgid "is invalid" -msgstr "" - -## From Ecto.Changeset.validate_acceptance/3 -msgid "must be accepted" -msgstr "" - -## From Ecto.Changeset.validate_format/3 -msgid "has invalid format" -msgstr "" - -## From Ecto.Changeset.validate_subset/3 -msgid "has an invalid entry" -msgstr "" - -## From Ecto.Changeset.validate_exclusion/3 -msgid "is reserved" -msgstr "" - -## From Ecto.Changeset.validate_confirmation/3 -msgid "does not match confirmation" -msgstr "" - -## From Ecto.Changeset.no_assoc_constraint/3 -msgid "is still associated with this entry" -msgstr "" - -msgid "are still associated with this entry" -msgstr "" - -## From Ecto.Changeset.validate_length/3 -msgid "should be %{count} character(s)" -msgid_plural "should be %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have %{count} item(s)" -msgid_plural "should have %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at least %{count} character(s)" -msgid_plural "should be at least %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at least %{count} item(s)" -msgid_plural "should have at least %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at most %{count} character(s)" -msgid_plural "should be at most %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at most %{count} item(s)" -msgid_plural "should have at most %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -## From Ecto.Changeset.validate_number/3 -msgid "must be less than %{number}" -msgstr "" - -msgid "must be greater than %{number}" -msgstr "" - -msgid "must be less than or equal to %{number}" -msgstr "" - -msgid "must be greater than or equal to %{number}" -msgstr "" - -msgid "must be equal to %{number}" -msgstr "" diff --git a/play_web/priv/gettext/errors.pot b/play_web/priv/gettext/errors.pot index 39a220b..d6f47fa 100644 --- a/play_web/priv/gettext/errors.pot +++ b/play_web/priv/gettext/errors.pot @@ -8,88 +8,3 @@ ## date. Leave `msgstr`s empty as changing them here has no ## effect: edit them in PO (`.po`) files instead. -## From Ecto.Changeset.cast/4 -msgid "can't be blank" -msgstr "" - -## From Ecto.Changeset.unique_constraint/3 -msgid "has already been taken" -msgstr "" - -## From Ecto.Changeset.put_change/3 -msgid "is invalid" -msgstr "" - -## From Ecto.Changeset.validate_acceptance/3 -msgid "must be accepted" -msgstr "" - -## From Ecto.Changeset.validate_format/3 -msgid "has invalid format" -msgstr "" - -## From Ecto.Changeset.validate_subset/3 -msgid "has an invalid entry" -msgstr "" - -## From Ecto.Changeset.validate_exclusion/3 -msgid "is reserved" -msgstr "" - -## From Ecto.Changeset.validate_confirmation/3 -msgid "does not match confirmation" -msgstr "" - -## From Ecto.Changeset.no_assoc_constraint/3 -msgid "is still associated with this entry" -msgstr "" - -msgid "are still associated with this entry" -msgstr "" - -## From Ecto.Changeset.validate_length/3 -msgid "should be %{count} character(s)" -msgid_plural "should be %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have %{count} item(s)" -msgid_plural "should have %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at least %{count} character(s)" -msgid_plural "should be at least %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at least %{count} item(s)" -msgid_plural "should have at least %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at most %{count} character(s)" -msgid_plural "should be at most %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at most %{count} item(s)" -msgid_plural "should have at most %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -## From Ecto.Changeset.validate_number/3 -msgid "must be less than %{number}" -msgstr "" - -msgid "must be greater than %{number}" -msgstr "" - -msgid "must be less than or equal to %{number}" -msgstr "" - -msgid "must be greater than or equal to %{number}" -msgstr "" - -msgid "must be equal to %{number}" -msgstr "" diff --git a/play_web/test/support/channel_case.ex b/play_web/test/support/channel_case.ex index cfceecf..030909a 100644 --- a/play_web/test/support/channel_case.ex +++ b/play_web/test/support/channel_case.ex @@ -25,13 +25,7 @@ defmodule PlayWeb.ChannelCase do end end - setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(PlayWeb.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(PlayWeb.Repo, {:shared, self()}) - end - + setup _tags do :ok end end diff --git a/play_web/test/support/conn_case.ex b/play_web/test/support/conn_case.ex index 49c4b11..69d450b 100644 --- a/play_web/test/support/conn_case.ex +++ b/play_web/test/support/conn_case.ex @@ -26,13 +26,7 @@ defmodule PlayWeb.ConnCase do end end - setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(PlayWeb.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(PlayWeb.Repo, {:shared, self()}) - end - + setup _tags do {:ok, conn: Phoenix.ConnTest.build_conn()} end end diff --git a/play_web/test/test_helper.exs b/play_web/test/test_helper.exs index f5b3ed2..869559e 100644 --- a/play_web/test/test_helper.exs +++ b/play_web/test/test_helper.exs @@ -1,2 +1 @@ ExUnit.start() -Ecto.Adapters.SQL.Sandbox.mode(PlayWeb.Repo, :manual)