feat: Rename content to content_web

This commit is contained in:
Robert Prehn 2020-07-20 19:15:11 +00:00
parent 641bce3c71
commit d1242ee0db
55 changed files with 107 additions and 107 deletions

View file

@ -1,3 +0,0 @@
defmodule Content.LayoutView do
use Content, :view
end

View file

@ -1,3 +0,0 @@
defmodule Content.PageView do
use Content, :view
end

View file

@ -1,14 +0,0 @@
defmodule Content.ErrorViewTest do
use Content.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.html" do
assert render_to_string(Content.ErrorView, "404.html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(Content.ErrorView, "500.html", []) == "Internal Server Error"
end
end

View file

@ -1,3 +0,0 @@
defmodule Content.PageViewTest do
use Content.ConnCase, async: true
end

View file

@ -1,2 +0,0 @@
ExUnit.start()
# Ecto.Adapters.SQL.Sandbox.mode(Content.Repo, :manual)

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -1,12 +1,12 @@
defmodule Content do
defmodule ContentWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use Content, :controller
use Content, :view
use ContentWeb, :controller
use ContentWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
@ -19,19 +19,19 @@ defmodule Content do
def controller do
quote do
use Phoenix.Controller, namespace: Content
use Phoenix.Controller, namespace: ContentWeb
import Plug.Conn
import Content.Gettext
alias Content.Router.Helpers, as: Routes
import ContentWeb.Gettext
alias ContentWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
root: "lib/content/templates",
namespace: Content,
root: "lib/content_web/templates",
namespace: ContentWeb,
pattern: "**/*"
# Import convenience functions from controllers
@ -55,7 +55,7 @@ defmodule Content do
def channel do
quote do
use Phoenix.Channel
import Content.Gettext
import ContentWeb.Gettext
end
end
@ -67,9 +67,9 @@ defmodule Content do
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
import Content.ErrorHelpers
import Content.Gettext
alias Content.Router.Helpers, as: Routes
import ContentWeb.ErrorHelpers
import ContentWeb.Gettext
alias ContentWeb.Router.Helpers, as: Routes
end
end

View file

@ -1,4 +1,4 @@
defmodule Content.Application do
defmodule ContentWeb.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
@ -8,23 +8,23 @@ defmodule Content.Application do
def start(_type, _args) do
children = [
# Start the Telemetry supervisor
Content.Telemetry,
ContentWeb.Telemetry,
# Start the Endpoint (http/https)
Content.Endpoint
# Start a worker by calling: Content.Worker.start_link(arg)
# {Content.Worker, arg}
ContentWeb.Endpoint
# Start a worker by calling: ContentWeb.Worker.start_link(arg)
# {ContentWeb.Worker, arg}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Content.Supervisor]
opts = [strategy: :one_for_one, name: ContentWeb.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
Content.Endpoint.config_change(changed, removed)
ContentWeb.Endpoint.config_change(changed, removed)
:ok
end
end

View file

@ -1,8 +1,8 @@
defmodule Content.UserSocket do
defmodule ContentWeb.UserSocket do
use Phoenix.Socket
## Channels
# channel "room:*", Content.RoomChannel
# channel "room:*", ContentWeb.RoomChannel
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
@ -27,7 +27,7 @@ defmodule Content.UserSocket do
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
# Content.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
# ContentWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
@impl true

View file

@ -1,5 +1,5 @@
defmodule Content.PageController do
use Content, :controller
defmodule ContentWeb.PageController do
use ContentWeb, :controller
def index(conn, _params) do
render(conn, "index.html")

View file

@ -1,5 +1,5 @@
defmodule Content.Endpoint do
use Phoenix.Endpoint, otp_app: :content
defmodule ContentWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :content_web
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
@ -10,7 +10,7 @@ defmodule Content.Endpoint do
signing_salt: "wfYQp84C"
]
socket "/socket", Content.UserSocket,
socket "/socket", ContentWeb.UserSocket,
websocket: true,
longpoll: false
@ -22,7 +22,7 @@ defmodule Content.Endpoint do
# when deploying your static files in production.
plug Plug.Static,
at: "/",
from: :content,
from: :content_web,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
@ -32,7 +32,7 @@ defmodule Content.Endpoint do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :content
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :content_web
end
plug Phoenix.LiveDashboard.RequestLogger,
@ -50,6 +50,6 @@ defmodule Content.Endpoint do
plug Plug.MethodOverride
plug Plug.Head
plug Plug.Session, @session_options
plug Pow.Plug.Session, otp_app: :content
plug Content.Router
plug Pow.Plug.Session, otp_app: :content_web
plug ContentWeb.Router
end

View file

@ -1,11 +1,11 @@
defmodule Content.Gettext do
defmodule ContentWeb.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 Content.Gettext
import ContentWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
@ -20,5 +20,5 @@ defmodule Content.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :content
use Gettext, otp_app: :content_web
end

View file

@ -1,5 +1,5 @@
defmodule Content.Router do
use Content, :router
defmodule ContentWeb.Router do
use ContentWeb, :router
pipeline :browser do
plug :accepts, ["html"]
@ -13,7 +13,7 @@ defmodule Content.Router do
plug :accepts, ["json"]
end
scope "/", Content do
scope "/", ContentWeb do
pipe_through :browser
get "/:id", PageController, :show

View file

@ -1,4 +1,4 @@
defmodule Content.Telemetry do
defmodule ContentWeb.Telemetry do
@moduledoc """
Collects metrics for the application and allows them to be transmitted using the Telemetry framework.
"""
@ -34,11 +34,11 @@ defmodule Content.Telemetry do
),
# Database Metrics
summary("content.repo.query.total_time", unit: {:native, :millisecond}),
summary("content.repo.query.decode_time", unit: {:native, :millisecond}),
summary("content.repo.query.query_time", unit: {:native, :millisecond}),
summary("content.repo.query.queue_time", unit: {:native, :millisecond}),
summary("content.repo.query.idle_time", unit: {:native, :millisecond}),
summary("content_web.repo.query.total_time", unit: {:native, :millisecond}),
summary("content_web.repo.query.decode_time", unit: {:native, :millisecond}),
summary("content_web.repo.query.query_time", unit: {:native, :millisecond}),
summary("content_web.repo.query.queue_time", unit: {:native, :millisecond}),
summary("content_web.repo.query.idle_time", unit: {:native, :millisecond}),
# VM Metrics
summary("vm.memory.total", unit: {:byte, :kilobyte}),
@ -52,7 +52,7 @@ defmodule Content.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.
# {Content, :count_users, []}
# {ContentWeb, :count_users, []}
]
end
end

