Refactor Jol module to JOL.
Gotta keep shit on brand.
This commit is contained in:
parent
94b7d6e6da
commit
5c3fb3483a
|
@ -1,4 +1,4 @@
|
||||||
# Jol
|
# JOL
|
||||||
|
|
||||||
To start your Phoenix server:
|
To start your Phoenix server:
|
||||||
|
|
||||||
|
|
|
@ -8,18 +8,18 @@
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
config :jol,
|
config :jol,
|
||||||
ecto_repos: [Jol.Repo],
|
ecto_repos: [JOL.Repo],
|
||||||
generators: [timestamp_type: :utc_datetime]
|
generators: [timestamp_type: :utc_datetime]
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :jol, JolWeb.Endpoint,
|
config :jol, JOLWeb.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
adapter: Bandit.PhoenixAdapter,
|
adapter: Bandit.PhoenixAdapter,
|
||||||
render_errors: [
|
render_errors: [
|
||||||
formats: [html: JolWeb.ErrorHTML, json: JolWeb.ErrorJSON],
|
formats: [html: JOLWeb.ErrorHTML, json: JOLWeb.ErrorJSON],
|
||||||
layout: false
|
layout: false
|
||||||
],
|
],
|
||||||
pubsub_server: Jol.PubSub,
|
pubsub_server: JOL.PubSub,
|
||||||
live_view: [signing_salt: "4pcqZGxe"]
|
live_view: [signing_salt: "4pcqZGxe"]
|
||||||
|
|
||||||
# Configures the mailer
|
# Configures the mailer
|
||||||
|
@ -29,7 +29,7 @@ config :jol, JolWeb.Endpoint,
|
||||||
#
|
#
|
||||||
# For production it's recommended to configure a different adapter
|
# For production it's recommended to configure a different adapter
|
||||||
# at the `config/runtime.exs`.
|
# at the `config/runtime.exs`.
|
||||||
config :jol, Jol.Mailer, adapter: Swoosh.Adapters.Local
|
config :jol, JOL.Mailer, adapter: Swoosh.Adapters.Local
|
||||||
|
|
||||||
# Configure esbuild (the version is required)
|
# Configure esbuild (the version is required)
|
||||||
config :esbuild,
|
config :esbuild,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
# Configure your database
|
# Configure your database
|
||||||
config :jol, Jol.Repo,
|
config :jol, JOL.Repo,
|
||||||
username: "postgres",
|
username: "postgres",
|
||||||
password: "postgres",
|
password: "postgres",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
|
@ -16,7 +16,7 @@ config :jol, Jol.Repo,
|
||||||
# The watchers configuration can be used to run external
|
# The watchers configuration can be used to run external
|
||||||
# watchers to your application. For example, we can use it
|
# watchers to your application. For example, we can use it
|
||||||
# to bundle .js and .css sources.
|
# to bundle .js and .css sources.
|
||||||
config :jol, JolWeb.Endpoint,
|
config :jol, JOLWeb.Endpoint,
|
||||||
# Binding to loopback ipv4 address prevents access from other machines.
|
# Binding to loopback ipv4 address prevents access from other machines.
|
||||||
# Change to `ip: {0, 0, 0, 0}` to allow 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],
|
http: [ip: {127, 0, 0, 1}, port: 4000],
|
||||||
|
@ -53,7 +53,7 @@ config :jol, JolWeb.Endpoint,
|
||||||
# different ports.
|
# different ports.
|
||||||
|
|
||||||
# Watch static and templates for browser reloading.
|
# Watch static and templates for browser reloading.
|
||||||
config :jol, JolWeb.Endpoint,
|
config :jol, JOLWeb.Endpoint,
|
||||||
live_reload: [
|
live_reload: [
|
||||||
patterns: [
|
patterns: [
|
||||||
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
|
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||||
|
|
|
@ -5,10 +5,10 @@ import Config
|
||||||
# manifest is generated by the `mix assets.deploy` task,
|
# manifest is generated by the `mix assets.deploy` task,
|
||||||
# which you should run after static files are built and
|
# which you should run after static files are built and
|
||||||
# before starting your production server.
|
# before starting your production server.
|
||||||
config :jol, JolWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
|
config :jol, JOLWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
|
||||||
|
|
||||||
# Configures Swoosh API Client
|
# Configures Swoosh API Client
|
||||||
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Jol.Finch
|
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: JOL.Finch
|
||||||
|
|
||||||
# Disable Swoosh Local Memory Storage
|
# Disable Swoosh Local Memory Storage
|
||||||
config :swoosh, local: false
|
config :swoosh, local: false
|
||||||
|
|
|
@ -17,7 +17,7 @@ import Config
|
||||||
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
||||||
# script that automatically sets the env var above.
|
# script that automatically sets the env var above.
|
||||||
if System.get_env("PHX_SERVER") do
|
if System.get_env("PHX_SERVER") do
|
||||||
config :jol, JolWeb.Endpoint, server: true
|
config :jol, JOLWeb.Endpoint, server: true
|
||||||
end
|
end
|
||||||
|
|
||||||
if config_env() == :prod do
|
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: []
|
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
||||||
|
|
||||||
config :jol, Jol.Repo,
|
config :jol, JOL.Repo,
|
||||||
# ssl: true,
|
# ssl: true,
|
||||||
url: database_url,
|
url: database_url,
|
||||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||||
|
@ -53,7 +53,7 @@ if config_env() == :prod do
|
||||||
|
|
||||||
config :jol, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
config :jol, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||||
|
|
||||||
config :jol, JolWeb.Endpoint,
|
config :jol, JOLWeb.Endpoint,
|
||||||
url: [host: host, port: 443, scheme: "https"],
|
url: [host: host, port: 443, scheme: "https"],
|
||||||
http: [
|
http: [
|
||||||
# Enable IPv6 and bind on all interfaces.
|
# 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 get SSL working, you will need to add the `https` key
|
||||||
# to your endpoint configuration:
|
# to your endpoint configuration:
|
||||||
#
|
#
|
||||||
# config :jol, JolWeb.Endpoint,
|
# config :jol, JOLWeb.Endpoint,
|
||||||
# https: [
|
# https: [
|
||||||
# ...,
|
# ...,
|
||||||
# port: 443,
|
# port: 443,
|
||||||
|
@ -92,7 +92,7 @@ if config_env() == :prod do
|
||||||
# We also recommend setting `force_ssl` in your config/prod.exs,
|
# We also recommend setting `force_ssl` in your config/prod.exs,
|
||||||
# ensuring no data is ever sent via http, always redirecting to https:
|
# ensuring no data is ever sent via http, always redirecting to https:
|
||||||
#
|
#
|
||||||
# config :jol, JolWeb.Endpoint,
|
# config :jol, JOLWeb.Endpoint,
|
||||||
# force_ssl: [hsts: true]
|
# force_ssl: [hsts: true]
|
||||||
#
|
#
|
||||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
# 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
|
# 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:
|
# are not using SMTP. Here is an example of the configuration:
|
||||||
#
|
#
|
||||||
# config :jol, Jol.Mailer,
|
# config :jol, JOL.Mailer,
|
||||||
# adapter: Swoosh.Adapters.Mailgun,
|
# adapter: Swoosh.Adapters.Mailgun,
|
||||||
# api_key: System.get_env("MAILGUN_API_KEY"),
|
# api_key: System.get_env("MAILGUN_API_KEY"),
|
||||||
# domain: System.get_env("MAILGUN_DOMAIN")
|
# domain: System.get_env("MAILGUN_DOMAIN")
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Config
|
||||||
# The MIX_TEST_PARTITION environment variable can be used
|
# The MIX_TEST_PARTITION environment variable can be used
|
||||||
# to provide built-in test partitioning in CI environment.
|
# to provide built-in test partitioning in CI environment.
|
||||||
# Run `mix help test` for more information.
|
# Run `mix help test` for more information.
|
||||||
config :jol, Jol.Repo,
|
config :jol, JOL.Repo,
|
||||||
username: "postgres",
|
username: "postgres",
|
||||||
password: "postgres",
|
password: "postgres",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
|
@ -15,13 +15,13 @@ config :jol, Jol.Repo,
|
||||||
|
|
||||||
# We don't run a server during test. If one is required,
|
# We don't run a server during test. If one is required,
|
||||||
# you can enable the server option below.
|
# you can enable the server option below.
|
||||||
config :jol, JolWeb.Endpoint,
|
config :jol, JOLWeb.Endpoint,
|
||||||
http: [ip: {127, 0, 0, 1}, port: 4002],
|
http: [ip: {127, 0, 0, 1}, port: 4002],
|
||||||
secret_key_base: "TcmWd6GafOT64XVzHiK6e6Yub8o8jhoi4gMK5K4PlAXyD7nfwzjsutXiMDifprgw",
|
secret_key_base: "TcmWd6GafOT64XVzHiK6e6Yub8o8jhoi4gMK5K4PlAXyD7nfwzjsutXiMDifprgw",
|
||||||
server: false
|
server: false
|
||||||
|
|
||||||
# In test we don't send emails.
|
# In test we don't send emails.
|
||||||
config :jol, Jol.Mailer, adapter: Swoosh.Adapters.Test
|
config :jol, JOL.Mailer, adapter: Swoosh.Adapters.Test
|
||||||
|
|
||||||
# Disable swoosh api client as it is only required for production adapters.
|
# Disable swoosh api client as it is only required for production adapters.
|
||||||
config :swoosh, :api_client, false
|
config :swoosh, :api_client, false
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
defmodule Jol do
|
defmodule JOL do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Jol keeps the contexts that define your domain
|
JOL keeps the contexts that define your domain
|
||||||
and business logic.
|
and business logic.
|
||||||
|
|
||||||
Contexts are also responsible for managing your data, regardless
|
Contexts are also responsible for managing your data, regardless
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Jol.Application do
|
defmodule JOL.Application do
|
||||||
# See https://hexdocs.pm/elixir/Application.html
|
# See https://hexdocs.pm/elixir/Application.html
|
||||||
# for more information on OTP Applications
|
# for more information on OTP Applications
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
@ -8,21 +8,21 @@ defmodule Jol.Application do
|
||||||
@impl true
|
@impl true
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
children = [
|
children = [
|
||||||
JolWeb.Telemetry,
|
JOLWeb.Telemetry,
|
||||||
Jol.Repo,
|
JOL.Repo,
|
||||||
{DNSCluster, query: Application.get_env(:jol, :dns_cluster_query) || :ignore},
|
{DNSCluster, query: Application.get_env(:jol, :dns_cluster_query) || :ignore},
|
||||||
{Phoenix.PubSub, name: Jol.PubSub},
|
{Phoenix.PubSub, name: JOL.PubSub},
|
||||||
# Start the Finch HTTP client for sending emails
|
# Start the Finch HTTP client for sending emails
|
||||||
{Finch, name: Jol.Finch},
|
{Finch, name: JOL.Finch},
|
||||||
# Start a worker by calling: Jol.Worker.start_link(arg)
|
# Start a worker by calling: JOL.Worker.start_link(arg)
|
||||||
# {Jol.Worker, arg},
|
# {JOL.Worker, arg},
|
||||||
# Start to serve requests, typically the last entry
|
# Start to serve requests, typically the last entry
|
||||||
JolWeb.Endpoint
|
JOLWeb.Endpoint
|
||||||
]
|
]
|
||||||
|
|
||||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||||
# for other strategies and supported options
|
# for other strategies and supported options
|
||||||
opts = [strategy: :one_for_one, name: Jol.Supervisor]
|
opts = [strategy: :one_for_one, name: JOL.Supervisor]
|
||||||
Supervisor.start_link(children, opts)
|
Supervisor.start_link(children, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ defmodule Jol.Application do
|
||||||
# whenever the application is updated.
|
# whenever the application is updated.
|
||||||
@impl true
|
@impl true
|
||||||
def config_change(changed, _new, removed) do
|
def config_change(changed, _new, removed) do
|
||||||
JolWeb.Endpoint.config_change(changed, removed)
|
JOLWeb.Endpoint.config_change(changed, removed)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Jol.Blog do
|
defmodule JOL.Blog do
|
||||||
alias Jol.Blog.Post
|
alias JOL.Blog.Post
|
||||||
|
|
||||||
use NimblePublisher,
|
use NimblePublisher,
|
||||||
build: Post,
|
build: Post,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Jol.Blog.Parser do
|
defmodule JOL.Blog.Parser do
|
||||||
# Parses blog posts.
|
# Parses blog posts.
|
||||||
def parse(_path, content) do
|
def parse(_path, content) do
|
||||||
%{"attrs" => attrs, "body" => body} =
|
%{"attrs" => attrs, "body" => body} =
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
defmodule Jol.Mailer do
|
defmodule JOL.Mailer do
|
||||||
use Swoosh.Mailer, otp_app: :jol
|
use Swoosh.Mailer, otp_app: :jol
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Jol.Repo do
|
defmodule JOL.Repo do
|
||||||
use Ecto.Repo,
|
use Ecto.Repo,
|
||||||
otp_app: :jol,
|
otp_app: :jol,
|
||||||
adapter: Ecto.Adapters.Postgres
|
adapter: Ecto.Adapters.Postgres
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
defmodule JolWeb do
|
defmodule JOLWeb do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
The entrypoint for defining your web interface, such
|
The entrypoint for defining your web interface, such
|
||||||
as controllers, components, channels, and so on.
|
as controllers, components, channels, and so on.
|
||||||
|
|
||||||
This can be used in your application as:
|
This can be used in your application as:
|
||||||
|
|
||||||
use JolWeb, :controller
|
use JOLWeb, :controller
|
||||||
use JolWeb, :html
|
use JOLWeb, :html
|
||||||
|
|
||||||
The definitions below will be executed for every controller,
|
The definitions below will be executed for every controller,
|
||||||
component, etc, so keep them short and clean, focused
|
component, etc, so keep them short and clean, focused
|
||||||
|
@ -40,10 +40,10 @@ defmodule JolWeb do
|
||||||
quote do
|
quote do
|
||||||
use Phoenix.Controller,
|
use Phoenix.Controller,
|
||||||
formats: [:html, :json],
|
formats: [:html, :json],
|
||||||
layouts: [html: JolWeb.Layouts]
|
layouts: [html: JOLWeb.Layouts]
|
||||||
|
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import JolWeb.Gettext
|
import JOLWeb.Gettext
|
||||||
|
|
||||||
unquote(verified_routes())
|
unquote(verified_routes())
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ defmodule JolWeb do
|
||||||
def live_view do
|
def live_view do
|
||||||
quote do
|
quote do
|
||||||
use Phoenix.LiveView,
|
use Phoenix.LiveView,
|
||||||
layout: {JolWeb.Layouts, :app}
|
layout: {JOLWeb.Layouts, :app}
|
||||||
|
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
end
|
end
|
||||||
|
@ -84,8 +84,8 @@ defmodule JolWeb do
|
||||||
# HTML escaping functionality
|
# HTML escaping functionality
|
||||||
import Phoenix.HTML
|
import Phoenix.HTML
|
||||||
# Core UI components and translation
|
# Core UI components and translation
|
||||||
import JolWeb.CoreComponents
|
import JOLWeb.CoreComponents
|
||||||
import JolWeb.Gettext
|
import JOLWeb.Gettext
|
||||||
|
|
||||||
# Shortcut for generating JS commands
|
# Shortcut for generating JS commands
|
||||||
alias Phoenix.LiveView.JS
|
alias Phoenix.LiveView.JS
|
||||||
|
@ -98,9 +98,9 @@ defmodule JolWeb do
|
||||||
def verified_routes do
|
def verified_routes do
|
||||||
quote do
|
quote do
|
||||||
use Phoenix.VerifiedRoutes,
|
use Phoenix.VerifiedRoutes,
|
||||||
endpoint: JolWeb.Endpoint,
|
endpoint: JOLWeb.Endpoint,
|
||||||
router: JolWeb.Router,
|
router: JOLWeb.Router,
|
||||||
statics: JolWeb.static_paths()
|
statics: JOLWeb.static_paths()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule JolWeb.CoreComponents do
|
defmodule JOLWeb.CoreComponents do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Provides core UI components.
|
Provides core UI components.
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ defmodule JolWeb.CoreComponents do
|
||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
|
|
||||||
alias Phoenix.LiveView.JS
|
alias Phoenix.LiveView.JS
|
||||||
import JolWeb.Gettext
|
import JOLWeb.Gettext
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Renders a modal.
|
Renders a modal.
|
||||||
|
@ -660,9 +660,9 @@ defmodule JolWeb.CoreComponents do
|
||||||
# with our gettext backend as first argument. Translations are
|
# with our gettext backend as first argument. Translations are
|
||||||
# available in the errors.po file (as we use the "errors" domain).
|
# available in the errors.po file (as we use the "errors" domain).
|
||||||
if count = opts[:count] do
|
if count = opts[:count] do
|
||||||
Gettext.dngettext(JolWeb.Gettext, "errors", msg, msg, count, opts)
|
Gettext.dngettext(JOLWeb.Gettext, "errors", msg, msg, count, opts)
|
||||||
else
|
else
|
||||||
Gettext.dgettext(JolWeb.Gettext, "errors", msg, opts)
|
Gettext.dgettext(JOLWeb.Gettext, "errors", msg, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule JolWeb.Layouts do
|
defmodule JOLWeb.Layouts do
|
||||||
use JolWeb, :html
|
use JOLWeb, :html
|
||||||
|
|
||||||
embed_templates "layouts/*"
|
embed_templates "layouts/*"
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="csrf-token" content={get_csrf_token()} />
|
<meta name="csrf-token" content={get_csrf_token()} />
|
||||||
<.live_title suffix=" · Phoenix Framework">
|
<.live_title suffix=" · Phoenix Framework">
|
||||||
<%= assigns[:page_title] || "Jol" %>
|
<%= assigns[:page_title] || "JOL" %>
|
||||||
</.live_title>
|
</.live_title>
|
||||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule JolWeb.ErrorHTML do
|
defmodule JOLWeb.ErrorHTML do
|
||||||
use JolWeb, :html
|
use JOLWeb, :html
|
||||||
|
|
||||||
# If you want to customize your error pages,
|
# If you want to customize your error pages,
|
||||||
# uncomment the embed_templates/1 call below
|
# uncomment the embed_templates/1 call below
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule JolWeb.ErrorJSON do
|
defmodule JOLWeb.ErrorJSON do
|
||||||
# If you want to customize a particular status code,
|
# If you want to customize a particular status code,
|
||||||
# you may add your own clauses, such as:
|
# you may add your own clauses, such as:
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule JolWeb.PageController do
|
defmodule JOLWeb.PageController do
|
||||||
use JolWeb, :controller
|
use JOLWeb, :controller
|
||||||
|
|
||||||
def home(conn, _params) do
|
def home(conn, _params) do
|
||||||
# The home page is often custom made,
|
# The home page is often custom made,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule JolWeb.PageHTML do
|
defmodule JOLWeb.PageHTML do
|
||||||
use JolWeb, :html
|
use JOLWeb, :html
|
||||||
|
|
||||||
embed_templates "page_html/*"
|
embed_templates "page_html/*"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule JolWeb.Endpoint do
|
defmodule JOLWeb.Endpoint do
|
||||||
use Phoenix.Endpoint, otp_app: :jol
|
use Phoenix.Endpoint, otp_app: :jol
|
||||||
|
|
||||||
# The session will be stored in the cookie and signed,
|
# The session will be stored in the cookie and signed,
|
||||||
|
@ -23,7 +23,7 @@ defmodule JolWeb.Endpoint do
|
||||||
at: "/",
|
at: "/",
|
||||||
from: :jol,
|
from: :jol,
|
||||||
gzip: false,
|
gzip: false,
|
||||||
only: JolWeb.static_paths()
|
only: JOLWeb.static_paths()
|
||||||
|
|
||||||
# Code reloading can be explicitly enabled under the
|
# Code reloading can be explicitly enabled under the
|
||||||
# :code_reloader configuration of your endpoint.
|
# :code_reloader configuration of your endpoint.
|
||||||
|
@ -49,5 +49,5 @@ defmodule JolWeb.Endpoint do
|
||||||
plug Plug.MethodOverride
|
plug Plug.MethodOverride
|
||||||
plug Plug.Head
|
plug Plug.Head
|
||||||
plug Plug.Session, @session_options
|
plug Plug.Session, @session_options
|
||||||
plug JolWeb.Router
|
plug JOLWeb.Router
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
defmodule JolWeb.Gettext do
|
defmodule JOLWeb.Gettext do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
A module providing Internationalization with a gettext-based API.
|
A module providing Internationalization with a gettext-based API.
|
||||||
|
|
||||||
By using [Gettext](https://hexdocs.pm/gettext),
|
By using [Gettext](https://hexdocs.pm/gettext),
|
||||||
your module gains a set of macros for translations, for example:
|
your module gains a set of macros for translations, for example:
|
||||||
|
|
||||||
import JolWeb.Gettext
|
import JOLWeb.Gettext
|
||||||
|
|
||||||
# Simple translation
|
# Simple translation
|
||||||
gettext("Here is the string to translate")
|
gettext("Here is the string to translate")
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
defmodule JolWeb.Router do
|
defmodule JOLWeb.Router do
|
||||||
use JolWeb, :router
|
use JOLWeb, :router
|
||||||
|
|
||||||
pipeline :browser do
|
pipeline :browser do
|
||||||
plug :accepts, ["html"]
|
plug :accepts, ["html"]
|
||||||
plug :fetch_session
|
plug :fetch_session
|
||||||
plug :fetch_live_flash
|
plug :fetch_live_flash
|
||||||
plug :put_root_layout, html: {JolWeb.Layouts, :root}
|
plug :put_root_layout, html: {JOLWeb.Layouts, :root}
|
||||||
plug :protect_from_forgery
|
plug :protect_from_forgery
|
||||||
plug :put_secure_browser_headers
|
plug :put_secure_browser_headers
|
||||||
end
|
end
|
||||||
|
@ -14,14 +14,14 @@ defmodule JolWeb.Router do
|
||||||
plug :accepts, ["json"]
|
plug :accepts, ["json"]
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", JolWeb do
|
scope "/", JOLWeb do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
get "/", PageController, :home
|
get "/", PageController, :home
|
||||||
end
|
end
|
||||||
|
|
||||||
# Other scopes may use custom stacks.
|
# Other scopes may use custom stacks.
|
||||||
# scope "/api", JolWeb do
|
# scope "/api", JOLWeb do
|
||||||
# pipe_through :api
|
# pipe_through :api
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ defmodule JolWeb.Router do
|
||||||
scope "/dev" do
|
scope "/dev" do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
live_dashboard "/dashboard", metrics: JolWeb.Telemetry
|
live_dashboard "/dashboard", metrics: JOLWeb.Telemetry
|
||||||
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule JolWeb.Telemetry do
|
defmodule JOLWeb.Telemetry do
|
||||||
use Supervisor
|
use Supervisor
|
||||||
import Telemetry.Metrics
|
import Telemetry.Metrics
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ defmodule JolWeb.Telemetry do
|
||||||
[
|
[
|
||||||
# A module, function and arguments to be invoked periodically.
|
# A module, function and arguments to be invoked periodically.
|
||||||
# This function must call :telemetry.execute/3 and a metric must be added above.
|
# This function must call :telemetry.execute/3 and a metric must be added above.
|
||||||
# {JolWeb, :count_users, []}
|
# {JOLWeb, :count_users, []}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
4
mix.exs
4
mix.exs
|
@ -1,4 +1,4 @@
|
||||||
defmodule Jol.MixProject do
|
defmodule JOL.MixProject do
|
||||||
use Mix.Project
|
use Mix.Project
|
||||||
|
|
||||||
def project do
|
def project do
|
||||||
|
@ -18,7 +18,7 @@ defmodule Jol.MixProject do
|
||||||
# Type `mix help compile.app` for more information.
|
# Type `mix help compile.app` for more information.
|
||||||
def application do
|
def application do
|
||||||
[
|
[
|
||||||
mod: {Jol.Application, []},
|
mod: {JOL.Application, []},
|
||||||
extra_applications: [:logger, :runtime_tools]
|
extra_applications: [:logger, :runtime_tools]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Inside the script, you can read and write to any of your
|
# Inside the script, you can read and write to any of your
|
||||||
# repositories directly:
|
# repositories directly:
|
||||||
#
|
#
|
||||||
# Jol.Repo.insert!(%Jol.SomeSchema{})
|
# JOL.Repo.insert!(%JOL.SomeSchema{})
|
||||||
#
|
#
|
||||||
# We recommend using the bang functions (`insert!`, `update!`
|
# We recommend using the bang functions (`insert!`, `update!`
|
||||||
# and so on) as they will fail if something goes wrong.
|
# and so on) as they will fail if something goes wrong.
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
defmodule JolWeb.ErrorHTMLTest do
|
defmodule JOLWeb.ErrorHTMLTest do
|
||||||
use JolWeb.ConnCase, async: true
|
use JOLWeb.ConnCase, async: true
|
||||||
|
|
||||||
# Bring render_to_string/4 for testing custom views
|
# Bring render_to_string/4 for testing custom views
|
||||||
import Phoenix.Template
|
import Phoenix.Template
|
||||||
|
|
||||||
test "renders 404.html" do
|
test "renders 404.html" do
|
||||||
assert render_to_string(JolWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
assert render_to_string(JOLWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders 500.html" do
|
test "renders 500.html" do
|
||||||
assert render_to_string(JolWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
assert render_to_string(JOLWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
defmodule JolWeb.ErrorJSONTest do
|
defmodule JOLWeb.ErrorJSONTest do
|
||||||
use JolWeb.ConnCase, async: true
|
use JOLWeb.ConnCase, async: true
|
||||||
|
|
||||||
test "renders 404" do
|
test "renders 404" do
|
||||||
assert JolWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
assert JOLWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders 500" do
|
test "renders 500" do
|
||||||
assert JolWeb.ErrorJSON.render("500.json", %{}) ==
|
assert JOLWeb.ErrorJSON.render("500.json", %{}) ==
|
||||||
%{errors: %{detail: "Internal Server Error"}}
|
%{errors: %{detail: "Internal Server Error"}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule JolWeb.PageControllerTest do
|
defmodule JOLWeb.PageControllerTest do
|
||||||
use JolWeb.ConnCase
|
use JOLWeb.ConnCase
|
||||||
|
|
||||||
test "GET /", %{conn: conn} do
|
test "GET /", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
defmodule Jol.Blog.ParserTest do
|
defmodule JOL.Blog.ParserTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: true
|
||||||
alias Jol.Blog.Parser
|
alias JOL.Blog.Parser
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
content = """
|
content = """
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule JolWeb.ConnCase do
|
defmodule JOLWeb.ConnCase do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module defines the test case to be used by
|
This module defines the test case to be used by
|
||||||
tests that require setting up a connection.
|
tests that require setting up a connection.
|
||||||
|
@ -11,7 +11,7 @@ defmodule JolWeb.ConnCase do
|
||||||
we enable the SQL sandbox, so changes done to the database
|
we enable the SQL sandbox, so changes done to the database
|
||||||
are reverted at the end of every test. If you are using
|
are reverted at the end of every test. If you are using
|
||||||
PostgreSQL, you can even run database tests asynchronously
|
PostgreSQL, you can even run database tests asynchronously
|
||||||
by setting `use JolWeb.ConnCase, async: true`, although
|
by setting `use JOLWeb.ConnCase, async: true`, although
|
||||||
this option is not recommended for other databases.
|
this option is not recommended for other databases.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -20,19 +20,19 @@ defmodule JolWeb.ConnCase do
|
||||||
using do
|
using do
|
||||||
quote do
|
quote do
|
||||||
# The default endpoint for testing
|
# The default endpoint for testing
|
||||||
@endpoint JolWeb.Endpoint
|
@endpoint JOLWeb.Endpoint
|
||||||
|
|
||||||
use JolWeb, :verified_routes
|
use JOLWeb, :verified_routes
|
||||||
|
|
||||||
# Import conveniences for testing with connections
|
# Import conveniences for testing with connections
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import Phoenix.ConnTest
|
import Phoenix.ConnTest
|
||||||
import JolWeb.ConnCase
|
import JOLWeb.ConnCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
Jol.DataCase.setup_sandbox(tags)
|
JOL.DataCase.setup_sandbox(tags)
|
||||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Jol.DataCase do
|
defmodule JOL.DataCase do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module defines the setup for tests requiring
|
This module defines the setup for tests requiring
|
||||||
access to the application's data layer.
|
access to the application's data layer.
|
||||||
|
@ -10,7 +10,7 @@ defmodule Jol.DataCase do
|
||||||
we enable the SQL sandbox, so changes done to the database
|
we enable the SQL sandbox, so changes done to the database
|
||||||
are reverted at the end of every test. If you are using
|
are reverted at the end of every test. If you are using
|
||||||
PostgreSQL, you can even run database tests asynchronously
|
PostgreSQL, you can even run database tests asynchronously
|
||||||
by setting `use Jol.DataCase, async: true`, although
|
by setting `use JOL.DataCase, async: true`, although
|
||||||
this option is not recommended for other databases.
|
this option is not recommended for other databases.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -18,17 +18,17 @@ defmodule Jol.DataCase do
|
||||||
|
|
||||||
using do
|
using do
|
||||||
quote do
|
quote do
|
||||||
alias Jol.Repo
|
alias JOL.Repo
|
||||||
|
|
||||||
import Ecto
|
import Ecto
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
import Jol.DataCase
|
import JOL.DataCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
Jol.DataCase.setup_sandbox(tags)
|
JOL.DataCase.setup_sandbox(tags)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ defmodule Jol.DataCase do
|
||||||
Sets up the sandbox based on the test tags.
|
Sets up the sandbox based on the test tags.
|
||||||
"""
|
"""
|
||||||
def setup_sandbox(tags) do
|
def setup_sandbox(tags) do
|
||||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Jol.Repo, shared: not tags[:async])
|
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(JOL.Repo, shared: not tags[:async])
|
||||||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
ExUnit.start()
|
ExUnit.start()
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(Jol.Repo, :manual)
|
Ecto.Adapters.SQL.Sandbox.mode(JOL.Repo, :manual)
|
||||||
|
|
Loading…
Reference in a new issue