Refactor Jol module to JOL.

Gotta keep shit on brand.
This commit is contained in:
Jessica Canady 2024-05-21 12:52:37 -04:00
parent 94b7d6e6da
commit 5c3fb3483a
Signed by: phoenix
SSH key fingerprint: SHA256:aaLOzOrLi+0n4eDZNQKH97PehwRt6KSE5fYJc+ZRKCQ
33 changed files with 103 additions and 103 deletions

View file

@ -1,4 +1,4 @@
# Jol
# JOL
To start your Phoenix server:

View file

@ -8,18 +8,18 @@
import Config
config :jol,
ecto_repos: [Jol.Repo],
ecto_repos: [JOL.Repo],
generators: [timestamp_type: :utc_datetime]
# Configures the endpoint
config :jol, JolWeb.Endpoint,
config :jol, JOLWeb.Endpoint,
url: [host: "localhost"],
adapter: Bandit.PhoenixAdapter,
render_errors: [
formats: [html: JolWeb.ErrorHTML, json: JolWeb.ErrorJSON],
formats: [html: JOLWeb.ErrorHTML, json: JOLWeb.ErrorJSON],
layout: false
],
pubsub_server: Jol.PubSub,
pubsub_server: JOL.PubSub,
live_view: [signing_salt: "4pcqZGxe"]
# Configures the mailer
@ -29,7 +29,7 @@ config :jol, JolWeb.Endpoint,
#
# For production it's recommended to configure a different adapter
# 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)
config :esbuild,

View file

@ -1,7 +1,7 @@
import Config
# Configure your database
config :jol, Jol.Repo,
config :jol, JOL.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
@ -16,7 +16,7 @@ config :jol, Jol.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 :jol, JolWeb.Endpoint,
config :jol, JOLWeb.Endpoint,
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {127, 0, 0, 1}, port: 4000],
@ -53,7 +53,7 @@ config :jol, JolWeb.Endpoint,
# different ports.
# Watch static and templates for browser reloading.
config :jol, JolWeb.Endpoint,
config :jol, JOLWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",

View file

@ -5,10 +5,10 @@ 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 :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
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
config :swoosh, local: false

View file

@ -17,7 +17,7 @@ import Config
# 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 :jol, JolWeb.Endpoint, server: true
config :jol, JOLWeb.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 :jol, Jol.Repo,
config :jol, JOL.Repo,
# ssl: true,
url: database_url,
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, JolWeb.Endpoint,
config :jol, JOLWeb.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 :jol, JolWeb.Endpoint,
# config :jol, JOLWeb.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 :jol, JolWeb.Endpoint,
# config :jol, JOLWeb.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 :jol, Jol.Mailer,
# config :jol, JOL.Mailer,
# adapter: Swoosh.Adapters.Mailgun,
# api_key: System.get_env("MAILGUN_API_KEY"),
# domain: System.get_env("MAILGUN_DOMAIN")

View file

@ -5,7 +5,7 @@ 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 :jol, Jol.Repo,
config :jol, JOL.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
@ -15,13 +15,13 @@ config :jol, Jol.Repo,
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :jol, JolWeb.Endpoint,
config :jol, JOLWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
secret_key_base: "TcmWd6GafOT64XVzHiK6e6Yub8o8jhoi4gMK5K4PlAXyD7nfwzjsutXiMDifprgw",
server: false
# 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.
config :swoosh, :api_client, false

View file

