From a988eb4bc22a5823053d21cd3b14025d3c12e904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Diedrich?= Date: Tue, 21 May 2024 23:48:50 +0200 Subject: [PATCH] init SlideLife --- .gitignore | 26 ++----------------- README.md | 2 +- assets/tailwind.config.js | 4 +-- config/config.exs | 16 ++++++------ config/dev.exs | 16 ++++++------ config/prod.exs | 4 +-- config/runtime.exs | 16 ++++++------ config/test.exs | 8 +++--- lib/modern_base/mailer.ex | 3 --- lib/{modern_base.ex => slide_life.ex} | 4 +-- .../application.ex | 22 ++++++++-------- lib/slide_life/mailer.ex | 3 +++ lib/{modern_base => slide_life}/repo.ex | 4 +-- lib/{modern_base_web.ex => slide_life_web.ex} | 22 ++++++++-------- .../components/core_components.ex | 8 +++--- .../components/layouts.ex | 8 +++--- .../components/layouts/app.html.heex | 0 .../components/layouts/root.html.heex | 2 +- .../controllers/error_html.ex | 8 +++--- .../controllers/error_json.ex | 2 +- .../controllers/page_controller.ex | 4 +-- .../controllers/page_html.ex | 4 +-- .../controllers/page_html/home.html.heex | 0 .../endpoint.ex | 14 +++++----- .../gettext.ex | 6 ++--- .../router.ex | 14 +++++----- .../telemetry.ex | 14 +++++----- mix.exs | 12 ++++----- priv/repo/seeds.exs | 2 +- .../controllers/error_html_test.exs | 14 ---------- .../controllers/error_json_test.exs | 12 --------- .../controllers/error_html_test.exs | 14 ++++++++++ .../controllers/error_json_test.exs | 12 +++++++++ .../controllers/page_controller_test.exs | 4 +-- test/support/conn_case.ex | 12 ++++----- test/support/data_case.ex | 12 ++++----- test/test_helper.exs | 2 +- 37 files changed, 154 insertions(+), 176 deletions(-) delete mode 100644 lib/modern_base/mailer.ex rename lib/{modern_base.ex => slide_life.ex} (68%) rename lib/{modern_base => slide_life}/application.ex (54%) create mode 100644 lib/slide_life/mailer.ex rename lib/{modern_base => slide_life}/repo.ex (50%) rename lib/{modern_base_web.ex => slide_life_web.ex} (83%) rename lib/{modern_base_web => slide_life_web}/components/core_components.ex (98%) rename lib/{modern_base_web => slide_life_web}/components/layouts.ex (66%) rename lib/{modern_base_web => slide_life_web}/components/layouts/app.html.heex (100%) rename lib/{modern_base_web => slide_life_web}/components/layouts/root.html.heex (91%) rename lib/{modern_base_web => slide_life_web}/controllers/error_html.ex (73%) rename lib/{modern_base_web => slide_life_web}/controllers/error_json.ex (94%) rename lib/{modern_base_web => slide_life_web}/controllers/page_controller.ex (67%) rename lib/{modern_base_web => slide_life_web}/controllers/page_html.ex (73%) rename lib/{modern_base_web => slide_life_web}/controllers/page_html/home.html.heex (100%) rename lib/{modern_base_web => slide_life_web}/endpoint.ex (83%) rename lib/{modern_base_web => slide_life_web}/gettext.ex (85%) rename lib/{modern_base_web => slide_life_web}/router.ex (74%) rename lib/{modern_base_web => slide_life_web}/telemetry.ex (88%) delete mode 100644 test/modern_base_web/controllers/error_html_test.exs delete mode 100644 test/modern_base_web/controllers/error_json_test.exs create mode 100644 test/slide_life_web/controllers/error_html_test.exs create mode 100644 test/slide_life_web/controllers/error_json_test.exs rename test/{modern_base_web => slide_life_web}/controllers/page_controller_test.exs (67%) diff --git a/.gitignore b/.gitignore index 393c29a..fdc8a90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,15 @@ -# The directory Mix will write compiled artifacts to. +/.lexical/ /_build/ - -# If you run "mix test --cover", coverage assets end up here. /cover/ - -# The directory Mix downloads your dependencies sources to. /deps/ - -# Where 3rd-party dependencies like ExDoc output generated docs. /doc/ - -# Ignore .fetch files in case you like to edit your project deps locally. /.fetch - -# If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump - -# Also ignore archive artifacts (built via "mix archive.build"). *.ez - -# Temporary files, for example, from tests. /tmp/ - -# Ignore package tarball (built via "mix hex.build"). -modern_base-*.tar - -# Ignore assets that are produced by build tools. +slide_life-*.tar /priv/static/assets/ - -# Ignore digested assets cache. /priv/static/cache_manifest.json - -# In case you use Node.js/npm, you want to ignore these. npm-debug.log /assets/node_modules/ diff --git a/README.md b/README.md index a744a45..caba961 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ModernBase +# SlideLife To start your Phoenix server: diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index 5dc356c..df0489e 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/modern_base_web.ex", - "../lib/modern_base_web/**/*.*ex" + "../lib/slide_life_web.ex", + "../lib/slide_life_web/**/*.*ex" ], theme: { extend: { diff --git a/config/config.exs b/config/config.exs index 208b801..9e9cab4 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,19 +7,19 @@ # General application configuration import Config -config :modern_base, - ecto_repos: [ModernBase.Repo], +config :slide_life, + ecto_repos: [SlideLife.Repo], generators: [timestamp_type: :utc_datetime] # Configures the endpoint -config :modern_base, ModernBaseWeb.Endpoint, +config :slide_life, SlideLifeWeb.Endpoint, url: [host: "localhost"], adapter: Bandit.PhoenixAdapter, render_errors: [ - formats: [html: ModernBaseWeb.ErrorHTML, json: ModernBaseWeb.ErrorJSON], + formats: [html: SlideLifeWeb.ErrorHTML, json: SlideLifeWeb.ErrorJSON], layout: false ], - pubsub_server: ModernBase.PubSub, + pubsub_server: SlideLife.PubSub, live_view: [signing_salt: "UVlXhkXp"] # Configures the mailer @@ -29,12 +29,12 @@ config :modern_base, ModernBaseWeb.Endpoint, # # For production it's recommended to configure a different adapter # at the `config/runtime.exs`. -config :modern_base, ModernBase.Mailer, adapter: Swoosh.Adapters.Local +config :slide_life, SlideLife.Mailer, adapter: Swoosh.Adapters.Local # Configure esbuild (the version is required) config :esbuild, version: "0.17.11", - modern_base: [ + slide_life: [ args: ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), cd: Path.expand("../assets", __DIR__), @@ -44,7 +44,7 @@ config :esbuild, # Configure tailwind (the version is required) config :tailwind, version: "3.4.0", - modern_base: [ + slide_life: [ args: ~w( --config=tailwind.config.js --input=css/app.css diff --git a/config/dev.exs b/config/dev.exs index a919376..079d08d 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,11 +1,11 @@ import Config # Configure your database -config :modern_base, ModernBase.Repo, +config :slide_life, SlideLife.Repo, username: "postgres", password: "postgres", hostname: "localhost", - database: "modern_base_dev", + database: "slide_life_dev", stacktrace: true, show_sensitive_data_on_connection_error: true, pool_size: 10 @@ -16,7 +16,7 @@ config :modern_base, ModernBase.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 :modern_base, ModernBaseWeb.Endpoint, +config :slide_life, SlideLifeWeb.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], @@ -25,8 +25,8 @@ config :modern_base, ModernBaseWeb.Endpoint, debug_errors: true, secret_key_base: "SJCi/gfKcoIeiOLcl5pcNoMsAtluCExbdb66zFwuSrMPjKHr/DumTB35OCXisztJ", watchers: [ - esbuild: {Esbuild, :install_and_run, [:modern_base, ~w(--sourcemap=inline --watch)]}, - tailwind: {Tailwind, :install_and_run, [:modern_base, ~w(--watch)]} + esbuild: {Esbuild, :install_and_run, [:slide_life, ~w(--sourcemap=inline --watch)]}, + tailwind: {Tailwind, :install_and_run, [:slide_life, ~w(--watch)]} ] # ## SSL Support @@ -53,17 +53,17 @@ config :modern_base, ModernBaseWeb.Endpoint, # different ports. # Watch static and templates for browser reloading. -config :modern_base, ModernBaseWeb.Endpoint, +config :slide_life, SlideLifeWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", - ~r"lib/modern_base_web/(controllers|live|components)/.*(ex|heex)$" + ~r"lib/slide_life_web/(controllers|live|components)/.*(ex|heex)$" ] ] # Enable dev routes for dashboard and mailbox -config :modern_base, dev_routes: true +config :slide_life, 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 bf30a8e..28ada70 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 :modern_base, ModernBaseWeb.Endpoint, +config :slide_life, SlideLifeWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" # Configures Swoosh API Client -config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: ModernBase.Finch +config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: SlideLife.Finch # Disable Swoosh Local Memory Storage config :swoosh, local: false diff --git a/config/runtime.exs b/config/runtime.exs index 14f2b97..d88f502 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/modern_base start +# PHX_SERVER=true bin/slide_life 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 :modern_base, ModernBaseWeb.Endpoint, server: true + config :slide_life, SlideLifeWeb.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 :modern_base, ModernBase.Repo, + config :slide_life, SlideLife.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 :modern_base, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") + config :slide_life, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") - config :modern_base, ModernBaseWeb.Endpoint, + config :slide_life, SlideLifeWeb.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 :modern_base, ModernBaseWeb.Endpoint, + # config :slide_life, SlideLifeWeb.Endpoint, # https: [ # ..., # port: 443, @@ -92,7 +92,7 @@ if config_env() == :prod do # We also recommend setting `force_ssl` in your config/prod.exs, # ensuring no data is ever sent via http, always redirecting to https: # - # config :modern_base, ModernBaseWeb.Endpoint, + # config :slide_life, SlideLifeWeb.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 :modern_base, ModernBase.Mailer, + # config :slide_life, SlideLife.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 5d551d5..f73ca17 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 :modern_base, ModernBase.Repo, +config :slide_life, SlideLife.Repo, username: "postgres", password: "postgres", hostname: "localhost", - database: "modern_base_test#{System.get_env("MIX_TEST_PARTITION")}", + database: "slide_life_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 :modern_base, ModernBaseWeb.Endpoint, +config :slide_life, SlideLifeWeb.Endpoint, http: [ip: {127, 0, 0, 1}, port: 4002], secret_key_base: "Nrp7SlEOymCdvtNm/jLvYBfD9l+FZqQHTitjkVafLgxH22SEQXx3w2kjON2KsYFa", server: false # In test we don't send emails. -config :modern_base, ModernBase.Mailer, adapter: Swoosh.Adapters.Test +config :slide_life, SlideLife.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/lib/modern_base/mailer.ex b/lib/modern_base/mailer.ex deleted file mode 100644 index 407d9ae..0000000 --- a/lib/modern_base/mailer.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule ModernBase.Mailer do - use Swoosh.Mailer, otp_app: :modern_base -end diff --git a/lib/modern_base.ex b/lib/slide_life.ex similarity index 68% rename from lib/modern_base.ex rename to lib/slide_life.ex index 316a2e2..6d9db2a 100644 --- a/lib/modern_base.ex +++ b/lib/slide_life.ex @@ -1,6 +1,6 @@ -defmodule ModernBase do +defmodule SlideLife do @moduledoc """ - ModernBase keeps the contexts that define your domain + SlideLife keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless diff --git a/lib/modern_base/application.ex b/lib/slide_life/application.ex similarity index 54% rename from lib/modern_base/application.ex rename to lib/slide_life/application.ex index 0dd7be1..6c7c1f3 100644 --- a/lib/modern_base/application.ex +++ b/lib/slide_life/application.ex @@ -1,4 +1,4 @@ -defmodule ModernBase.Application do +defmodule SlideLife.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false @@ -8,21 +8,21 @@ defmodule ModernBase.Application do @impl true def start(_type, _args) do children = [ - ModernBaseWeb.Telemetry, - ModernBase.Repo, - {DNSCluster, query: Application.get_env(:modern_base, :dns_cluster_query) || :ignore}, - {Phoenix.PubSub, name: ModernBase.PubSub}, + SlideLifeWeb.Telemetry, + SlideLife.Repo, + {DNSCluster, query: Application.get_env(:slide_life, :dns_cluster_query) || :ignore}, + {Phoenix.PubSub, name: SlideLife.PubSub}, # Start the Finch HTTP client for sending emails - {Finch, name: ModernBase.Finch}, - # Start a worker by calling: ModernBase.Worker.start_link(arg) - # {ModernBase.Worker, arg}, + {Finch, name: SlideLife.Finch}, + # Start a worker by calling: SlideLife.Worker.start_link(arg) + # {SlideLife.Worker, arg}, # Start to serve requests, typically the last entry - ModernBaseWeb.Endpoint + SlideLifeWeb.Endpoint ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: ModernBase.Supervisor] + opts = [strategy: :one_for_one, name: SlideLife.Supervisor] Supervisor.start_link(children, opts) end @@ -30,7 +30,7 @@ defmodule ModernBase.Application do # whenever the application is updated. @impl true def config_change(changed, _new, removed) do - ModernBaseWeb.Endpoint.config_change(changed, removed) + SlideLifeWeb.Endpoint.config_change(changed, removed) :ok end end diff --git a/lib/slide_life/mailer.ex b/lib/slide_life/mailer.ex new file mode 100644 index 0000000..61b57a6 --- /dev/null +++ b/lib/slide_life/mailer.ex @@ -0,0 +1,3 @@ +defmodule SlideLife.Mailer do + use Swoosh.Mailer, otp_app: :slide_life +end diff --git a/lib/modern_base/repo.ex b/lib/slide_life/repo.ex similarity index 50% rename from lib/modern_base/repo.ex rename to lib/slide_life/repo.ex index 07165ee..25fc1a2 100644 --- a/lib/modern_base/repo.ex +++ b/lib/slide_life/repo.ex @@ -1,5 +1,5 @@ -defmodule ModernBase.Repo do +defmodule SlideLife.Repo do use Ecto.Repo, - otp_app: :modern_base, + otp_app: :slide_life, adapter: Ecto.Adapters.Postgres end diff --git a/lib/modern_base_web.ex b/lib/slide_life_web.ex similarity index 83% rename from lib/modern_base_web.ex rename to lib/slide_life_web.ex index c20bc0e..8465cd4 100644 --- a/lib/modern_base_web.ex +++ b/lib/slide_life_web.ex @@ -1,12 +1,12 @@ -defmodule ModernBaseWeb do +defmodule SlideLifeWeb 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 ModernBaseWeb, :controller - use ModernBaseWeb, :html + use SlideLifeWeb, :controller + use SlideLifeWeb, :html The definitions below will be executed for every controller, component, etc, so keep them short and clean, focused @@ -40,10 +40,10 @@ defmodule ModernBaseWeb do quote do use Phoenix.Controller, formats: [:html, :json], - layouts: [html: ModernBaseWeb.Layouts] + layouts: [html: SlideLifeWeb.Layouts] import Plug.Conn - import ModernBaseWeb.Gettext + import SlideLifeWeb.Gettext unquote(verified_routes()) end @@ -52,7 +52,7 @@ defmodule ModernBaseWeb do def live_view do quote do use Phoenix.LiveView, - layout: {ModernBaseWeb.Layouts, :app} + layout: {SlideLifeWeb.Layouts, :app} unquote(html_helpers()) end @@ -84,8 +84,8 @@ defmodule ModernBaseWeb do # HTML escaping functionality import Phoenix.HTML # Core UI components and translation - import ModernBaseWeb.CoreComponents - import ModernBaseWeb.Gettext + import SlideLifeWeb.CoreComponents + import SlideLifeWeb.Gettext # Shortcut for generating JS commands alias Phoenix.LiveView.JS @@ -98,9 +98,9 @@ defmodule ModernBaseWeb do def verified_routes do quote do use Phoenix.VerifiedRoutes, - endpoint: ModernBaseWeb.Endpoint, - router: ModernBaseWeb.Router, - statics: ModernBaseWeb.static_paths() + endpoint: SlideLifeWeb.Endpoint, + router: SlideLifeWeb.Router, + statics: SlideLifeWeb.static_paths() end end diff --git a/lib/modern_base_web/components/core_components.ex b/lib/slide_life_web/components/core_components.ex similarity index 98% rename from lib/modern_base_web/components/core_components.ex rename to lib/slide_life_web/components/core_components.ex index c3aa359..ddaa718 100644 --- a/lib/modern_base_web/components/core_components.ex +++ b/lib/slide_life_web/components/core_components.ex @@ -1,4 +1,4 @@ -defmodule ModernBaseWeb.CoreComponents do +defmodule SlideLifeWeb.CoreComponents do @moduledoc """ Provides core UI components. @@ -17,7 +17,7 @@ defmodule ModernBaseWeb.CoreComponents do use Phoenix.Component alias Phoenix.LiveView.JS - import ModernBaseWeb.Gettext + import SlideLifeWeb.Gettext @doc """ Renders a modal. @@ -661,9 +661,9 @@ defmodule ModernBaseWeb.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(ModernBaseWeb.Gettext, "errors", msg, msg, count, opts) + Gettext.dngettext(SlideLifeWeb.Gettext, "errors", msg, msg, count, opts) else - Gettext.dgettext(ModernBaseWeb.Gettext, "errors", msg, opts) + Gettext.dgettext(SlideLifeWeb.Gettext, "errors", msg, opts) end end diff --git a/lib/modern_base_web/components/layouts.ex b/lib/slide_life_web/components/layouts.ex similarity index 66% rename from lib/modern_base_web/components/layouts.ex rename to lib/slide_life_web/components/layouts.ex index 5c72c4d..08785c7 100644 --- a/lib/modern_base_web/components/layouts.ex +++ b/lib/slide_life_web/components/layouts.ex @@ -1,14 +1,14 @@ -defmodule ModernBaseWeb.Layouts do +defmodule SlideLifeWeb.Layouts do @moduledoc """ This module holds different layouts used by your application. See the `layouts` directory for all templates available. The "root" layout is a skeleton rendered as part of the application router. The "app" layout is set as the default - layout on both `use ModernBaseWeb, :controller` and - `use ModernBaseWeb, :live_view`. + layout on both `use SlideLifeWeb, :controller` and + `use SlideLifeWeb, :live_view`. """ - use ModernBaseWeb, :html + use SlideLifeWeb, :html embed_templates "layouts/*" end diff --git a/lib/modern_base_web/components/layouts/app.html.heex b/lib/slide_life_web/components/layouts/app.html.heex similarity index 100% rename from lib/modern_base_web/components/layouts/app.html.heex rename to lib/slide_life_web/components/layouts/app.html.heex diff --git a/lib/modern_base_web/components/layouts/root.html.heex b/lib/slide_life_web/components/layouts/root.html.heex similarity index 91% rename from lib/modern_base_web/components/layouts/root.html.heex rename to lib/slide_life_web/components/layouts/root.html.heex index 9962436..f59f848 100644 --- a/lib/modern_base_web/components/layouts/root.html.heex +++ b/lib/slide_life_web/components/layouts/root.html.heex @@ -5,7 +5,7 @@ <.live_title suffix=" ยท Phoenix Framework"> - <%= assigns[:page_title] || "ModernBase" %> + <%= assigns[:page_title] || "SlideLife" %>