diff --git a/.gitignore b/.gitignore index 9a8075b..d200850 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,7 @@ erl_crash.dump /tmp/ # Ignore package tarball (built via "mix hex.build"). -twenty_fourty_eight-*.tar +twenty_forty_eight-*.tar # Ignore assets that are produced by build tools. /priv/static/assets/ diff --git a/README.md b/README.md index f74f7c3..e7fde87 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TwentyFourtyEight +# TwentyFortyEight To start your Phoenix server: diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index e26e2a4..fb449f9 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -8,8 +8,8 @@ const path = require("path") module.exports = { content: [ "./js/**/*.js", - "../lib/twenty_fourty_eight_web.ex", - "../lib/twenty_fourty_eight_web/**/*.*ex" + "../lib/twenty_forty_eight_web.ex", + "../lib/twenty_forty_eight_web/**/*.*ex" ], theme: { extend: { diff --git a/config/config.exs b/config/config.exs index bbe8040..ce31ca0 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,19 +7,19 @@ # General application configuration import Config -config :twenty_fourty_eight, - ecto_repos: [TwentyFourtyEight.Repo], +config :twenty_forty_eight, + ecto_repos: [TwentyFortyEight.Repo], generators: [timestamp_type: :utc_datetime] # Configures the endpoint -config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, +config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, url: [host: "localhost"], adapter: Phoenix.Endpoint.Cowboy2Adapter, render_errors: [ - formats: [html: TwentyFourtyEightWeb.ErrorHTML, json: TwentyFourtyEightWeb.ErrorJSON], + formats: [html: TwentyFortyEightWeb.ErrorHTML, json: TwentyFortyEightWeb.ErrorJSON], layout: false ], - pubsub_server: TwentyFourtyEight.PubSub, + pubsub_server: TwentyFortyEight.PubSub, live_view: [signing_salt: "SipBW+C+"] # Configures the mailer @@ -29,7 +29,7 @@ config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, # # For production it's recommended to configure a different adapter # at the `config/runtime.exs`. -config :twenty_fourty_eight, TwentyFourtyEight.Mailer, adapter: Swoosh.Adapters.Local +config :twenty_forty_eight, TwentyFortyEight.Mailer, adapter: Swoosh.Adapters.Local # Configure esbuild (the version is required) config :esbuild, diff --git a/config/dev.exs b/config/dev.exs index 4590088..d3b15c0 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,11 +1,11 @@ import Config # Configure your database -config :twenty_fourty_eight, TwentyFourtyEight.Repo, +config :twenty_forty_eight, TwentyFortyEight.Repo, username: "postgres", password: "postgres", hostname: "localhost", - database: "twenty_fourty_eight_dev", + database: "twenty_forty_eight_dev", stacktrace: true, show_sensitive_data_on_connection_error: true, pool_size: 10 @@ -16,7 +16,7 @@ config :twenty_fourty_eight, TwentyFourtyEight.Repo, # The watchers configuration can be used to run external # watchers to your application. For example, we can use it # to bundle .js and .css sources. -config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, +config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, # Binding to loopback ipv4 address prevents access from other machines. # Change to `ip: {0, 0, 0, 0}` to allow access from other machines. http: [ip: {127, 0, 0, 1}, port: 4000], @@ -53,17 +53,17 @@ config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, # different ports. # Watch static and templates for browser reloading. -config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, +config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", - ~r"lib/twenty_fourty_eight_web/(controllers|live|components)/.*(ex|heex)$" + ~r"lib/twenty_forty_eight_web/(controllers|live|components)/.*(ex|heex)$" ] ] # Enable dev routes for dashboard and mailbox -config :twenty_fourty_eight, dev_routes: true +config :twenty_forty_eight, dev_routes: true # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" diff --git a/config/prod.exs b/config/prod.exs index 5ac828a..cfa57ef 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -5,11 +5,11 @@ import Config # manifest is generated by the `mix assets.deploy` task, # which you should run after static files are built and # before starting your production server. -config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, +config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" # Configures Swoosh API Client -config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: TwentyFourtyEight.Finch +config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: TwentyFortyEight.Finch # Disable Swoosh Local Memory Storage config :swoosh, local: false diff --git a/config/runtime.exs b/config/runtime.exs index 972b483..a6d9ff5 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -12,12 +12,12 @@ import Config # If you use `mix release`, you need to explicitly enable the server # by passing the PHX_SERVER=true when you start it: # -# PHX_SERVER=true bin/twenty_fourty_eight start +# PHX_SERVER=true bin/twenty_forty_eight start # # Alternatively, you can use `mix phx.gen.release` to generate a `bin/server` # script that automatically sets the env var above. if System.get_env("PHX_SERVER") do - config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, server: true + config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, server: true end if config_env() == :prod do @@ -30,7 +30,7 @@ if config_env() == :prod do maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: [] - config :twenty_fourty_eight, TwentyFourtyEight.Repo, + config :twenty_forty_eight, TwentyFortyEight.Repo, # ssl: true, url: database_url, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), @@ -51,9 +51,9 @@ if config_env() == :prod do host = System.get_env("PHX_HOST") || "example.com" port = String.to_integer(System.get_env("PORT") || "4000") - config :twenty_fourty_eight, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") + config :twenty_forty_eight, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") - config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, + config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, url: [host: host, port: 443, scheme: "https"], http: [ # Enable IPv6 and bind on all interfaces. @@ -70,7 +70,7 @@ if config_env() == :prod do # To get SSL working, you will need to add the `https` key # to your endpoint configuration: # - # config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, + # config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, # https: [ # ..., # port: 443, @@ -92,7 +92,7 @@ if config_env() == :prod do # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # - # config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, + # config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. @@ -103,7 +103,7 @@ if config_env() == :prod do # Also, you may need to configure the Swoosh API client of your choice if you # are not using SMTP. Here is an example of the configuration: # - # config :twenty_fourty_eight, TwentyFourtyEight.Mailer, + # config :twenty_forty_eight, TwentyFortyEight.Mailer, # adapter: Swoosh.Adapters.Mailgun, # api_key: System.get_env("MAILGUN_API_KEY"), # domain: System.get_env("MAILGUN_DOMAIN") diff --git a/config/test.exs b/config/test.exs index 3bb18eb..3ed1e62 100644 --- a/config/test.exs +++ b/config/test.exs @@ -5,23 +5,23 @@ import Config # The MIX_TEST_PARTITION environment variable can be used # to provide built-in test partitioning in CI environment. # Run `mix help test` for more information. -config :twenty_fourty_eight, TwentyFourtyEight.Repo, +config :twenty_forty_eight, TwentyFortyEight.Repo, username: "postgres", password: "postgres", hostname: "localhost", - database: "twenty_fourty_eight_test#{System.get_env("MIX_TEST_PARTITION")}", + database: "twenty_forty_eight_test#{System.get_env("MIX_TEST_PARTITION")}", pool: Ecto.Adapters.SQL.Sandbox, pool_size: 10 # We don't run a server during test. If one is required, # you can enable the server option below. -config :twenty_fourty_eight, TwentyFourtyEightWeb.Endpoint, +config :twenty_forty_eight, TwentyFortyEightWeb.Endpoint, http: [ip: {127, 0, 0, 1}, port: 4002], secret_key_base: "EFU3MRLY/qeAOoxVCm27dDdEXF/HkcIqmEQjkqOXFVihcLgQe2LGBpRqaPs7BqCf", server: false # In test we don't send emails. -config :twenty_fourty_eight, TwentyFourtyEight.Mailer, adapter: Swoosh.Adapters.Test +config :twenty_forty_eight, TwentyFortyEight.Mailer, adapter: Swoosh.Adapters.Test # Disable swoosh api client as it is only required for production adapters. config :swoosh, :api_client, false diff --git a/index.html b/index.html index 9cbe346..0ccfca8 100644 --- a/index.html +++ b/index.html @@ -114,7 +114,7 @@ -