@ -1,6 +1,6 @@
defmodule Jol do
defmodule JOL do
@moduledoc """
Jol keeps the contexts that define your domain
JOL keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless

View file

@ -1,4 +1,4 @@
defmodule Jol.Application do
defmodule JOL.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
@ -8,21 +8,21 @@ defmodule Jol.Application do
@impl true
def start(_type, _args) do
children = [
JolWeb.Telemetry,
Jol.Repo,
JOLWeb.Telemetry,
JOL.Repo,
{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
{Finch, name: Jol.Finch},
# Start a worker by calling: Jol.Worker.start_link(arg)
# {Jol.Worker, arg},
{Finch, name: JOL.Finch},
# Start a worker by calling: JOL.Worker.start_link(arg)
# {JOL.Worker, arg},
# Start to serve requests, typically the last entry
JolWeb.Endpoint
JOLWeb.Endpoint
]
# See https://hexdocs.pm/elixir/Supervisor.html
# 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)
end
@ -30,7 +30,7 @@ defmodule Jol.Application do
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
JolWeb.Endpoint.config_change(changed, removed)
JOLWeb.Endpoint.config_change(changed, removed)
:ok
end
end

View file

@ -1,5 +1,5 @@
defmodule Jol.Blog do
alias Jol.Blog.Post
defmodule JOL.Blog do
alias JOL.Blog.Post
use NimblePublisher,
build: Post,

View file

@ -1,4 +1,4 @@
defmodule Jol.Blog.Parser do
defmodule JOL.Blog.Parser do
# Parses blog posts.
def parse(_path, content) do
%{"attrs" => attrs, "body" => body} =

View file

@ -1,3 +1,3 @@
defmodule Jol.Mailer do
defmodule JOL.Mailer do
use Swoosh.Mailer, otp_app: :jol
end

View file

@ -1,4 +1,4 @@
defmodule Jol.Repo do
defmodule JOL.Repo do
use Ecto.Repo,
otp_app: :jol,
adapter: Ecto.Adapters.Postgres

View file

@ -1,12 +1,12 @@
defmodule JolWeb do
defmodule JOLWeb 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 JolWeb, :controller
use JolWeb, :html
use JOLWeb, :controller
use JOLWeb, :html
The definitions below will be executed for every controller,
component, etc, so keep them short and clean, focused
@ -40,10 +40,10 @@ defmodule JolWeb do
quote do
use Phoenix.Controller,
formats: [:html, :json],
layouts: [html: JolWeb.Layouts]
layouts: [html: JOLWeb.Layouts]
import Plug.Conn
import JolWeb.Gettext
import JOLWeb.Gettext
unquote(verified_routes())
end
@ -52,7 +52,7 @@ defmodule JolWeb do
def live_view do
quote do
use Phoenix.LiveView,
layout: {JolWeb.Layouts, :app}
layout: {JOLWeb.Layouts, :app}
unquote(html_helpers())
end
@ -84,8 +84,8 @@ defmodule JolWeb do
# HTML escaping functionality
import Phoenix.HTML
# Core UI components and translation
import JolWeb.CoreComponents
import JolWeb.Gettext
import JOLWeb.CoreComponents
import JOLWeb.Gettext
# Shortcut for generating JS commands
alias Phoenix.LiveView.JS
@ -98,9 +98,9 @@ defmodule JolWeb do
def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: JolWeb.Endpoint,
router: JolWeb.Router,
statics: JolWeb.static_paths()
endpoint: JOLWeb.Endpoint,
router: JOLWeb.Router,
statics: JOLWeb.static_paths()
end
end

View file

@ -1,4 +1,4 @@
defmodule JolWeb.CoreComponents do
defmodule JOLWeb.CoreComponents do
@moduledoc """
Provides core UI components.
@ -17,7 +17,7 @@ defmodule JolWeb.CoreComponents do
use Phoenix.Component
alias Phoenix.LiveView.JS
import JolWeb.Gettext
import JOLWeb.Gettext
@doc """
Renders a modal.
@ -660,9 +660,9 @@ defmodule JolWeb.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(JolWeb.Gettext, "errors", msg, msg, count, opts)
Gettext.dngettext(JOLWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(JolWeb.Gettext, "errors", msg, opts)
Gettext.dgettext(JOLWeb.Gettext, "errors", msg, opts)
end
end

View file

@ -1,5 +1,5 @@
defmodule JolWeb.Layouts do
use JolWeb, :html
defmodule JOLWeb.Layouts do
use JOLWeb, :html
embed_templates "layouts/*"
end

View file

@ -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] || "Jol" %>
<%= assigns[:page_title] || "JOL" %>
</.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"}>

View file

@ -1,5 +1,5 @@
defmodule JolWeb.ErrorHTML do
use JolWeb, :html
defmodule JOLWeb.ErrorHTML do
use JOLWeb, :html
# If you want to customize your error pages,
# uncomment the embed_templates/1 call below

View file

@ -1,4 +1,4 @@
defmodule JolWeb.ErrorJSON do
defmodule JOLWeb.ErrorJSON do
# If you want to customize a particular status code,
# you may add your own clauses, such as:
#

View file

@ -1,5 +1,5 @@
defmodule JolWeb.PageController do
use JolWeb, :controller
defmodule JOLWeb.PageController do
use JOLWeb, :controller
def home(conn, _params) do
# The home page is often custom made,

View file

@ -1,5 +1,5 @@
defmodule JolWeb.PageHTML do
use JolWeb, :html
defmodule JOLWeb.PageHTML do
use JOLWeb, :html
embed_templates "page_html/*"
end

View file

@ -1,4 +1,4 @@
defmodule JolWeb.Endpoint do
defmodule JOLWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :jol
# The session will be stored in the cookie and signed,
@ -23,7 +23,7 @@ defmodule JolWeb.Endpoint do
at: "/",
from: :jol,
gzip: false,
only: JolWeb.static_paths()
only: JOLWeb.static_paths()
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
@ -49,5 +49,5 @@ defmodule JolWeb.Endpoint do
plug Plug.MethodOverride
plug Plug.Head
plug Plug.Session, @session_options
plug JolWeb.Router
plug JOLWeb.Router
end

View file

@ -1,11 +1,11 @@
defmodule JolWeb.Gettext do
defmodule JOLWeb.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 JolWeb.Gettext
import JOLWeb.Gettext
# Simple translation
gettext("Here is the string to translate")

View file

@ -1,11 +1,11 @@
defmodule JolWeb.Router do
use JolWeb, :router
defmodule JOLWeb.Router do
use JOLWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
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 :put_secure_browser_headers
end
@ -14,14 +14,14 @@ defmodule JolWeb.Router do
plug :accepts, ["json"]
end
scope "/", JolWeb do
scope "/", JOLWeb do
pipe_through :browser
get "/", PageController, :home
end
# Other scopes may use custom stacks.
# scope "/api", JolWeb do
# scope "/api", JOLWeb do
# pipe_through :api
# end
@ -37,7 +37,7 @@ defmodule JolWeb.Router do
scope "/dev" do
pipe_through :browser
live_dashboard "/dashboard", metrics: JolWeb.Telemetry
live_dashboard "/dashboard", metrics: JOLWeb.Telemetry
forward "/mailbox", Plug.Swoosh.MailboxPreview
end
end

View file

@ -1,4 +1,4 @@
defmodule JolWeb.Telemetry do
defmodule JOLWeb.Telemetry do
use Supervisor
import Telemetry.Metrics
@ -86,7 +86,7 @@ defmodule JolWeb.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.
# {JolWeb, :count_users, []}
# {JOLWeb, :count_users, []}
]
end
end

View file

@ -1,4 +1,4 @@
defmodule Jol.MixProject do
defmodule JOL.MixProject do
use Mix.Project
def project do
@ -18,7 +18,7 @@ defmodule Jol.MixProject do
# Type `mix help compile.app` for more information.
def application do
[
mod: {Jol.Application, []},
mod: {JOL.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end

View file

@ -5,7 +5,7 @@
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Jol.Repo.insert!(%Jol.SomeSchema{})
# JOL.Repo.insert!(%JOL.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.

View file

@ -1,14 +1,14 @@
defmodule JolWeb.ErrorHTMLTest do
use JolWeb.ConnCase, async: true
defmodule JOLWeb.ErrorHTMLTest do
use JOLWeb.ConnCase, async: true
# Bring render_to_string/4 for testing custom views
import Phoenix.Template
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
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

View file

@ -1,12 +1,12 @@
defmodule JolWeb.ErrorJSONTest do
use JolWeb.ConnCase, async: true
defmodule JOLWeb.ErrorJSONTest do
use JOLWeb.ConnCase, async: true
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
test "renders 500" do
assert JolWeb.ErrorJSON.render("500.json", %{}) ==
assert JOLWeb.ErrorJSON.render("500.json", %{}) ==
%{errors: %{detail: "Internal Server Error"}}
end
end

View file

@ -1,5 +1,5 @@
defmodule JolWeb.PageControllerTest do
use JolWeb.ConnCase
defmodule JOLWeb.PageControllerTest do
use JOLWeb.ConnCase
test "GET /", %{conn: conn} do
conn = get(conn, ~p"/")

View file

@ -1,6 +1,6 @@
defmodule Jol.Blog.ParserTest do
defmodule JOL.Blog.ParserTest do
use ExUnit.Case, async: true
alias Jol.Blog.Parser
alias JOL.Blog.Parser
setup do
content = """

