From 4fea03a6e602566a20ce53fbfc413fe992863457 Mon Sep 17 00:00:00 2001 From: Victor Martinez <49537445+JasterV@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:52:00 +0100 Subject: [PATCH] Setup phoenix the way I need it --- .formatter.exs | 6 +- README.md | 17 +- config/config.exs | 6 +- config/dev.exs | 10 - config/runtime.exs | 15 - config/test.exs | 13 - lib/intisync/application.ex | 1 - lib/intisync/repo.ex | 5 - .../components/core_components.ex | 371 ++---------------- .../components/layouts/app.html.heex | 24 +- .../components/layouts/root.html.heex | 3 +- .../controllers/page_controller.ex | 9 - lib/intisync_web/controllers/page_html.ex | 5 - .../controllers/page_html/home.html.heex | 222 ----------- lib/intisync_web/endpoint.ex | 1 - lib/intisync_web/telemetry.ex | 23 -- mix.exs | 17 +- mix.lock | 13 +- priv/repo/migrations/.formatter.exs | 4 - priv/repo/seeds.exs | 11 - priv/static/images/logo.svg | 6 - .../controllers/error_html_test.exs | 14 - .../controllers/error_json_test.exs | 12 - .../controllers/page_controller_test.exs | 8 - test/support/conn_case.ex | 3 +- test/support/data_case.ex | 58 --- test/test_helper.exs | 1 - 27 files changed, 47 insertions(+), 831 deletions(-) delete mode 100644 lib/intisync/repo.ex delete mode 100644 lib/intisync_web/controllers/page_controller.ex delete mode 100644 lib/intisync_web/controllers/page_html.ex delete mode 100644 lib/intisync_web/controllers/page_html/home.html.heex delete mode 100644 priv/repo/migrations/.formatter.exs delete mode 100644 priv/repo/seeds.exs delete mode 100644 priv/static/images/logo.svg delete mode 100644 test/intisync_web/controllers/error_html_test.exs delete mode 100644 test/intisync_web/controllers/error_json_test.exs delete mode 100644 test/intisync_web/controllers/page_controller_test.exs delete mode 100644 test/support/data_case.ex diff --git a/.formatter.exs b/.formatter.exs index ef8840c..e17148b 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,6 +1,6 @@ [ - import_deps: [:ecto, :ecto_sql, :phoenix], - subdirectories: ["priv/*/migrations"], + import_deps: [:phoenix], + subdirectories: [], plugins: [Phoenix.LiveView.HTMLFormatter], - inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] + inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}"] ] diff --git a/README.md b/README.md index 0804b8e..de566bf 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,11 @@ # Intisync -To start your Phoenix server: +Allow clients to create private sessions and interact with each other in real time - * Run `mix setup` to install and setup dependencies - * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server` +### Notes on the project name -Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. +Despite the similarity on the name, this project is not endorsed by [Intiface](https://github.com/intiface) and [Intiface](https://github.com/intiface) is their own registered trademark. -Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). +I chose this name because this project was inspired by `Intiface` and the clients require the use of their software to connect the Hub to the bluetooth devices. -## Learn more - - * Official website: https://www.phoenixframework.org/ - * Guides: https://hexdocs.pm/phoenix/overview.html - * Docs: https://hexdocs.pm/phoenix - * Forum: https://elixirforum.com/c/phoenix-forum - * Source: https://github.com/phoenixframework/phoenix +Also I find the name IntiSync very catchy and easy to remember. diff --git a/config/config.exs b/config/config.exs index 496224c..7bcbdf7 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,10 +7,6 @@ # General application configuration import Config -config :intisync, - ecto_repos: [Intisync.Repo], - generators: [timestamp_type: :utc_datetime] - # Configures the endpoint config :intisync, IntisyncWeb.Endpoint, url: [host: "localhost"], @@ -27,7 +23,7 @@ config :esbuild, version: "0.17.11", intisync: [ args: - ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), + ~w(js/hub.js js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), cd: Path.expand("../assets", __DIR__), env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} ] diff --git a/config/dev.exs b/config/dev.exs index 3a79514..d506de5 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,15 +1,5 @@ import Config -# Configure your database -config :intisync, Intisync.Repo, - username: "postgres", - password: "postgres", - hostname: "localhost", - database: "intisync_dev", - stacktrace: true, - show_sensitive_data_on_connection_error: true, - pool_size: 10 - # For development, we disable any cache and enable # debugging and code reloading. # diff --git a/config/runtime.exs b/config/runtime.exs index b441e24..a12099f 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -21,21 +21,6 @@ if System.get_env("PHX_SERVER") do end if config_env() == :prod do - database_url = - System.get_env("DATABASE_URL") || - raise """ - environment variable DATABASE_URL is missing. - For example: ecto://USER:PASS@HOST/DATABASE - """ - - maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: [] - - config :intisync, Intisync.Repo, - # ssl: true, - url: database_url, - pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), - socket_options: maybe_ipv6 - # The secret key base is used to sign/encrypt cookies and other secrets. # A default value is used in config/dev.exs and config/test.exs but you # want to use a different value for prod and you most likely don't want diff --git a/config/test.exs b/config/test.exs index 7e1cf58..f7db39a 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,18 +1,5 @@ import Config -# Configure your database -# -# 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 :intisync, Intisync.Repo, - username: "postgres", - password: "postgres", - hostname: "localhost", - database: "intisync_test#{System.get_env("MIX_TEST_PARTITION")}", - pool: Ecto.Adapters.SQL.Sandbox, - pool_size: System.schedulers_online() * 2 - # We don't run a server during test. If one is required, # you can enable the server option below. config :intisync, IntisyncWeb.Endpoint, diff --git a/lib/intisync/application.ex b/lib/intisync/application.ex index 2a0947c..f781857 100644 --- a/lib/intisync/application.ex +++ b/lib/intisync/application.ex @@ -9,7 +9,6 @@ defmodule Intisync.Application do def start(_type, _args) do children = [ IntisyncWeb.Telemetry, - Intisync.Repo, {DNSCluster, query: Application.get_env(:intisync, :dns_cluster_query) || :ignore}, {Phoenix.PubSub, name: Intisync.PubSub}, # Start a worker by calling: Intisync.Worker.start_link(arg) diff --git a/lib/intisync/repo.ex b/lib/intisync/repo.ex deleted file mode 100644 index 323fea5..0000000 --- a/lib/intisync/repo.ex +++ /dev/null @@ -1,5 +0,0 @@ -defmodule Intisync.Repo do - use Ecto.Repo, - otp_app: :intisync, - adapter: Ecto.Adapters.Postgres -end diff --git a/lib/intisync_web/components/core_components.ex b/lib/intisync_web/components/core_components.ex index 2628a4e..999640e 100644 --- a/lib/intisync_web/components/core_components.ex +++ b/lib/intisync_web/components/core_components.ex @@ -36,20 +36,12 @@ defmodule IntisyncWeb.CoreComponents do """ attr :id, :string, required: true - attr :show, :boolean, default: false - attr :on_cancel, JS, default: %JS{} slot :inner_block, required: true def modal(assigns) do ~H""" -