Twenty Fourty Eight.

+

Twenty Forty Eight.

Score 934
diff --git a/lib/twenty_fourty_eight.ex b/lib/twenty_forty_eight.ex similarity index 65% rename from lib/twenty_fourty_eight.ex rename to lib/twenty_forty_eight.ex index b2283b5..e8eae04 100644 --- a/lib/twenty_fourty_eight.ex +++ b/lib/twenty_forty_eight.ex @@ -1,6 +1,6 @@ -defmodule TwentyFourtyEight do +defmodule TwentyFortyEight do @moduledoc """ - TwentyFourtyEight keeps the contexts that define your domain + TwentyFortyEight keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless diff --git a/lib/twenty_fourty_eight/application.ex b/lib/twenty_forty_eight/application.ex similarity index 50% rename from lib/twenty_fourty_eight/application.ex rename to lib/twenty_forty_eight/application.ex index c9d7041..744a2cc 100644 --- a/lib/twenty_fourty_eight/application.ex +++ b/lib/twenty_forty_eight/application.ex @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEight.Application do +defmodule TwentyFortyEight.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false @@ -8,22 +8,22 @@ defmodule TwentyFourtyEight.Application do @impl true def start(_type, _args) do children = [ - TwentyFourtyEightWeb.Telemetry, - TwentyFourtyEight.Repo, + TwentyFortyEightWeb.Telemetry, + TwentyFortyEight.Repo, {DNSCluster, - query: Application.get_env(:twenty_fourty_eight, :dns_cluster_query) || :ignore}, - {Phoenix.PubSub, name: TwentyFourtyEight.PubSub}, + query: Application.get_env(:twenty_forty_eight, :dns_cluster_query) || :ignore}, + {Phoenix.PubSub, name: TwentyFortyEight.PubSub}, # Start the Finch HTTP client for sending emails - {Finch, name: TwentyFourtyEight.Finch}, - {Registry, keys: :unique, name: TwentyFourtyEight.Game.Registry}, - {DynamicSupervisor, name: TwentyFourtyEight.Game.Supervisor, strategy: :one_for_one}, + {Finch, name: TwentyFortyEight.Finch}, + {Registry, keys: :unique, name: TwentyFortyEight.Game.Registry}, + {DynamicSupervisor, name: TwentyFortyEight.Game.Supervisor, strategy: :one_for_one}, # Start to serve requests, typically the last entry - TwentyFourtyEightWeb.Endpoint + TwentyFortyEightWeb.Endpoint ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: TwentyFourtyEight.Supervisor] + opts = [strategy: :one_for_one, name: TwentyFortyEight.Supervisor] Supervisor.start_link(children, opts) end @@ -31,7 +31,7 @@ defmodule TwentyFourtyEight.Application do # whenever the application is updated. @impl true def config_change(changed, _new, removed) do - TwentyFourtyEightWeb.Endpoint.config_change(changed, removed) + TwentyFortyEightWeb.Endpoint.config_change(changed, removed) :ok end end diff --git a/lib/twenty_fourty_eight/game/engine.ex b/lib/twenty_forty_eight/game/engine.ex similarity index 99% rename from lib/twenty_fourty_eight/game/engine.ex rename to lib/twenty_forty_eight/game/engine.ex index 686689e..4a2a0d6 100644 --- a/lib/twenty_fourty_eight/game/engine.ex +++ b/lib/twenty_forty_eight/game/engine.ex @@ -1,6 +1,6 @@ -defmodule TwentyFourtyEight.Game.Engine do +defmodule TwentyFortyEight.Game.Engine do # TODO - # 1. rename Fourty -> Forty + # 1. rename Forty -> Forty # 2. mark a game as lost if, at the start of a turn, the board is exhausted and no move would change that # 3. factor out board creation into a separate module. the engine's state can then be reduced (doesn't need stuff only required to create the board.) # 4. fix obstacle creation and make it configurable. diff --git a/lib/twenty_fourty_eight/game/game.ex b/lib/twenty_forty_eight/game/game.ex similarity index 95% rename from lib/twenty_fourty_eight/game/game.ex rename to lib/twenty_forty_eight/game/game.ex index 17aeb69..014fe3a 100644 --- a/lib/twenty_fourty_eight/game/game.ex +++ b/lib/twenty_forty_eight/game/game.ex @@ -1,8 +1,8 @@ -defmodule TwentyFourtyEight.Game.Game do +defmodule TwentyFortyEight.Game.Game do use Ecto.Schema import Ecto.Changeset - alias TwentyFourtyEight.Repo + alias TwentyFortyEight.Repo @slug_length 8 @slug_alphabet String.graphemes( diff --git a/lib/twenty_fourty_eight/game/manager.ex b/lib/twenty_forty_eight/game/manager.ex similarity index 86% rename from lib/twenty_fourty_eight/game/manager.ex rename to lib/twenty_forty_eight/game/manager.ex index edd161f..9b173c5 100644 --- a/lib/twenty_fourty_eight/game/manager.ex +++ b/lib/twenty_forty_eight/game/manager.ex @@ -1,10 +1,10 @@ -defmodule TwentyFourtyEight.Game.Manager do +defmodule TwentyFortyEight.Game.Manager do use GenServer, restart: :transient - alias TwentyFourtyEight.Game.Engine + alias TwentyFortyEight.Game.Engine - @registry TwentyFourtyEight.Game.Registry - @supervisor TwentyFourtyEight.Game.Supervisor + @registry TwentyFortyEight.Game.Registry + @supervisor TwentyFortyEight.Game.Supervisor def get_game(name, state) when is_binary(name) do case Registry.lookup(@registry, name) do diff --git a/lib/twenty_forty_eight/mailer.ex b/lib/twenty_forty_eight/mailer.ex new file mode 100644 index 0000000..136bda4 --- /dev/null +++ b/lib/twenty_forty_eight/mailer.ex @@ -0,0 +1,3 @@ +defmodule TwentyFortyEight.Mailer do + use Swoosh.Mailer, otp_app: :twenty_forty_eight +end diff --git a/lib/twenty_forty_eight/repo.ex b/lib/twenty_forty_eight/repo.ex new file mode 100644 index 0000000..0592f44 --- /dev/null +++ b/lib/twenty_forty_eight/repo.ex @@ -0,0 +1,5 @@ +defmodule TwentyFortyEight.Repo do + use Ecto.Repo, + otp_app: :twenty_forty_eight, + adapter: Ecto.Adapters.Postgres +end diff --git a/lib/twenty_fourty_eight_web.ex b/lib/twenty_forty_eight_web.ex similarity index 80% rename from lib/twenty_fourty_eight_web.ex rename to lib/twenty_forty_eight_web.ex index c0347c1..ec1e7d8 100644 --- a/lib/twenty_fourty_eight_web.ex +++ b/lib/twenty_forty_eight_web.ex @@ -1,12 +1,12 @@ -defmodule TwentyFourtyEightWeb do +defmodule TwentyFortyEightWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, components, channels, and so on. This can be used in your application as: - use TwentyFourtyEightWeb, :controller - use TwentyFourtyEightWeb, :html + use TwentyFortyEightWeb, :controller + use TwentyFortyEightWeb, :html The definitions below will be executed for every controller, component, etc, so keep them short and clean, focused @@ -40,10 +40,10 @@ defmodule TwentyFourtyEightWeb do quote do use Phoenix.Controller, formats: [:html, :json], - layouts: [html: TwentyFourtyEightWeb.Layouts] + layouts: [html: TwentyFortyEightWeb.Layouts] import Plug.Conn - import TwentyFourtyEightWeb.Gettext + import TwentyFortyEightWeb.Gettext unquote(verified_routes()) end @@ -52,7 +52,7 @@ defmodule TwentyFourtyEightWeb do def live_view do quote do use Phoenix.LiveView, - layout: {TwentyFourtyEightWeb.Layouts, :app} + layout: {TwentyFortyEightWeb.Layouts, :app} unquote(html_helpers()) end @@ -84,8 +84,8 @@ defmodule TwentyFourtyEightWeb do # HTML escaping functionality import Phoenix.HTML # Core UI components and translation - import TwentyFourtyEightWeb.CoreComponents - import TwentyFourtyEightWeb.Gettext + import TwentyFortyEightWeb.CoreComponents + import TwentyFortyEightWeb.Gettext # Shortcut for generating JS commands alias Phoenix.LiveView.JS @@ -98,9 +98,9 @@ defmodule TwentyFourtyEightWeb do def verified_routes do quote do use Phoenix.VerifiedRoutes, - endpoint: TwentyFourtyEightWeb.Endpoint, - router: TwentyFourtyEightWeb.Router, - statics: TwentyFourtyEightWeb.static_paths() + endpoint: TwentyFortyEightWeb.Endpoint, + router: TwentyFortyEightWeb.Router, + statics: TwentyFortyEightWeb.static_paths() end end diff --git a/lib/twenty_fourty_eight_web/components/core_components.ex b/lib/twenty_forty_eight_web/components/core_components.ex similarity index 98% rename from lib/twenty_fourty_eight_web/components/core_components.ex rename to lib/twenty_forty_eight_web/components/core_components.ex index 7d9954c..152fd4f 100644 --- a/lib/twenty_fourty_eight_web/components/core_components.ex +++ b/lib/twenty_forty_eight_web/components/core_components.ex @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEightWeb.CoreComponents do +defmodule TwentyFortyEightWeb.CoreComponents do @moduledoc """ Provides core UI components. @@ -17,7 +17,7 @@ defmodule TwentyFourtyEightWeb.CoreComponents do use Phoenix.Component alias Phoenix.LiveView.JS - import TwentyFourtyEightWeb.Gettext + import TwentyFortyEightWeb.Gettext @doc """ Renders a modal. @@ -659,9 +659,9 @@ defmodule TwentyFourtyEightWeb.CoreComponents do # with our gettext backend as first argument. Translations are # available in the errors.po file (as we use the "errors" domain). if count = opts[:count] do - Gettext.dngettext(TwentyFourtyEightWeb.Gettext, "errors", msg, msg, count, opts) + Gettext.dngettext(TwentyFortyEightWeb.Gettext, "errors", msg, msg, count, opts) else - Gettext.dgettext(TwentyFourtyEightWeb.Gettext, "errors", msg, opts) + Gettext.dgettext(TwentyFortyEightWeb.Gettext, "errors", msg, opts) end end diff --git a/lib/twenty_forty_eight_web/components/layouts.ex b/lib/twenty_forty_eight_web/components/layouts.ex new file mode 100644 index 0000000..19a4900 --- /dev/null +++ b/lib/twenty_forty_eight_web/components/layouts.ex @@ -0,0 +1,5 @@ +defmodule TwentyFortyEightWeb.Layouts do + use TwentyFortyEightWeb, :html + + embed_templates "layouts/*" +end diff --git a/lib/twenty_fourty_eight_web/components/layouts/app.html.heex b/lib/twenty_forty_eight_web/components/layouts/app.html.heex similarity index 100% rename from lib/twenty_fourty_eight_web/components/layouts/app.html.heex rename to lib/twenty_forty_eight_web/components/layouts/app.html.heex diff --git a/lib/twenty_fourty_eight_web/components/layouts/root.html.heex b/lib/twenty_forty_eight_web/components/layouts/root.html.heex similarity index 83% rename from lib/twenty_fourty_eight_web/components/layouts/root.html.heex rename to lib/twenty_forty_eight_web/components/layouts/root.html.heex index 48a0d93..9c289a5 100644 --- a/lib/twenty_fourty_eight_web/components/layouts/root.html.heex +++ b/lib/twenty_forty_eight_web/components/layouts/root.html.heex @@ -5,14 +5,14 @@ <.live_title> - <%= assigns[:page_title] || "TwentyFourtyEight" %> + <%= assigns[:page_title] || "TwentyFortyEight" %> -

Twenty Fourty Eight.

+

Twenty Forty Eight.

<.flash_group flash={@flash} /> <%= @inner_content %> diff --git a/lib/twenty_fourty_eight_web/controllers/error_html.ex b/lib/twenty_forty_eight_web/controllers/error_html.ex similarity index 65% rename from lib/twenty_fourty_eight_web/controllers/error_html.ex rename to lib/twenty_forty_eight_web/controllers/error_html.ex index f9f85dc..97fb67a 100644 --- a/lib/twenty_fourty_eight_web/controllers/error_html.ex +++ b/lib/twenty_forty_eight_web/controllers/error_html.ex @@ -1,12 +1,12 @@ -defmodule TwentyFourtyEightWeb.ErrorHTML do - use TwentyFourtyEightWeb, :html +defmodule TwentyFortyEightWeb.ErrorHTML do + use TwentyFortyEightWeb, :html # If you want to customize your error pages, # uncomment the embed_templates/1 call below # and add pages to the error directory: # - # * lib/twenty_fourty_eight_web/controllers/error_html/404.html.heex - # * lib/twenty_fourty_eight_web/controllers/error_html/500.html.heex + # * lib/twenty_forty_eight_web/controllers/error_html/404.html.heex + # * lib/twenty_forty_eight_web/controllers/error_html/500.html.heex # # embed_templates "error_html/*" diff --git a/lib/twenty_fourty_eight_web/controllers/error_json.ex b/lib/twenty_forty_eight_web/controllers/error_json.ex similarity index 91% rename from lib/twenty_fourty_eight_web/controllers/error_json.ex rename to lib/twenty_forty_eight_web/controllers/error_json.ex index d7d6ad9..6224c1d 100644 --- a/lib/twenty_fourty_eight_web/controllers/error_json.ex +++ b/lib/twenty_forty_eight_web/controllers/error_json.ex @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEightWeb.ErrorJSON do +defmodule TwentyFortyEightWeb.ErrorJSON do # If you want to customize a particular status code, # you may add your own clauses, such as: # diff --git a/lib/twenty_fourty_eight_web/controllers/game_controller.ex b/lib/twenty_forty_eight_web/controllers/game_controller.ex similarity index 75% rename from lib/twenty_fourty_eight_web/controllers/game_controller.ex rename to lib/twenty_forty_eight_web/controllers/game_controller.ex index d8f3355..2ebf18a 100644 --- a/lib/twenty_fourty_eight_web/controllers/game_controller.ex +++ b/lib/twenty_forty_eight_web/controllers/game_controller.ex @@ -1,7 +1,7 @@ -defmodule TwentyFourtyEightWeb.GameController do - use TwentyFourtyEightWeb, :controller +defmodule TwentyFortyEightWeb.GameController do + use TwentyFortyEightWeb, :controller - alias TwentyFourtyEight.Game.Game + alias TwentyFortyEight.Game.Game def new(conn, _params) do changeset = Game.changeset(%{}) diff --git a/lib/twenty_fourty_eight_web/controllers/game_html.ex b/lib/twenty_forty_eight_web/controllers/game_html.ex similarity index 91% rename from lib/twenty_fourty_eight_web/controllers/game_html.ex rename to lib/twenty_forty_eight_web/controllers/game_html.ex index f2cc1be..fcc2bdf 100644 --- a/lib/twenty_fourty_eight_web/controllers/game_html.ex +++ b/lib/twenty_forty_eight_web/controllers/game_html.ex @@ -1,5 +1,5 @@ -defmodule TwentyFourtyEightWeb.GameHTML do - use TwentyFourtyEightWeb, :html +defmodule TwentyFortyEightWeb.GameHTML do + use TwentyFortyEightWeb, :html def new(assigns) do ~H""" diff --git a/lib/twenty_fourty_eight_web/endpoint.ex b/lib/twenty_forty_eight_web/endpoint.ex similarity index 80% rename from lib/twenty_fourty_eight_web/endpoint.ex rename to lib/twenty_forty_eight_web/endpoint.ex index f45e55e..563f491 100644 --- a/lib/twenty_fourty_eight_web/endpoint.ex +++ b/lib/twenty_forty_eight_web/endpoint.ex @@ -1,12 +1,12 @@ -defmodule TwentyFourtyEightWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :twenty_fourty_eight +defmodule TwentyFortyEightWeb.Endpoint do + use Phoenix.Endpoint, otp_app: :twenty_forty_eight # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, - key: "_twenty_fourty_eight_key", + key: "_twenty_forty_eight_key", signing_salt: "wp9e8fHq", same_site: "Lax" ] @@ -19,9 +19,9 @@ defmodule TwentyFourtyEightWeb.Endpoint do # when deploying your static files in production. plug Plug.Static, at: "/", - from: :twenty_fourty_eight, + from: :twenty_forty_eight, gzip: false, - only: TwentyFourtyEightWeb.static_paths() + only: TwentyFortyEightWeb.static_paths() # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. @@ -29,7 +29,7 @@ defmodule TwentyFourtyEightWeb.Endpoint do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader - plug Phoenix.Ecto.CheckRepoStatus, otp_app: :twenty_fourty_eight + plug Phoenix.Ecto.CheckRepoStatus, otp_app: :twenty_forty_eight end plug Phoenix.LiveDashboard.RequestLogger, @@ -47,5 +47,5 @@ defmodule TwentyFourtyEightWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options - plug TwentyFourtyEightWeb.Router + plug TwentyFortyEightWeb.Router end diff --git a/lib/twenty_fourty_eight_web/gettext.ex b/lib/twenty_forty_eight_web/gettext.ex similarity index 82% rename from lib/twenty_fourty_eight_web/gettext.ex rename to lib/twenty_forty_eight_web/gettext.ex index 1db58b7..5ce6534 100644 --- a/lib/twenty_fourty_eight_web/gettext.ex +++ b/lib/twenty_forty_eight_web/gettext.ex @@ -1,11 +1,11 @@ -defmodule TwentyFourtyEightWeb.Gettext do +defmodule TwentyFortyEightWeb.Gettext do @moduledoc """ A module providing Internationalization with a gettext-based API. By using [Gettext](https://hexdocs.pm/gettext), your module gains a set of macros for translations, for example: - import TwentyFourtyEightWeb.Gettext + import TwentyFortyEightWeb.Gettext # Simple translation gettext("Here is the string to translate") @@ -20,5 +20,5 @@ defmodule TwentyFourtyEightWeb.Gettext do See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ - use Gettext, otp_app: :twenty_fourty_eight + use Gettext, otp_app: :twenty_forty_eight end diff --git a/lib/twenty_fourty_eight_web/live/game_live.ex b/lib/twenty_forty_eight_web/live/game_live.ex similarity index 90% rename from lib/twenty_fourty_eight_web/live/game_live.ex rename to lib/twenty_forty_eight_web/live/game_live.ex index 7e2867b..ecb3ccf 100644 --- a/lib/twenty_fourty_eight_web/live/game_live.ex +++ b/lib/twenty_forty_eight_web/live/game_live.ex @@ -1,8 +1,8 @@ -defmodule TwentyFourtyEightWeb.GameLive do - use TwentyFourtyEightWeb, :live_view +defmodule TwentyFortyEightWeb.GameLive do + use TwentyFortyEightWeb, :live_view - alias TwentyFourtyEight.Game.Game - alias TwentyFourtyEight.Game.Manager, as: GameManager + alias TwentyFortyEight.Game.Game + alias TwentyFortyEight.Game.Manager, as: GameManager # Support arrows keys, hjkl, and wasd for movement. @up_keys ~w(ArrowUp w k) @@ -38,7 +38,7 @@ defmodule TwentyFourtyEightWeb.GameLive do {:ok, _pid} = GameManager.get_game(name, game) if connected?(socket) do - Phoenix.PubSub.subscribe(TwentyFourtyEight.PubSub, name) + Phoenix.PubSub.subscribe(TwentyFortyEight.PubSub, name) end {:ok, assign_game(socket, name)} @@ -51,7 +51,7 @@ defmodule TwentyFourtyEightWeb.GameLive do def handle_event("move", %{"key" => key}, %{assigns: %{name: name, state: :running}} = socket) when key in @known_keys do :ok = GameManager.tick(name, key_to_move(key)) - Phoenix.PubSub.broadcast(TwentyFourtyEight.PubSub, name, {:update, name}) + Phoenix.PubSub.broadcast(TwentyFortyEight.PubSub, name, {:update, name}) {:noreply, socket} end diff --git a/lib/twenty_fourty_eight_web/router.ex b/lib/twenty_forty_eight_web/router.ex similarity index 73% rename from lib/twenty_fourty_eight_web/router.ex rename to lib/twenty_forty_eight_web/router.ex index c6ec54f..2a2f47f 100644 --- a/lib/twenty_fourty_eight_web/router.ex +++ b/lib/twenty_forty_eight_web/router.ex @@ -1,11 +1,11 @@ -defmodule TwentyFourtyEightWeb.Router do - use TwentyFourtyEightWeb, :router +defmodule TwentyFortyEightWeb.Router do + use TwentyFortyEightWeb, :router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash - plug :put_root_layout, html: {TwentyFourtyEightWeb.Layouts, :root} + plug :put_root_layout, html: {TwentyFortyEightWeb.Layouts, :root} plug :protect_from_forgery plug :put_secure_browser_headers end @@ -14,7 +14,7 @@ defmodule TwentyFourtyEightWeb.Router do plug :accepts, ["json"] end - scope "/", TwentyFourtyEightWeb do + scope "/", TwentyFortyEightWeb do pipe_through :browser get "/", GameController, :new @@ -23,12 +23,12 @@ defmodule TwentyFourtyEightWeb.Router do end # Other scopes may use custom stacks. - # scope "/api", TwentyFourtyEightWeb do + # scope "/api", TwentyFortyEightWeb do # pipe_through :api # end # Enable LiveDashboard and Swoosh mailbox preview in development - if Application.compile_env(:twenty_fourty_eight, :dev_routes) do + if Application.compile_env(:twenty_forty_eight, :dev_routes) do # If you want to use the LiveDashboard in production, you should put # it behind authentication and allow only admins to access it. # If your application does not have an admins-only section yet, @@ -39,7 +39,7 @@ defmodule TwentyFourtyEightWeb.Router do scope "/dev" do pipe_through :browser - live_dashboard "/dashboard", metrics: TwentyFourtyEightWeb.Telemetry + live_dashboard "/dashboard", metrics: TwentyFortyEightWeb.Telemetry forward "/mailbox", Plug.Swoosh.MailboxPreview end end diff --git a/lib/twenty_fourty_eight_web/telemetry.ex b/lib/twenty_forty_eight_web/telemetry.ex similarity index 87% rename from lib/twenty_fourty_eight_web/telemetry.ex rename to lib/twenty_forty_eight_web/telemetry.ex index 5cbbc07..1953c43 100644 --- a/lib/twenty_fourty_eight_web/telemetry.ex +++ b/lib/twenty_forty_eight_web/telemetry.ex @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEightWeb.Telemetry do +defmodule TwentyFortyEightWeb.Telemetry do use Supervisor import Telemetry.Metrics @@ -52,23 +52,23 @@ defmodule TwentyFourtyEightWeb.Telemetry do ), # Database Metrics - summary("twenty_fourty_eight.repo.query.total_time", + summary("twenty_forty_eight.repo.query.total_time", unit: {:native, :millisecond}, description: "The sum of the other measurements" ), - summary("twenty_fourty_eight.repo.query.decode_time", + summary("twenty_forty_eight.repo.query.decode_time", unit: {:native, :millisecond}, description: "The time spent decoding the data received from the database" ), - summary("twenty_fourty_eight.repo.query.query_time", + summary("twenty_forty_eight.repo.query.query_time", unit: {:native, :millisecond}, description: "The time spent executing the query" ), - summary("twenty_fourty_eight.repo.query.queue_time", + summary("twenty_forty_eight.repo.query.queue_time", unit: {:native, :millisecond}, description: "The time spent waiting for a database connection" ), - summary("twenty_fourty_eight.repo.query.idle_time", + summary("twenty_forty_eight.repo.query.idle_time", unit: {:native, :millisecond}, description: "The time the connection spent waiting before being checked out for the query" @@ -86,7 +86,7 @@ defmodule TwentyFourtyEightWeb.Telemetry do [ # A module, function and arguments to be invoked periodically. # This function must call :telemetry.execute/3 and a metric must be added above. - # {TwentyFourtyEightWeb, :count_users, []} + # {TwentyFortyEightWeb, :count_users, []} ] end end diff --git a/lib/twenty_fourty_eight/mailer.ex b/lib/twenty_fourty_eight/mailer.ex deleted file mode 100644 index a650eee..0000000 --- a/lib/twenty_fourty_eight/mailer.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule TwentyFourtyEight.Mailer do - use Swoosh.Mailer, otp_app: :twenty_fourty_eight -end diff --git a/lib/twenty_fourty_eight/repo.ex b/lib/twenty_fourty_eight/repo.ex deleted file mode 100644 index baa6888..0000000 --- a/lib/twenty_fourty_eight/repo.ex +++ /dev/null @@ -1,5 +0,0 @@ -defmodule TwentyFourtyEight.Repo do - use Ecto.Repo, - otp_app: :twenty_fourty_eight, - adapter: Ecto.Adapters.Postgres -end diff --git a/lib/twenty_fourty_eight_web/components/layouts.ex b/lib/twenty_fourty_eight_web/components/layouts.ex deleted file mode 100644 index a1f9d6f..0000000 --- a/lib/twenty_fourty_eight_web/components/layouts.ex +++ /dev/null @@ -1,5 +0,0 @@ -defmodule TwentyFourtyEightWeb.Layouts do - use TwentyFourtyEightWeb, :html - - embed_templates "layouts/*" -end diff --git a/mix.exs b/mix.exs index 862a833..e23383d 100644 --- a/mix.exs +++ b/mix.exs @@ -1,9 +1,9 @@ -defmodule TwentyFourtyEight.MixProject do +defmodule TwentyFortyEight.MixProject do use Mix.Project def project do [ - app: :twenty_fourty_eight, + app: :twenty_forty_eight, version: "0.1.0", elixir: "~> 1.14", elixirc_paths: elixirc_paths(Mix.env()), @@ -18,7 +18,7 @@ defmodule TwentyFourtyEight.MixProject do # Type `mix help compile.app` for more information. def application do [ - mod: {TwentyFourtyEight.Application, []}, + mod: {TwentyFortyEight.Application, []}, extra_applications: [:logger, :runtime_tools] ] end diff --git a/priv/repo/migrations/20231027172144_create_game_table.exs b/priv/repo/migrations/20231027172144_create_game_table.exs index a099825..1950b79 100644 --- a/priv/repo/migrations/20231027172144_create_game_table.exs +++ b/priv/repo/migrations/20231027172144_create_game_table.exs @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEight.Repo.Migrations.CreateGameTable do +defmodule TwentyFortyEight.Repo.Migrations.CreateGameTable do use Ecto.Migration def change do diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index 7ccc389..844dd94 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -5,7 +5,7 @@ # Inside the script, you can read and write to any of your # repositories directly: # -# TwentyFourtyEight.Repo.insert!(%TwentyFourtyEight.SomeSchema{}) +# TwentyFortyEight.Repo.insert!(%TwentyFortyEight.SomeSchema{}) # # We recommend using the bang functions (`insert!`, `update!` # and so on) as they will fail if something goes wrong. diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 4d99e8b..1563901 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEightWeb.ConnCase do +defmodule TwentyFortyEightWeb.ConnCase do @moduledoc """ This module defines the test case to be used by tests that require setting up a connection. @@ -11,7 +11,7 @@ defmodule TwentyFourtyEightWeb.ConnCase do we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously - by setting `use TwentyFourtyEightWeb.ConnCase, async: true`, although + by setting `use TwentyFortyEightWeb.ConnCase, async: true`, although this option is not recommended for other databases. """ @@ -20,19 +20,19 @@ defmodule TwentyFourtyEightWeb.ConnCase do using do quote do # The default endpoint for testing - @endpoint TwentyFourtyEightWeb.Endpoint + @endpoint TwentyFortyEightWeb.Endpoint - use TwentyFourtyEightWeb, :verified_routes + use TwentyFortyEightWeb, :verified_routes # Import conveniences for testing with connections import Plug.Conn import Phoenix.ConnTest - import TwentyFourtyEightWeb.ConnCase + import TwentyFortyEightWeb.ConnCase end end setup tags do - TwentyFourtyEight.DataCase.setup_sandbox(tags) + TwentyFortyEight.DataCase.setup_sandbox(tags) {:ok, conn: Phoenix.ConnTest.build_conn()} end end diff --git a/test/support/data_case.ex b/test/support/data_case.ex index fca3a8a..1d5241d 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -1,4 +1,4 @@ -defmodule TwentyFourtyEight.DataCase do +defmodule TwentyFortyEight.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. @@ -10,7 +10,7 @@ defmodule TwentyFourtyEight.DataCase do we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously - by setting `use TwentyFourtyEight.DataCase, async: true`, although + by setting `use TwentyFortyEight.DataCase, async: true`, although this option is not recommended for other databases. """ @@ -18,17 +18,17 @@ defmodule TwentyFourtyEight.DataCase do using do quote do - alias TwentyFourtyEight.Repo + alias TwentyFortyEight.Repo import Ecto import Ecto.Changeset import Ecto.Query - import TwentyFourtyEight.DataCase + import TwentyFortyEight.DataCase end end setup tags do - TwentyFourtyEight.DataCase.setup_sandbox(tags) + TwentyFortyEight.DataCase.setup_sandbox(tags) :ok end @@ -36,7 +36,7 @@ defmodule TwentyFourtyEight.DataCase do Sets up the sandbox based on the test tags. """ def setup_sandbox(tags) do - pid = Ecto.Adapters.SQL.Sandbox.start_owner!(TwentyFourtyEight.Repo, shared: not tags[:async]) + pid = Ecto.Adapters.SQL.Sandbox.start_owner!(TwentyFortyEight.Repo, shared: not tags[:async]) on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) end diff --git a/test/test_helper.exs b/test/test_helper.exs index be996e9..7f67cca 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1,2 @@ ExUnit.start() -Ecto.Adapters.SQL.Sandbox.mode(TwentyFourtyEight.Repo, :manual) +Ecto.Adapters.SQL.Sandbox.mode(TwentyFortyEight.Repo, :manual) diff --git a/test/twenty_forty_eight_web/controllers/error_html_test.exs b/test/twenty_forty_eight_web/controllers/error_html_test.exs new file mode 100644 index 0000000..d13fa1e --- /dev/null +++ b/test/twenty_forty_eight_web/controllers/error_html_test.exs @@ -0,0 +1,15 @@ +defmodule TwentyFortyEightWeb.ErrorHTMLTest do + use TwentyFortyEightWeb.ConnCase, async: true + + # Bring render_to_string/4 for testing custom views + import Phoenix.Template + + test "renders 404.html" do + assert render_to_string(TwentyFortyEightWeb.ErrorHTML, "404", "html", []) == "Not Found" + end + + test "renders 500.html" do + assert render_to_string(TwentyFortyEightWeb.ErrorHTML, "500", "html", []) == + "Internal Server Error" + end +end diff --git a/test/twenty_forty_eight_web/controllers/error_json_test.exs b/test/twenty_forty_eight_web/controllers/error_json_test.exs new file mode 100644 index 0000000..c5dd25c --- /dev/null +++ b/test/twenty_forty_eight_web/controllers/error_json_test.exs @@ -0,0 +1,14 @@ +defmodule TwentyFortyEightWeb.ErrorJSONTest do + use TwentyFortyEightWeb.ConnCase, async: true + + test "renders 404" do + assert TwentyFortyEightWeb.ErrorJSON.render("404.json", %{}) == %{ + errors: %{detail: "Not Found"} + } + end + + test "renders 500" do + assert TwentyFortyEightWeb.ErrorJSON.render("500.json", %{}) == + %{errors: %{detail: "Internal Server Error"}} + end +end diff --git a/test/twenty_fourty_eight_web/controllers/page_controller_test.exs b/test/twenty_forty_eight_web/controllers/page_controller_test.exs similarity index 63% rename from test/twenty_fourty_eight_web/controllers/page_controller_test.exs rename to test/twenty_forty_eight_web/controllers/page_controller_test.exs index 5ae261c..cea4480 100644 --- a/test/twenty_fourty_eight_web/controllers/page_controller_test.exs +++ b/test/twenty_forty_eight_web/controllers/page_controller_test.exs @@ -1,5 +1,5 @@ -defmodule TwentyFourtyEightWeb.PageControllerTest do - use TwentyFourtyEightWeb.ConnCase +defmodule TwentyFortyEightWeb.PageControllerTest do + use TwentyFortyEightWeb.ConnCase test "GET /", %{conn: conn} do conn = get(conn, ~p"/") diff --git a/test/twenty_fourty_eight_web/controllers/error_html_test.exs b/test/twenty_fourty_eight_web/controllers/error_html_test.exs deleted file mode 100644 index ab69462..0000000 --- a/test/twenty_fourty_eight_web/controllers/error_html_test.exs +++ /dev/null @@ -1,15 +0,0 @@ -defmodule TwentyFourtyEightWeb.ErrorHTMLTest do - use TwentyFourtyEightWeb.ConnCase, async: true - - # Bring render_to_string/4 for testing custom views - import Phoenix.Template - - test "renders 404.html" do - assert render_to_string(TwentyFourtyEightWeb.ErrorHTML, "404", "html", []) == "Not Found" - end - - test "renders 500.html" do - assert render_to_string(TwentyFourtyEightWeb.ErrorHTML, "500", "html", []) == - "Internal Server Error" - end -end diff --git a/test/twenty_fourty_eight_web/controllers/error_json_test.exs b/test/twenty_fourty_eight_web/controllers/error_json_test.exs deleted file mode 100644 index 130a55b..0000000 --- a/test/twenty_fourty_eight_web/controllers/error_json_test.exs +++ /dev/null @@ -1,14 +0,0 @@ -defmodule TwentyFourtyEightWeb.ErrorJSONTest do - use TwentyFourtyEightWeb.ConnCase, async: true - - test "renders 404" do - assert TwentyFourtyEightWeb.ErrorJSON.render("404.json", %{}) == %{ - errors: %{detail: "Not Found"} - } - end - - test "renders 500" do - assert TwentyFourtyEightWeb.ErrorJSON.render("500.json", %{}) == - %{errors: %{detail: "Internal Server Error"}} - end -end