View file

@ -1,4 +1,4 @@
defmodule JolWeb.ConnCase do
defmodule JOLWeb.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 JolWeb.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 JolWeb.ConnCase, async: true`, although
by setting `use JOLWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
"""
@ -20,19 +20,19 @@ defmodule JolWeb.ConnCase do
using do
quote do
# 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 Plug.Conn
import Phoenix.ConnTest
import JolWeb.ConnCase
import JOLWeb.ConnCase
end
end
setup tags do
Jol.DataCase.setup_sandbox(tags)
JOL.DataCase.setup_sandbox(tags)
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end

View file

@ -1,4 +1,4 @@
defmodule Jol.DataCase do
defmodule JOL.DataCase do
@moduledoc """
This module defines the setup for tests requiring
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
are reverted at the end of every test. If you are using
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.
"""
@ -18,17 +18,17 @@ defmodule Jol.DataCase do
using do
quote do
alias Jol.Repo
alias JOL.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
import Jol.DataCase
import JOL.DataCase
end
end
setup tags do
Jol.DataCase.setup_sandbox(tags)
JOL.DataCase.setup_sandbox(tags)
:ok
end
@ -36,7 +36,7 @@ defmodule Jol.DataCase do
Sets up the sandbox based on the test tags.
"""
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)
end

View file

@ -1,2 +1,2 @@
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Jol.Repo, :manual)
Ecto.Adapters.SQL.Sandbox.mode(JOL.Repo, :manual)