View file

@ -1,4 +1,4 @@
defmodule Content.ErrorHelpers do
defmodule ContentWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
@ -39,9 +39,9 @@ defmodule Content.ErrorHelpers do
# should be written to the errors.po file. The :count option is
# set by Ecto and indicates we should also apply plural rules.
if count = opts[:count] do
Gettext.dngettext(Content.Gettext, "errors", msg, msg, count, opts)
Gettext.dngettext(ContentWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(Content.Gettext, "errors", msg, opts)
Gettext.dgettext(ContentWeb.Gettext, "errors", msg, opts)
end
end
end

View file

@ -1,5 +1,5 @@
defmodule Content.ErrorView do
use Content, :view
defmodule ContentWeb.ErrorView do
use ContentWeb, :view
# If you want to customize a particular status code
# for a certain format, you may uncomment below.

View file

@ -0,0 +1,3 @@
defmodule ContentWeb.LayoutView do
use ContentWeb, :view
end

View file

@ -0,0 +1,3 @@
defmodule ContentWeb.PageView do
use ContentWeb, :view
end

View file

@ -1,9 +1,9 @@
defmodule Content.MixProject do
defmodule ContentWeb.MixProject do
use Mix.Project
def project do
[
app: :content,
app: :content_web,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
@ -24,7 +24,7 @@ defmodule Content.MixProject do
# Type `mix help compile.app` for more information.
def application do
[
mod: {Content.Application, []},
mod: {ContentWeb.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end

View file

@ -1,5 +1,5 @@
defmodule Content.PageControllerTest do
use Content.ConnCase
defmodule ContentWeb.PageControllerTest do
use ContentWeb.ConnCase
test "GET /", %{conn: conn} do
conn = get(conn, "/index")

View file

@ -0,0 +1,14 @@
defmodule ContentWeb.ErrorViewTest do
use ContentWeb.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.html" do
assert render_to_string(ContentWeb.ErrorView, "404.html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(ContentWeb.ErrorView, "500.html", []) == "Internal Server Error"
end
end

View file

@ -1,5 +1,5 @@
defmodule Content.LayoutViewTest do
use Content.ConnCase, async: true
defmodule ContentWeb.LayoutViewTest do
use ContentWeb.ConnCase, async: true
# When testing helpers, you may want to import Phoenix.HTML and
# use functions such as safe_to_string() to convert the helper

View file

@ -0,0 +1,3 @@
defmodule ContentWeb.PageViewTest do
use ContentWeb.ConnCase, async: true
end

View file

@ -1,4 +1,4 @@
defmodule Content.ChannelCase do
defmodule ContentWeb.ChannelCase do
@moduledoc """
This module defines the test case to be used by
channel tests.
@ -11,7 +11,7 @@ defmodule Content.ChannelCase 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 Content.ChannelCase, async: true`, although
by setting `use ContentWeb.ChannelCase, async: true`, although
this option is not recommended for other databases.
"""
@ -21,18 +21,18 @@ defmodule Content.ChannelCase do
quote do
# Import conveniences for testing with channels
import Phoenix.ChannelTest
import Content.ChannelCase
import ContentWeb.ChannelCase
# The default endpoint for testing
@endpoint Content.Endpoint
@endpoint ContentWeb.Endpoint
end
end
setup tags do
# :ok = Ecto.Adapters.SQL.Sandbox.checkout(Content.Repo)
# :ok = Ecto.Adapters.SQL.Sandbox.checkout(ContentWeb.Repo)
unless tags[:async] do
# Ecto.Adapters.SQL.Sandbox.mode(Content.Repo, {:shared, self()})
# Ecto.Adapters.SQL.Sandbox.mode(ContentWeb.Repo, {:shared, self()})
end
:ok

View file

@ -1,4 +1,4 @@
defmodule Content.ConnCase do
defmodule ContentWeb.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 Content.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 Content.ConnCase, async: true`, although
by setting `use ContentWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
"""
@ -22,20 +22,20 @@ defmodule Content.ConnCase do
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import Content.ConnCase
import ContentWeb.ConnCase
alias Content.Router.Helpers, as: Routes
alias ContentWeb.Router.Helpers, as: Routes
# The default endpoint for testing
@endpoint Content.Endpoint
@endpoint ContentWeb.Endpoint
end
end
setup tags do
# :ok = Ecto.Adapters.SQL.Sandbox.checkout(Content.Repo)
# :ok = Ecto.Adapters.SQL.Sandbox.checkout(ContentWeb.Repo)
unless tags[:async] do
# Ecto.Adapters.SQL.Sandbox.mode(Content.Repo, {:shared, self()})
# Ecto.Adapters.SQL.Sandbox.mode(ContentWeb.Repo, {:shared, self()})
end
{:ok, conn: Phoenix.ConnTest.build_conn()}

View file

@ -0,0 +1,2 @@
ExUnit.start()
# Ecto.Adapters.SQL.Sandbox.mode(ContentWeb.Repo, :manual)

View file

@ -27,7 +27,7 @@ defmodule CoreWeb.Router do
forward "/sent_emails", Bamboo.SentEmailViewerPlug
end
scope "/", Content do
scope "/", ContentWeb do
pipe_through :browser
get "/", PageController, :index

View file

@ -26,13 +26,13 @@ config :auth_web, AuthWeb.Endpoint,
live_view: [signing_salt: "AwljJYaY"]
config :core,
router_forwards: [{Content.Router, "/pages"}, {AuthWeb.Router, "/auth"}],
router_forwards: [{ContentWeb.Router, "/pages"}, {AuthWeb.Router, "/auth"}],
email_from: "example@example.org"
config :content,
config :content_web,
generators: [context_app: false]
config :content, Content.Endpoint, server: false
config :content_web, ContentWeb.Endpoint, server: false
config :auth_web, AuthWeb.Endpoint, server: false
import_config "../apps/*/config/config.exs"

View file

@ -71,7 +71,7 @@ config :auth_web, AuthWeb.Endpoint,
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :content, Content.Endpoint,
config :content_web, ContentWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
@ -82,7 +82,7 @@ config :content, Content.Endpoint,
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/content/assets", __DIR__)
cd: Path.expand("../apps/content_web/assets", __DIR__)
]
]
@ -111,13 +111,13 @@ config :content, Content.Endpoint,
# different ports.
# Watch static and templates for browser reloading.
config :content, Content.Endpoint,
config :content_web, ContentWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/content/(live|views)/.*(ex)$",
~r"lib/content/templates/.*(eex)$"
~r"lib/content_web/(live|views)/.*(ex)$",
~r"lib/content_web/templates/.*(eex)$"
]
]

View file

@ -56,7 +56,7 @@ config :auth_web, AuthWeb.Endpoint,
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :content, Content.Endpoint,
config :content_web, ContentWeb.Endpoint,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
@ -65,7 +65,7 @@ config :content, Content.Endpoint,
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :content, Content.Endpoint,
# config :content_web, ContentWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [
@ -89,7 +89,7 @@ config :content, Content.Endpoint,
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :content, Content.Endpoint,
# config :content_web, ContentWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.

View file

@ -21,6 +21,6 @@ config :auth_web, AuthWeb.Endpoint,
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :content, Content.Endpoint,
config :content_web, ContentWeb.Endpoint,
http: [port: 4002],
server: false