From d1242ee0db1d2be7eb195d56d61515e520613fd9 Mon Sep 17 00:00:00 2001 From: Robert Prehn Date: Mon, 20 Jul 2020 19:15:11 +0000 Subject: [PATCH] feat: Rename content to content_web --- apps/content/lib/content/views/layout_view.ex | 3 --- apps/content/lib/content/views/page_view.ex | 3 --- .../test/content/views/error_view_test.exs | 14 ---------- .../test/content/views/page_view_test.exs | 3 --- apps/content/test/test_helper.exs | 2 -- apps/{content => content_web}/.formatter.exs | 0 apps/{content => content_web}/.gitignore | 0 apps/{content => content_web}/README.md | 0 apps/{content => content_web}/assets/.babelrc | 0 .../assets/css/app.scss | 0 .../{content => content_web}/assets/js/app.js | 0 .../assets/js/socket.js | 0 .../assets/package-lock.json | 0 .../assets/package.json | 0 .../assets/static/favicon.ico | Bin .../assets/static/images/phoenix.png | Bin .../assets/static/robots.txt | 0 .../assets/webpack.config.js | 0 .../lib/content_web.ex} | 24 +++++++++--------- .../lib/content_web}/application.ex | 14 +++++----- .../lib/content_web}/channels/user_socket.ex | 6 ++--- .../controllers/page_controller.ex | 4 +-- .../lib/content_web}/endpoint.ex | 14 +++++----- .../lib/content_web}/gettext.ex | 6 ++--- .../lib/content_web}/router.ex | 6 ++--- .../lib/content_web}/telemetry.ex | 14 +++++----- .../templates/layout/_menu.html.eex | 0 .../templates/layout/app.html.eex | 0 .../templates/page/index.html.eex | 0 .../templates/page/theming.html.eex | 0 .../templates/page/theming/_buttons.html.eex | 0 .../templates/page/theming/_card.html.eex | 0 .../templates/page/theming/_input.html.eex | 0 .../templates/page/theming/_menu.html.eex | 0 .../templates/page/theming/_site.html.eex | 0 .../templates/page/theming/_tables.html.eex | 0 .../lib/content_web}/views/error_helpers.ex | 6 ++--- .../lib/content_web}/views/error_view.ex | 4 +-- .../lib/content_web/views/layout_view.ex | 3 +++ .../lib/content_web/views/page_view.ex | 3 +++ apps/{content => content_web}/mix.exs | 6 ++--- .../priv/gettext/en/LC_MESSAGES/errors.po | 0 .../priv/gettext/errors.pot | 0 .../controllers/page_controller_test.exs | 4 +-- .../test/content/views/error_view_test.exs | 14 ++++++++++ .../test/content/views/layout_view_test.exs | 4 +-- .../test/content/views/page_view_test.exs | 3 +++ .../test/support/channel_case.ex | 12 ++++----- .../test/support/conn_case.ex | 14 +++++----- apps/content_web/test/test_helper.exs | 2 ++ apps/core/lib/core_web/router.ex | 2 +- config/config.exs | 6 ++--- config/dev.exs | 10 ++++---- config/prod.exs | 6 ++--- config/test.exs | 2 +- 55 files changed, 107 insertions(+), 107 deletions(-) delete mode 100644 apps/content/lib/content/views/layout_view.ex delete mode 100644 apps/content/lib/content/views/page_view.ex delete mode 100644 apps/content/test/content/views/error_view_test.exs delete mode 100644 apps/content/test/content/views/page_view_test.exs delete mode 100644 apps/content/test/test_helper.exs rename apps/{content => content_web}/.formatter.exs (100%) rename apps/{content => content_web}/.gitignore (100%) rename apps/{content => content_web}/README.md (100%) rename apps/{content => content_web}/assets/.babelrc (100%) rename apps/{content => content_web}/assets/css/app.scss (100%) rename apps/{content => content_web}/assets/js/app.js (100%) rename apps/{content => content_web}/assets/js/socket.js (100%) rename apps/{content => content_web}/assets/package-lock.json (100%) rename apps/{content => content_web}/assets/package.json (100%) rename apps/{content => content_web}/assets/static/favicon.ico (100%) rename apps/{content => content_web}/assets/static/images/phoenix.png (100%) rename apps/{content => content_web}/assets/static/robots.txt (100%) rename apps/{content => content_web}/assets/webpack.config.js (100%) rename apps/{content/lib/content.ex => content_web/lib/content_web.ex} (76%) rename apps/{content/lib/content => content_web/lib/content_web}/application.ex (64%) rename apps/{content/lib/content => content_web/lib/content_web}/channels/user_socket.ex (85%) rename apps/{content/lib/content => content_web/lib/content_web}/controllers/page_controller.ex (67%) rename apps/{content/lib/content => content_web/lib/content_web}/endpoint.ex (83%) rename apps/{content/lib/content => content_web/lib/content_web}/gettext.ex (85%) rename apps/{content/lib/content => content_web/lib/content_web}/router.ex (78%) rename apps/{content/lib/content => content_web/lib/content_web}/telemetry.ex (75%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/layout/_menu.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/layout/app.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/index.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming/_buttons.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming/_card.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming/_input.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming/_menu.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming/_site.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/templates/page/theming/_tables.html.eex (100%) rename apps/{content/lib/content => content_web/lib/content_web}/views/error_helpers.ex (88%) rename apps/{content/lib/content => content_web/lib/content_web}/views/error_view.ex (88%) create mode 100644 apps/content_web/lib/content_web/views/layout_view.ex create mode 100644 apps/content_web/lib/content_web/views/page_view.ex rename apps/{content => content_web}/mix.exs (94%) rename apps/{content => content_web}/priv/gettext/en/LC_MESSAGES/errors.po (100%) rename apps/{content => content_web}/priv/gettext/errors.pot (100%) rename apps/{content => content_web}/test/content/controllers/page_controller_test.exs (61%) create mode 100644 apps/content_web/test/content/views/error_view_test.exs rename apps/{content => content_web}/test/content/views/layout_view_test.exs (71%) create mode 100644 apps/content_web/test/content/views/page_view_test.exs rename apps/{content => content_web}/test/support/channel_case.ex (72%) rename apps/{content => content_web}/test/support/conn_case.ex (71%) create mode 100644 apps/content_web/test/test_helper.exs diff --git a/apps/content/lib/content/views/layout_view.ex b/apps/content/lib/content/views/layout_view.ex deleted file mode 100644 index 7ed697b3..00000000 --- a/apps/content/lib/content/views/layout_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Content.LayoutView do - use Content, :view -end diff --git a/apps/content/lib/content/views/page_view.ex b/apps/content/lib/content/views/page_view.ex deleted file mode 100644 index 271c1cc2..00000000 --- a/apps/content/lib/content/views/page_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Content.PageView do - use Content, :view -end diff --git a/apps/content/test/content/views/error_view_test.exs b/apps/content/test/content/views/error_view_test.exs deleted file mode 100644 index ea70eb8a..00000000 --- a/apps/content/test/content/views/error_view_test.exs +++ /dev/null @@ -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 diff --git a/apps/content/test/content/views/page_view_test.exs b/apps/content/test/content/views/page_view_test.exs deleted file mode 100644 index 0a4ae804..00000000 --- a/apps/content/test/content/views/page_view_test.exs +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Content.PageViewTest do - use Content.ConnCase, async: true -end diff --git a/apps/content/test/test_helper.exs b/apps/content/test/test_helper.exs deleted file mode 100644 index b265bf76..00000000 --- a/apps/content/test/test_helper.exs +++ /dev/null @@ -1,2 +0,0 @@ -ExUnit.start() -# Ecto.Adapters.SQL.Sandbox.mode(Content.Repo, :manual) diff --git a/apps/content/.formatter.exs b/apps/content_web/.formatter.exs similarity index 100% rename from apps/content/.formatter.exs rename to apps/content_web/.formatter.exs diff --git a/apps/content/.gitignore b/apps/content_web/.gitignore similarity index 100% rename from apps/content/.gitignore rename to apps/content_web/.gitignore diff --git a/apps/content/README.md b/apps/content_web/README.md similarity index 100% rename from apps/content/README.md rename to apps/content_web/README.md diff --git a/apps/content/assets/.babelrc b/apps/content_web/assets/.babelrc similarity index 100% rename from apps/content/assets/.babelrc rename to apps/content_web/assets/.babelrc diff --git a/apps/content/assets/css/app.scss b/apps/content_web/assets/css/app.scss similarity index 100% rename from apps/content/assets/css/app.scss rename to apps/content_web/assets/css/app.scss diff --git a/apps/content/assets/js/app.js b/apps/content_web/assets/js/app.js similarity index 100% rename from apps/content/assets/js/app.js rename to apps/content_web/assets/js/app.js diff --git a/apps/content/assets/js/socket.js b/apps/content_web/assets/js/socket.js similarity index 100% rename from apps/content/assets/js/socket.js rename to apps/content_web/assets/js/socket.js diff --git a/apps/content/assets/package-lock.json b/apps/content_web/assets/package-lock.json similarity index 100% rename from apps/content/assets/package-lock.json rename to apps/content_web/assets/package-lock.json diff --git a/apps/content/assets/package.json b/apps/content_web/assets/package.json similarity index 100% rename from apps/content/assets/package.json rename to apps/content_web/assets/package.json diff --git a/apps/content/assets/static/favicon.ico b/apps/content_web/assets/static/favicon.ico similarity index 100% rename from apps/content/assets/static/favicon.ico rename to apps/content_web/assets/static/favicon.ico diff --git a/apps/content/assets/static/images/phoenix.png b/apps/content_web/assets/static/images/phoenix.png similarity index 100% rename from apps/content/assets/static/images/phoenix.png rename to apps/content_web/assets/static/images/phoenix.png diff --git a/apps/content/assets/static/robots.txt b/apps/content_web/assets/static/robots.txt similarity index 100% rename from apps/content/assets/static/robots.txt rename to apps/content_web/assets/static/robots.txt diff --git a/apps/content/assets/webpack.config.js b/apps/content_web/assets/webpack.config.js similarity index 100% rename from apps/content/assets/webpack.config.js rename to apps/content_web/assets/webpack.config.js diff --git a/apps/content/lib/content.ex b/apps/content_web/lib/content_web.ex similarity index 76% rename from apps/content/lib/content.ex rename to apps/content_web/lib/content_web.ex index 9063f9e2..ca60eb8e 100644 --- a/apps/content/lib/content.ex +++ b/apps/content_web/lib/content_web.ex @@ -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 diff --git a/apps/content/lib/content/application.ex b/apps/content_web/lib/content_web/application.ex similarity index 64% rename from apps/content/lib/content/application.ex rename to apps/content_web/lib/content_web/application.ex index 245bf8ea..ab522066 100644 --- a/apps/content/lib/content/application.ex +++ b/apps/content_web/lib/content_web/application.ex @@ -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 diff --git a/apps/content/lib/content/channels/user_socket.ex b/apps/content_web/lib/content_web/channels/user_socket.ex similarity index 85% rename from apps/content/lib/content/channels/user_socket.ex rename to apps/content_web/lib/content_web/channels/user_socket.ex index 2aa52f77..31d4aa3f 100644 --- a/apps/content/lib/content/channels/user_socket.ex +++ b/apps/content_web/lib/content_web/channels/user_socket.ex @@ -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 diff --git a/apps/content/lib/content/controllers/page_controller.ex b/apps/content_web/lib/content_web/controllers/page_controller.ex similarity index 67% rename from apps/content/lib/content/controllers/page_controller.ex rename to apps/content_web/lib/content_web/controllers/page_controller.ex index b4019997..cec971ab 100644 --- a/apps/content/lib/content/controllers/page_controller.ex +++ b/apps/content_web/lib/content_web/controllers/page_controller.ex @@ -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") diff --git a/apps/content/lib/content/endpoint.ex b/apps/content_web/lib/content_web/endpoint.ex similarity index 83% rename from apps/content/lib/content/endpoint.ex rename to apps/content_web/lib/content_web/endpoint.ex index 25b1cb78..bb508bff 100644 --- a/apps/content/lib/content/endpoint.ex +++ b/apps/content_web/lib/content_web/endpoint.ex @@ -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 diff --git a/apps/content/lib/content/gettext.ex b/apps/content_web/lib/content_web/gettext.ex similarity index 85% rename from apps/content/lib/content/gettext.ex rename to apps/content_web/lib/content_web/gettext.ex index 135b2da5..06a6ca8d 100644 --- a/apps/content/lib/content/gettext.ex +++ b/apps/content_web/lib/content_web/gettext.ex @@ -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 diff --git a/apps/content/lib/content/router.ex b/apps/content_web/lib/content_web/router.ex similarity index 78% rename from apps/content/lib/content/router.ex rename to apps/content_web/lib/content_web/router.ex index cf9f674a..2acb24da 100644 --- a/apps/content/lib/content/router.ex +++ b/apps/content_web/lib/content_web/router.ex @@ -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 diff --git a/apps/content/lib/content/telemetry.ex b/apps/content_web/lib/content_web/telemetry.ex similarity index 75% rename from apps/content/lib/content/telemetry.ex rename to apps/content_web/lib/content_web/telemetry.ex index 2b73f952..2d24639c 100644 --- a/apps/content/lib/content/telemetry.ex +++ b/apps/content_web/lib/content_web/telemetry.ex @@ -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 diff --git a/apps/content/lib/content/templates/layout/_menu.html.eex b/apps/content_web/lib/content_web/templates/layout/_menu.html.eex similarity index 100% rename from apps/content/lib/content/templates/layout/_menu.html.eex rename to apps/content_web/lib/content_web/templates/layout/_menu.html.eex diff --git a/apps/content/lib/content/templates/layout/app.html.eex b/apps/content_web/lib/content_web/templates/layout/app.html.eex similarity index 100% rename from apps/content/lib/content/templates/layout/app.html.eex rename to apps/content_web/lib/content_web/templates/layout/app.html.eex diff --git a/apps/content/lib/content/templates/page/index.html.eex b/apps/content_web/lib/content_web/templates/page/index.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/index.html.eex rename to apps/content_web/lib/content_web/templates/page/index.html.eex diff --git a/apps/content/lib/content/templates/page/theming.html.eex b/apps/content_web/lib/content_web/templates/page/theming.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming.html.eex rename to apps/content_web/lib/content_web/templates/page/theming.html.eex diff --git a/apps/content/lib/content/templates/page/theming/_buttons.html.eex b/apps/content_web/lib/content_web/templates/page/theming/_buttons.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming/_buttons.html.eex rename to apps/content_web/lib/content_web/templates/page/theming/_buttons.html.eex diff --git a/apps/content/lib/content/templates/page/theming/_card.html.eex b/apps/content_web/lib/content_web/templates/page/theming/_card.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming/_card.html.eex rename to apps/content_web/lib/content_web/templates/page/theming/_card.html.eex diff --git a/apps/content/lib/content/templates/page/theming/_input.html.eex b/apps/content_web/lib/content_web/templates/page/theming/_input.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming/_input.html.eex rename to apps/content_web/lib/content_web/templates/page/theming/_input.html.eex diff --git a/apps/content/lib/content/templates/page/theming/_menu.html.eex b/apps/content_web/lib/content_web/templates/page/theming/_menu.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming/_menu.html.eex rename to apps/content_web/lib/content_web/templates/page/theming/_menu.html.eex diff --git a/apps/content/lib/content/templates/page/theming/_site.html.eex b/apps/content_web/lib/content_web/templates/page/theming/_site.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming/_site.html.eex rename to apps/content_web/lib/content_web/templates/page/theming/_site.html.eex diff --git a/apps/content/lib/content/templates/page/theming/_tables.html.eex b/apps/content_web/lib/content_web/templates/page/theming/_tables.html.eex similarity index 100% rename from apps/content/lib/content/templates/page/theming/_tables.html.eex rename to apps/content_web/lib/content_web/templates/page/theming/_tables.html.eex diff --git a/apps/content/lib/content/views/error_helpers.ex b/apps/content_web/lib/content_web/views/error_helpers.ex similarity index 88% rename from apps/content/lib/content/views/error_helpers.ex rename to apps/content_web/lib/content_web/views/error_helpers.ex index 2e83f363..490c9b58 100644 --- a/apps/content/lib/content/views/error_helpers.ex +++ b/apps/content_web/lib/content_web/views/error_helpers.ex @@ -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 diff --git a/apps/content/lib/content/views/error_view.ex b/apps/content_web/lib/content_web/views/error_view.ex similarity index 88% rename from apps/content/lib/content/views/error_view.ex rename to apps/content_web/lib/content_web/views/error_view.ex index 29b08bff..412e6454 100644 --- a/apps/content/lib/content/views/error_view.ex +++ b/apps/content_web/lib/content_web/views/error_view.ex @@ -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. diff --git a/apps/content_web/lib/content_web/views/layout_view.ex b/apps/content_web/lib/content_web/views/layout_view.ex new file mode 100644 index 00000000..705e4cd2 --- /dev/null +++ b/apps/content_web/lib/content_web/views/layout_view.ex @@ -0,0 +1,3 @@ +defmodule ContentWeb.LayoutView do + use ContentWeb, :view +end diff --git a/apps/content_web/lib/content_web/views/page_view.ex b/apps/content_web/lib/content_web/views/page_view.ex new file mode 100644 index 00000000..29304db7 --- /dev/null +++ b/apps/content_web/lib/content_web/views/page_view.ex @@ -0,0 +1,3 @@ +defmodule ContentWeb.PageView do + use ContentWeb, :view +end diff --git a/apps/content/mix.exs b/apps/content_web/mix.exs similarity index 94% rename from apps/content/mix.exs rename to apps/content_web/mix.exs index 98c13d52..e159aeb4 100644 --- a/apps/content/mix.exs +++ b/apps/content_web/mix.exs @@ -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 diff --git a/apps/content/priv/gettext/en/LC_MESSAGES/errors.po b/apps/content_web/priv/gettext/en/LC_MESSAGES/errors.po similarity index 100% rename from apps/content/priv/gettext/en/LC_MESSAGES/errors.po rename to apps/content_web/priv/gettext/en/LC_MESSAGES/errors.po diff --git a/apps/content/priv/gettext/errors.pot b/apps/content_web/priv/gettext/errors.pot similarity index 100% rename from apps/content/priv/gettext/errors.pot rename to apps/content_web/priv/gettext/errors.pot diff --git a/apps/content/test/content/controllers/page_controller_test.exs b/apps/content_web/test/content/controllers/page_controller_test.exs similarity index 61% rename from apps/content/test/content/controllers/page_controller_test.exs rename to apps/content_web/test/content/controllers/page_controller_test.exs index 84071587..e7d1f3e0 100644 --- a/apps/content/test/content/controllers/page_controller_test.exs +++ b/apps/content_web/test/content/controllers/page_controller_test.exs @@ -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") diff --git a/apps/content_web/test/content/views/error_view_test.exs b/apps/content_web/test/content/views/error_view_test.exs new file mode 100644 index 00000000..22aa1da0 --- /dev/null +++ b/apps/content_web/test/content/views/error_view_test.exs @@ -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 diff --git a/apps/content/test/content/views/layout_view_test.exs b/apps/content_web/test/content/views/layout_view_test.exs similarity index 71% rename from apps/content/test/content/views/layout_view_test.exs rename to apps/content_web/test/content/views/layout_view_test.exs index 7d049194..6298a32e 100644 --- a/apps/content/test/content/views/layout_view_test.exs +++ b/apps/content_web/test/content/views/layout_view_test.exs @@ -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 diff --git a/apps/content_web/test/content/views/page_view_test.exs b/apps/content_web/test/content/views/page_view_test.exs new file mode 100644 index 00000000..2ad2f579 --- /dev/null +++ b/apps/content_web/test/content/views/page_view_test.exs @@ -0,0 +1,3 @@ +defmodule ContentWeb.PageViewTest do + use ContentWeb.ConnCase, async: true +end diff --git a/apps/content/test/support/channel_case.ex b/apps/content_web/test/support/channel_case.ex similarity index 72% rename from apps/content/test/support/channel_case.ex rename to apps/content_web/test/support/channel_case.ex index c7e58e56..83f22d75 100644 --- a/apps/content/test/support/channel_case.ex +++ b/apps/content_web/test/support/channel_case.ex @@ -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 diff --git a/apps/content/test/support/conn_case.ex b/apps/content_web/test/support/conn_case.ex similarity index 71% rename from apps/content/test/support/conn_case.ex rename to apps/content_web/test/support/conn_case.ex index 074c62cb..a9100029 100644 --- a/apps/content/test/support/conn_case.ex +++ b/apps/content_web/test/support/conn_case.ex @@ -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()} diff --git a/apps/content_web/test/test_helper.exs b/apps/content_web/test/test_helper.exs new file mode 100644 index 00000000..ab36f0a3 --- /dev/null +++ b/apps/content_web/test/test_helper.exs @@ -0,0 +1,2 @@ +ExUnit.start() +# Ecto.Adapters.SQL.Sandbox.mode(ContentWeb.Repo, :manual) diff --git a/apps/core/lib/core_web/router.ex b/apps/core/lib/core_web/router.ex index eeeae6f9..81149ef9 100644 --- a/apps/core/lib/core_web/router.ex +++ b/apps/core/lib/core_web/router.ex @@ -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 diff --git a/config/config.exs b/config/config.exs index 45ac29a9..f7bd051f 100644 --- a/config/config.exs +++ b/config/config.exs @@ -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" diff --git a/config/dev.exs b/config/dev.exs index af50402c..ba6d3c1a 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -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)$" ] ] diff --git a/config/prod.exs b/config/prod.exs index 6bd0b13d..075fbb5e 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -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`. diff --git a/config/test.exs b/config/test.exs index 7cdd7672..09062c88 100644 --- a/config/test.exs +++ b/config/test.exs @@ -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