init SlideLife
This commit is contained in:
26
.gitignore
vendored
26
.gitignore
vendored
@ -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/
|
||||
|
||||
|
@ -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: {
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -1,3 +0,0 @@
|
||||
defmodule ModernBase.Mailer do
|
||||
use Swoosh.Mailer, otp_app: :modern_base
|
||||
end
|
@ -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
|
@ -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
|
3
lib/slide_life/mailer.ex
Normal file
3
lib/slide_life/mailer.ex
Normal file
@ -0,0 +1,3 @@
|
||||
defmodule SlideLife.Mailer do
|
||||
use Swoosh.Mailer, otp_app: :slide_life
|
||||
end
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="csrf-token" content={get_csrf_token()} />
|
||||
<.live_title suffix=" · Phoenix Framework">
|
||||
<%= assigns[:page_title] || "ModernBase" %>
|
||||
<%= assigns[:page_title] || "SlideLife" %>
|
||||
</.live_title>
|
||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
@ -1,17 +1,17 @@
|
||||
defmodule ModernBaseWeb.ErrorHTML do
|
||||
defmodule SlideLifeWeb.ErrorHTML do
|
||||
@moduledoc """
|
||||
This module is invoked by your endpoint in case of errors on HTML requests.
|
||||
|
||||
See config/config.exs.
|
||||
"""
|
||||
use ModernBaseWeb, :html
|
||||
use SlideLifeWeb, :html
|
||||
|
||||
# If you want to customize your error pages,
|
||||
# uncomment the embed_templates/1 call below
|
||||
# and add pages to the error directory:
|
||||
#
|
||||
# * lib/modern_base_web/controllers/error_html/404.html.heex
|
||||
# * lib/modern_base_web/controllers/error_html/500.html.heex
|
||||
# * lib/slide_life_web/controllers/error_html/404.html.heex
|
||||
# * lib/slide_life_web/controllers/error_html/500.html.heex
|
||||
#
|
||||
# embed_templates "error_html/*"
|
||||
|
@ -1,4 +1,4 @@
|
||||
defmodule ModernBaseWeb.ErrorJSON do
|
||||
defmodule SlideLifeWeb.ErrorJSON do
|
||||
@moduledoc """
|
||||
This module is invoked by your endpoint in case of errors on JSON requests.
|
||||
|
@ -1,5 +1,5 @@
|
||||
defmodule ModernBaseWeb.PageController do
|
||||
use ModernBaseWeb, :controller
|
||||
defmodule SlideLifeWeb.PageController do
|
||||
use SlideLifeWeb, :controller
|
||||
|
||||
def home(conn, _params) do
|
||||
# The home page is often custom made,
|
@ -1,10 +1,10 @@
|
||||
defmodule ModernBaseWeb.PageHTML do
|
||||
defmodule SlideLifeWeb.PageHTML do
|
||||
@moduledoc """
|
||||
This module contains pages rendered by PageController.
|
||||
|
||||
See the `page_html` directory for all templates available.
|
||||
"""
|
||||
use ModernBaseWeb, :html
|
||||
use SlideLifeWeb, :html
|
||||
|
||||
embed_templates "page_html/*"
|
||||
end
|
@ -1,12 +1,12 @@
|
||||
defmodule ModernBaseWeb.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :modern_base
|
||||
defmodule SlideLifeWeb.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :slide_life
|
||||
|
||||
# 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: "_modern_base_key",
|
||||
key: "_slide_life_key",
|
||||
signing_salt: "ExhFLciv",
|
||||
same_site: "Lax"
|
||||
]
|
||||
@ -21,9 +21,9 @@ defmodule ModernBaseWeb.Endpoint do
|
||||
# when deploying your static files in production.
|
||||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :modern_base,
|
||||
from: :slide_life,
|
||||
gzip: false,
|
||||
only: ModernBaseWeb.static_paths()
|
||||
only: SlideLifeWeb.static_paths()
|
||||
|
||||
# Code reloading can be explicitly enabled under the
|
||||
# :code_reloader configuration of your endpoint.
|
||||
@ -31,7 +31,7 @@ defmodule ModernBaseWeb.Endpoint do
|
||||
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
|
||||
plug Phoenix.LiveReloader
|
||||
plug Phoenix.CodeReloader
|
||||
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :modern_base
|
||||
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :slide_life
|
||||
end
|
||||
|
||||
plug Phoenix.LiveDashboard.RequestLogger,
|
||||
@ -49,5 +49,5 @@ defmodule ModernBaseWeb.Endpoint do
|
||||
plug Plug.MethodOverride
|
||||
plug Plug.Head
|
||||
plug Plug.Session, @session_options
|
||||
plug ModernBaseWeb.Router
|
||||
plug SlideLifeWeb.Router
|
||||
end
|
@ -1,11 +1,11 @@
|
||||
defmodule ModernBaseWeb.Gettext do
|
||||
defmodule SlideLifeWeb.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 ModernBaseWeb.Gettext
|
||||
import SlideLifeWeb.Gettext
|
||||
|
||||
# Simple translation
|
||||
gettext("Here is the string to translate")
|
||||
@ -20,5 +20,5 @@ defmodule ModernBaseWeb.Gettext do
|
||||
|
||||
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
|
||||
"""
|
||||
use Gettext, otp_app: :modern_base
|
||||
use Gettext, otp_app: :slide_life
|
||||
end
|
@ -1,11 +1,11 @@
|
||||
defmodule ModernBaseWeb.Router do
|
||||
use ModernBaseWeb, :router
|
||||
defmodule SlideLifeWeb.Router do
|
||||
use SlideLifeWeb, :router
|
||||
|
||||
pipeline :browser do
|
||||
plug :accepts, ["html"]
|
||||
plug :fetch_session
|
||||
plug :fetch_live_flash
|
||||
plug :put_root_layout, html: {ModernBaseWeb.Layouts, :root}
|
||||
plug :put_root_layout, html: {SlideLifeWeb.Layouts, :root}
|
||||
plug :protect_from_forgery
|
||||
plug :put_secure_browser_headers
|
||||
end
|
||||
@ -14,19 +14,19 @@ defmodule ModernBaseWeb.Router do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", ModernBaseWeb do
|
||||
scope "/", SlideLifeWeb do
|
||||
pipe_through :browser
|
||||
|
||||
get "/", PageController, :home
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
# scope "/api", ModernBaseWeb do
|
||||
# scope "/api", SlideLifeWeb do
|
||||
# pipe_through :api
|
||||
# end
|
||||
|
||||
# Enable LiveDashboard and Swoosh mailbox preview in development
|
||||
if Application.compile_env(:modern_base, :dev_routes) do
|
||||
if Application.compile_env(:slide_life, :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,
|
||||
@ -37,7 +37,7 @@ defmodule ModernBaseWeb.Router do
|
||||
scope "/dev" do
|
||||
pipe_through :browser
|
||||
|
||||
live_dashboard "/dashboard", metrics: ModernBaseWeb.Telemetry
|
||||
live_dashboard "/dashboard", metrics: SlideLifeWeb.Telemetry
|
||||
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
||||
end
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
defmodule ModernBaseWeb.Telemetry do
|
||||
defmodule SlideLifeWeb.Telemetry do
|
||||
use Supervisor
|
||||
import Telemetry.Metrics
|
||||
|
||||
@ -52,23 +52,23 @@ defmodule ModernBaseWeb.Telemetry do
|
||||
),
|
||||
|
||||
# Database Metrics
|
||||
summary("modern_base.repo.query.total_time",
|
||||
summary("slide_life.repo.query.total_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The sum of the other measurements"
|
||||
),
|
||||
summary("modern_base.repo.query.decode_time",
|
||||
summary("slide_life.repo.query.decode_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The time spent decoding the data received from the database"
|
||||
),
|
||||
summary("modern_base.repo.query.query_time",
|
||||
summary("slide_life.repo.query.query_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The time spent executing the query"
|
||||
),
|
||||
summary("modern_base.repo.query.queue_time",
|
||||
summary("slide_life.repo.query.queue_time",
|
||||
unit: {:native, :millisecond},
|
||||
description: "The time spent waiting for a database connection"
|
||||
),
|
||||
summary("modern_base.repo.query.idle_time",
|
||||
summary("slide_life.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 ModernBaseWeb.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.
|
||||
# {ModernBaseWeb, :count_users, []}
|
||||
# {SlideLifeWeb, :count_users, []}
|
||||
]
|
||||
end
|
||||
end
|
12
mix.exs
12
mix.exs
@ -1,9 +1,9 @@
|
||||
defmodule ModernBase.MixProject do
|
||||
defmodule SlideLife.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :modern_base,
|
||||
app: :slide_life,
|
||||
version: "0.1.0",
|
||||
elixir: "~> 1.14",
|
||||
elixirc_paths: elixirc_paths(Mix.env()),
|
||||
@ -18,7 +18,7 @@ defmodule ModernBase.MixProject do
|
||||
# Type `mix help compile.app` for more information.
|
||||
def application do
|
||||
[
|
||||
mod: {ModernBase.Application, []},
|
||||
mod: {SlideLife.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
]
|
||||
end
|
||||
@ -74,10 +74,10 @@ defmodule ModernBase.MixProject do
|
||||
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
||||
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
|
||||
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
|
||||
"assets.build": ["tailwind modern_base", "esbuild modern_base"],
|
||||
"assets.build": ["tailwind slide_life", "esbuild slide_life"],
|
||||
"assets.deploy": [
|
||||
"tailwind modern_base --minify",
|
||||
"esbuild modern_base --minify",
|
||||
"tailwind slide_life --minify",
|
||||
"esbuild slide_life --minify",
|
||||
"phx.digest"
|
||||
]
|
||||
]
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# ModernBase.Repo.insert!(%ModernBase.SomeSchema{})
|
||||
# SlideLife.Repo.insert!(%SlideLife.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
|
@ -1,14 +0,0 @@
|
||||
defmodule ModernBaseWeb.ErrorHTMLTest do
|
||||
use ModernBaseWeb.ConnCase, async: true
|
||||
|
||||
# Bring render_to_string/4 for testing custom views
|
||||
import Phoenix.Template
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(ModernBaseWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(ModernBaseWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
defmodule ModernBaseWeb.ErrorJSONTest do
|
||||
use ModernBaseWeb.ConnCase, async: true
|
||||
|
||||
test "renders 404" do
|
||||
assert ModernBaseWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
||||
end
|
||||
|
||||
test "renders 500" do
|
||||
assert ModernBaseWeb.ErrorJSON.render("500.json", %{}) ==
|
||||
%{errors: %{detail: "Internal Server Error"}}
|
||||
end
|
||||
end
|
14
test/slide_life_web/controllers/error_html_test.exs
Normal file
14
test/slide_life_web/controllers/error_html_test.exs
Normal file
@ -0,0 +1,14 @@
|
||||
defmodule SlideLifeWeb.ErrorHTMLTest do
|
||||
use SlideLifeWeb.ConnCase, async: true
|
||||
|
||||
# Bring render_to_string/4 for testing custom views
|
||||
import Phoenix.Template
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(SlideLifeWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(SlideLifeWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
12
test/slide_life_web/controllers/error_json_test.exs
Normal file
12
test/slide_life_web/controllers/error_json_test.exs
Normal file
@ -0,0 +1,12 @@
|
||||
defmodule SlideLifeWeb.ErrorJSONTest do
|
||||
use SlideLifeWeb.ConnCase, async: true
|
||||
|
||||
test "renders 404" do
|
||||
assert SlideLifeWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
||||
end
|
||||
|
||||
test "renders 500" do
|
||||
assert SlideLifeWeb.ErrorJSON.render("500.json", %{}) ==
|
||||
%{errors: %{detail: "Internal Server Error"}}
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
defmodule ModernBaseWeb.PageControllerTest do
|
||||
use ModernBaseWeb.ConnCase
|
||||
defmodule SlideLifeWeb.PageControllerTest do
|
||||
use SlideLifeWeb.ConnCase
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
@ -1,4 +1,4 @@
|
||||
defmodule ModernBaseWeb.ConnCase do
|
||||
defmodule SlideLifeWeb.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 ModernBaseWeb.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 ModernBaseWeb.ConnCase, async: true`, although
|
||||
by setting `use SlideLifeWeb.ConnCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@ -20,19 +20,19 @@ defmodule ModernBaseWeb.ConnCase do
|
||||
using do
|
||||
quote do
|
||||
# The default endpoint for testing
|
||||
@endpoint ModernBaseWeb.Endpoint
|
||||
@endpoint SlideLifeWeb.Endpoint
|
||||
|
||||
use ModernBaseWeb, :verified_routes
|
||||
use SlideLifeWeb, :verified_routes
|
||||
|
||||
# Import conveniences for testing with connections
|
||||
import Plug.Conn
|
||||
import Phoenix.ConnTest
|
||||
import ModernBaseWeb.ConnCase
|
||||
import SlideLifeWeb.ConnCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
ModernBase.DataCase.setup_sandbox(tags)
|
||||
SlideLife.DataCase.setup_sandbox(tags)
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
defmodule ModernBase.DataCase do
|
||||
defmodule SlideLife.DataCase do
|
||||
@moduledoc """
|
||||
This module defines the setup for tests requiring
|
||||
access to the application's data layer.
|
||||
@ -10,7 +10,7 @@ defmodule ModernBase.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 ModernBase.DataCase, async: true`, although
|
||||
by setting `use SlideLife.DataCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@ -18,17 +18,17 @@ defmodule ModernBase.DataCase do
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias ModernBase.Repo
|
||||
alias SlideLife.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import ModernBase.DataCase
|
||||
import SlideLife.DataCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
ModernBase.DataCase.setup_sandbox(tags)
|
||||
SlideLife.DataCase.setup_sandbox(tags)
|
||||
:ok
|
||||
end
|
||||
|
||||
@ -36,7 +36,7 @@ defmodule ModernBase.DataCase do
|
||||
Sets up the sandbox based on the test tags.
|
||||
"""
|
||||
def setup_sandbox(tags) do
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(ModernBase.Repo, shared: not tags[:async])
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(SlideLife.Repo, shared: not tags[:async])
|
||||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
||||
end
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
ExUnit.start()
|
||||
Ecto.Adapters.SQL.Sandbox.mode(ModernBase.Repo, :manual)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(SlideLife.Repo, :manual)
|
||||
|
Reference in New Issue
Block a user