diff --git a/Dockerfile b/Dockerfile index 8e271cd..2e531b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,4 +55,4 @@ RUN chown -R app: ./prod USER app # Run the Phoenix app -CMD ["./prod/rel/podcast_feed/bin/podcast_feed", "start"] +CMD ["./prod/rel/openpod/bin/openpod", "start"] diff --git a/config/config.exs b/config/config.exs index 20534e3..066768d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,18 +7,18 @@ # General application configuration use Mix.Config -config :podcast_feed, - ecto_repos: [PodcastFeed.Repo] +config :openpod, + ecto_repos: [Openpod.Repo] # Configures the endpoint -config :podcast_feed, PodcastFeedWeb.Endpoint, +config :openpod, OpenpodWeb.Endpoint, url: [host: "localhost"], secret_key_base: "SWl0xVj8AVXoc2G0eUk6VfeOd/lppjkaKbiHWs4ucxAUJ8+wzAEa4bMo0ZVjtVVk", - render_errors: [view: PodcastFeedWeb.ErrorView, accepts: ~w(html json), layout: false], - pubsub_server: PodcastFeed.PubSub, + render_errors: [view: OpenpodWeb.ErrorView, accepts: ~w(html json), layout: false], + pubsub_server: Openpod.PubSub, live_view: [signing_salt: "6jHv46Xw"] -config :podcast_feed, +config :openpod, cache_duration: :timer.hours(24) # Configures Elixir's Logger diff --git a/config/dev.exs b/config/dev.exs index 50c3ea2..2edae43 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,10 +1,10 @@ use Mix.Config # Configure your database -config :podcast_feed, PodcastFeed.Repo, +config :openpod, Openpod.Repo, username: "postgres", password: "postgres", - database: "podcast_feed_dev", + database: "openpod_dev", hostname: "localhost", show_sensitive_data_on_connection_error: true, pool_size: 10 @@ -15,7 +15,7 @@ config :podcast_feed, PodcastFeed.Repo, # 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 :podcast_feed, PodcastFeedWeb.Endpoint, +config :openpod, OpenpodWeb.Endpoint, http: [port: 5000], debug_errors: true, code_reloader: true, @@ -55,13 +55,13 @@ config :podcast_feed, PodcastFeedWeb.Endpoint, # different ports. # Watch static and templates for browser reloading. -config :podcast_feed, PodcastFeedWeb.Endpoint, +config :openpod, OpenpodWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", - ~r"lib/podcast_feed_web/(live|views)/.*(ex)$", - ~r"lib/podcast_feed_web/templates/.*(eex)$" + ~r"lib/openpod_web/(live|views)/.*(ex)$", + ~r"lib/openpod_web/templates/.*(eex)$" ] ] diff --git a/config/prod.exs b/config/prod.exs index 0cf94b1..72ba60d 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -9,7 +9,7 @@ use Mix.Config # 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 :podcast_feed, PodcastFeedWeb.Endpoint, +config :openpod, OpenpodWeb.Endpoint, load_from_system_env: true, url: [scheme: "https", host: "other-unwilling-barasinga.gigalixirapp.com", port: 443], http: [port: {:system, "PORT"}], @@ -19,7 +19,7 @@ config :podcast_feed, PodcastFeedWeb.Endpoint, version: Application.spec(:phoenix_distillery, :vsn) # force_ssl: [rewrite_on: [:x_forwarded_proto]] -config :podcast_feed, +config :openpod, cache_duration: :timer.hours(24) # Do not print debug messages in production @@ -30,7 +30,7 @@ config :logger, level: :info # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # -# config :podcast_feed, PodcastFeedWeb.Endpoint, +# config :openpod, OpenpodWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [ @@ -54,7 +54,7 @@ config :logger, level: :info # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # -# config :podcast_feed, PodcastFeedWeb.Endpoint, +# config :openpod, OpenpodWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. diff --git a/config/releases.exs b/config/releases.exs index 56f2c8c..d060cae 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -4,7 +4,7 @@ secret_key_base = System.fetch_env!("SECRET_KEY_BASE") application_port = System.fetch_env!("APP_PORT") application_host = System.fetch_env!("APP_HOST") -config :podcast_feed, PodcastFeedWeb.Endpoint, +config :openpod, OpenpodWeb.Endpoint, url: [scheme: "http", host: application_host, port: String.to_integer(application_port)], http: [:inet6, port: String.to_integer(application_port)], secret_key_base: secret_key_base diff --git a/config/test.exs b/config/test.exs index 2b65e42..5aaafcd 100644 --- a/config/test.exs +++ b/config/test.exs @@ -5,16 +5,16 @@ use Mix.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 :podcast_feed, PodcastFeed.Repo, +# config :openpod, Openpod.Repo, # username: "postgres", # password: "postgres", -# database: "podcast_feed_test#{System.get_env("MIX_TEST_PARTITION")}", +# database: "openpod_test#{System.get_env("MIX_TEST_PARTITION")}", # hostname: "localhost", # pool: Ecto.Adapters.SQL.Sandbox # We don't run a server during test. If one is required, # you can enable the server option below. -config :podcast_feed, PodcastFeedWeb.Endpoint, +config :openpod, OpenpodWeb.Endpoint, http: [port: 4002], server: false diff --git a/lib/podcast_feed.ex b/lib/openpod.ex similarity index 68% rename from lib/podcast_feed.ex rename to lib/openpod.ex index 3d2609b..c49b4b4 100644 --- a/lib/podcast_feed.ex +++ b/lib/openpod.ex @@ -1,12 +1,12 @@ -defmodule PodcastFeed do +defmodule Openpod do @moduledoc """ - PodcastFeed keeps the contexts that define your domain + Openpod keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others. """ - alias PodcastFeed.Provider.Archive + alias Openpod.Provider.Archive def archive(identifier) do Archive.Parser.by_identifier(identifier) diff --git a/lib/podcast_feed/application.ex b/lib/openpod/application.ex similarity index 70% rename from lib/podcast_feed/application.ex rename to lib/openpod/application.ex index 28b1db7..0cc4bfa 100644 --- a/lib/podcast_feed/application.ex +++ b/lib/openpod/application.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeed.Application do +defmodule Openpod.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false @@ -15,25 +15,25 @@ defmodule PodcastFeed.Application do # Start the dynamic supervisor in order to dynamically start podcast cache {DynamicSupervisor, [name: @archive_supervisor, strategy: :one_for_one]}, # Start the Telemetry supervisor - PodcastFeedWeb.Telemetry, + OpenpodWeb.Telemetry, # Start the PubSub system - {Phoenix.PubSub, name: PodcastFeed.PubSub}, + {Phoenix.PubSub, name: Openpod.PubSub}, # Start the Endpoint (http/https) - PodcastFeedWeb.Endpoint - # Start a worker by calling: PodcastFeed.Worker.start_link(arg) - # {PodcastFeed.Worker, arg} + OpenpodWeb.Endpoint + # Start a worker by calling: Openpod.Worker.start_link(arg) + # {Openpod.Worker, arg} ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: PodcastFeed.Supervisor] + opts = [strategy: :one_for_one, name: Openpod.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 - PodcastFeedWeb.Endpoint.config_change(changed, removed) + OpenpodWeb.Endpoint.config_change(changed, removed) :ok end end diff --git a/lib/podcast_feed/boundary/archive_server.ex b/lib/openpod/boundary/archive_server.ex similarity index 89% rename from lib/podcast_feed/boundary/archive_server.ex rename to lib/openpod/boundary/archive_server.ex index f4820ab..838a920 100644 --- a/lib/podcast_feed/boundary/archive_server.ex +++ b/lib/openpod/boundary/archive_server.ex @@ -1,10 +1,10 @@ -defmodule PodcastFeed.Boundary.ArchiveServer do +defmodule Openpod.Boundary.ArchiveServer do @moduledoc false use GenServer, restart: :temporary require Logger - alias PodcastFeed - alias PodcastFeed.Provider.Archive + alias Openpod + alias Openpod.Provider.Archive @registry :podcast_registry @archive_supervisor :archive_supervisor @@ -44,7 +44,7 @@ defmodule PodcastFeed.Boundary.ArchiveServer do def handle_call(:get_feed, _from, feed) do Logger.debug "retrieve cached feed data for #{feed[:identifier]}..." - {:reply, feed[:feed_data], feed, Application.fetch_env!(:podcast_feed, :cache_duration)} + {:reply, feed[:feed_data], feed, Application.fetch_env!(:openpod, :cache_duration)} end def handle_call(:reload, _from, feed) do diff --git a/lib/podcast_feed/provider/archive/parser.ex b/lib/openpod/provider/archive/parser.ex similarity index 96% rename from lib/podcast_feed/provider/archive/parser.ex rename to lib/openpod/provider/archive/parser.ex index 8105472..6928b08 100644 --- a/lib/podcast_feed/provider/archive/parser.ex +++ b/lib/openpod/provider/archive/parser.ex @@ -1,10 +1,10 @@ -defmodule PodcastFeed.Provider.Archive.Parser do +defmodule Openpod.Provider.Archive.Parser do @moduledoc """ This module provides a public API for fetching data from archive.org and convert them in a common podcast data structures. """ - alias PodcastFeed.Utility.Format + alias Openpod.Utility.Format alias __MODULE__ @archive_metadata_url "http://archive.org/metadata/{identifier}" @@ -29,10 +29,10 @@ defmodule PodcastFeed.Provider.Archive.Parser do def by_identifier(identifier) do %Parser{identifier: identifier} |> enrich_with_archive_metadata() - |> to_podcast_feed_data() + |> to_openpod_data() end - def to_podcast_feed_data(token) do + def to_openpod_data(token) do %{ podcast: podcast_data(token), items: items_data(token) diff --git a/lib/podcast_feed/utility/format.ex b/lib/openpod/utility/format.ex similarity index 87% rename from lib/podcast_feed/utility/format.ex rename to lib/openpod/utility/format.ex index 84561e3..f493ab5 100644 --- a/lib/podcast_feed/utility/format.ex +++ b/lib/openpod/utility/format.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeed.Utility.Format do +defmodule Openpod.Utility.Format do @moduledoc """ This module provides utility to format a string """ diff --git a/lib/podcast_feed_web.ex b/lib/openpod_web.ex similarity index 74% rename from lib/podcast_feed_web.ex rename to lib/openpod_web.ex index c57e851..f53a809 100644 --- a/lib/podcast_feed_web.ex +++ b/lib/openpod_web.ex @@ -1,12 +1,12 @@ -defmodule PodcastFeedWeb do +defmodule OpenpodWeb 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 PodcastFeedWeb, :controller - use PodcastFeedWeb, :view + use OpenpodWeb, :controller + use OpenpodWeb, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused @@ -19,19 +19,19 @@ defmodule PodcastFeedWeb do def controller do quote do - use Phoenix.Controller, namespace: PodcastFeedWeb + use Phoenix.Controller, namespace: OpenpodWeb import Plug.Conn - import PodcastFeedWeb.Gettext - alias PodcastFeedWeb.Router.Helpers, as: Routes + import OpenpodWeb.Gettext + alias OpenpodWeb.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, - root: "lib/podcast_feed_web/templates", - namespace: PodcastFeedWeb + root: "lib/openpod_web/templates", + namespace: OpenpodWeb # Import convenience functions from controllers import Phoenix.Controller, @@ -54,7 +54,7 @@ defmodule PodcastFeedWeb do def channel do quote do use Phoenix.Channel - import PodcastFeedWeb.Gettext + import OpenpodWeb.Gettext end end @@ -66,9 +66,9 @@ defmodule PodcastFeedWeb do # Import basic rendering functionality (render, render_layout, etc) import Phoenix.View - import PodcastFeedWeb.ErrorHelpers - import PodcastFeedWeb.Gettext - alias PodcastFeedWeb.Router.Helpers, as: Routes + import OpenpodWeb.ErrorHelpers + import OpenpodWeb.Gettext + alias OpenpodWeb.Router.Helpers, as: Routes end end diff --git a/lib/podcast_feed_web/channels/user_socket.ex b/lib/openpod_web/channels/user_socket.ex similarity index 84% rename from lib/podcast_feed_web/channels/user_socket.ex rename to lib/openpod_web/channels/user_socket.ex index fff1666..744a16b 100644 --- a/lib/podcast_feed_web/channels/user_socket.ex +++ b/lib/openpod_web/channels/user_socket.ex @@ -1,8 +1,8 @@ -defmodule PodcastFeedWeb.UserSocket do +defmodule OpenpodWeb.UserSocket do use Phoenix.Socket ## Channels - # channel "room:*", PodcastFeedWeb.RoomChannel + # channel "room:*", OpenpodWeb.RoomChannel # Socket params are passed from the client and can # be used to verify and authenticate a user. After @@ -27,7 +27,7 @@ defmodule PodcastFeedWeb.UserSocket do # Would allow you to broadcast a "disconnect" event and terminate # all active sockets and channels for a given user: # - # PodcastFeedWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) + # OpenpodWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) # # Returning `nil` makes this socket anonymous. @impl true diff --git a/lib/podcast_feed_web/controllers/feed_controller.ex b/lib/openpod_web/controllers/feed_controller.ex similarity index 82% rename from lib/podcast_feed_web/controllers/feed_controller.ex rename to lib/openpod_web/controllers/feed_controller.ex index 22ae924..156146c 100644 --- a/lib/podcast_feed_web/controllers/feed_controller.ex +++ b/lib/openpod_web/controllers/feed_controller.ex @@ -1,6 +1,6 @@ -defmodule PodcastFeedWeb.FeedController do - use PodcastFeedWeb, :controller - alias PodcastFeed.Boundary.ArchiveServer +defmodule OpenpodWeb.FeedController do + use OpenpodWeb, :controller + alias Openpod.Boundary.ArchiveServer def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do do_by_identifier(conn, identifier, fn -> ArchiveServer.reload(identifier) end) diff --git a/lib/openpod_web/controllers/page_controller.ex b/lib/openpod_web/controllers/page_controller.ex new file mode 100644 index 0000000..4b827eb --- /dev/null +++ b/lib/openpod_web/controllers/page_controller.ex @@ -0,0 +1,7 @@ +defmodule OpenpodWeb.PageController do + use OpenpodWeb, :controller + + def index(conn, _params) do + render(conn, "index.html") + end +end diff --git a/lib/podcast_feed_web/endpoint.ex b/lib/openpod_web/endpoint.ex similarity index 83% rename from lib/podcast_feed_web/endpoint.ex rename to lib/openpod_web/endpoint.ex index 8601e3d..3e00537 100644 --- a/lib/podcast_feed_web/endpoint.ex +++ b/lib/openpod_web/endpoint.ex @@ -1,16 +1,16 @@ -defmodule PodcastFeedWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :podcast_feed +defmodule OpenpodWeb.Endpoint do + use Phoenix.Endpoint, otp_app: :openpod # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, - key: "_podcast_feed_key", + key: "_openpod_key", signing_salt: "kxzln5AX" ] - socket "/socket", PodcastFeedWeb.UserSocket, + socket "/socket", OpenpodWeb.UserSocket, websocket: true, longpoll: false @@ -22,7 +22,7 @@ defmodule PodcastFeedWeb.Endpoint do # when deploying your static files in production. plug Plug.Static, at: "/", - from: :podcast_feed, + from: :openpod, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) @@ -32,7 +32,7 @@ defmodule PodcastFeedWeb.Endpoint do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader - # plug Phoenix.Ecto.CheckRepoStatus, otp_app: :podcast_feed + # plug Phoenix.Ecto.CheckRepoStatus, otp_app: :openpod end plug Phoenix.LiveDashboard.RequestLogger, @@ -50,5 +50,5 @@ defmodule PodcastFeedWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options - plug PodcastFeedWeb.Router + plug OpenpodWeb.Router end diff --git a/lib/podcast_feed_web/gettext.ex b/lib/openpod_web/gettext.ex similarity index 84% rename from lib/podcast_feed_web/gettext.ex rename to lib/openpod_web/gettext.ex index 8c16e31..d2af122 100644 --- a/lib/podcast_feed_web/gettext.ex +++ b/lib/openpod_web/gettext.ex @@ -1,11 +1,11 @@ -defmodule PodcastFeedWeb.Gettext do +defmodule OpenpodWeb.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 PodcastFeedWeb.Gettext + import OpenpodWeb.Gettext # Simple translation gettext("Here is the string to translate") @@ -20,5 +20,5 @@ defmodule PodcastFeedWeb.Gettext do See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ - use Gettext, otp_app: :podcast_feed + use Gettext, otp_app: :openpod end diff --git a/lib/podcast_feed_web/router.ex b/lib/openpod_web/router.ex similarity index 81% rename from lib/podcast_feed_web/router.ex rename to lib/openpod_web/router.ex index d9072a1..d9fa41f 100644 --- a/lib/podcast_feed_web/router.ex +++ b/lib/openpod_web/router.ex @@ -1,5 +1,5 @@ -defmodule PodcastFeedWeb.Router do - use PodcastFeedWeb, :router +defmodule OpenpodWeb.Router do + use OpenpodWeb, :router pipeline :browser do plug :accepts, ["html"] @@ -13,14 +13,14 @@ defmodule PodcastFeedWeb.Router do plug :accepts, ["json"] end - scope "/podcast", PodcastFeedWeb do + scope "/podcast", OpenpodWeb do pipe_through :browser get "/:identifier", FeedController, :by_identifier end # Other scopes may use custom stacks. - # scope "/api", PodcastFeedWeb do + # scope "/api", OpenpodWeb do # pipe_through :api # end @@ -36,7 +36,7 @@ defmodule PodcastFeedWeb.Router do scope "/" do pipe_through :browser - live_dashboard "/dashboard", metrics: PodcastFeedWeb.Telemetry + live_dashboard "/dashboard", metrics: OpenpodWeb.Telemetry end end end diff --git a/lib/podcast_feed_web/telemetry.ex b/lib/openpod_web/telemetry.ex similarity index 72% rename from lib/podcast_feed_web/telemetry.ex rename to lib/openpod_web/telemetry.ex index e554f61..5ae6197 100644 --- a/lib/podcast_feed_web/telemetry.ex +++ b/lib/openpod_web/telemetry.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeedWeb.Telemetry do +defmodule OpenpodWeb.Telemetry do use Supervisor import Telemetry.Metrics @@ -31,11 +31,11 @@ defmodule PodcastFeedWeb.Telemetry do ), # Database Metrics - summary("podcast_feed.repo.query.total_time", unit: {:native, :millisecond}), - summary("podcast_feed.repo.query.decode_time", unit: {:native, :millisecond}), - summary("podcast_feed.repo.query.query_time", unit: {:native, :millisecond}), - summary("podcast_feed.repo.query.queue_time", unit: {:native, :millisecond}), - summary("podcast_feed.repo.query.idle_time", unit: {:native, :millisecond}), + summary("openpod.repo.query.total_time", unit: {:native, :millisecond}), + summary("openpod.repo.query.decode_time", unit: {:native, :millisecond}), + summary("openpod.repo.query.query_time", unit: {:native, :millisecond}), + summary("openpod.repo.query.queue_time", unit: {:native, :millisecond}), + summary("openpod.repo.query.idle_time", unit: {:native, :millisecond}), # VM Metrics summary("vm.memory.total", unit: {:byte, :kilobyte}), @@ -49,7 +49,7 @@ defmodule PodcastFeedWeb.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. - # {PodcastFeedWeb, :count_users, []} + # {OpenpodWeb, :count_users, []} ] end end diff --git a/lib/podcast_feed_web/templates/feed/feed.xml.eex b/lib/openpod_web/templates/feed/feed.xml.eex similarity index 94% rename from lib/podcast_feed_web/templates/feed/feed.xml.eex rename to lib/openpod_web/templates/feed/feed.xml.eex index 50bc7a6..ca9dcef 100644 --- a/lib/podcast_feed_web/templates/feed/feed.xml.eex +++ b/lib/openpod_web/templates/feed/feed.xml.eex @@ -21,7 +21,7 @@ <%= @podcast.keywords |> Enum.join(", ") %> ]]> - + <%= @podcast.pubDate |> Calendar.DateTime.Format.rfc2822 %> <![CDATA[<%= @podcast.title %>]]> ]]> diff --git a/lib/podcast_feed_web/templates/layout/app.html.eex b/lib/openpod_web/templates/layout/app.html.eex similarity index 96% rename from lib/podcast_feed_web/templates/layout/app.html.eex rename to lib/openpod_web/templates/layout/app.html.eex index 3d820b4..cff8100 100644 --- a/lib/podcast_feed_web/templates/layout/app.html.eex +++ b/lib/openpod_web/templates/layout/app.html.eex @@ -4,7 +4,7 @@ - PodcastFeed · Phoenix Framework + Openpod · Phoenix Framework "/> diff --git a/lib/podcast_feed_web/templates/page/index.html.eex b/lib/openpod_web/templates/page/index.html.eex similarity index 100% rename from lib/podcast_feed_web/templates/page/index.html.eex rename to lib/openpod_web/templates/page/index.html.eex diff --git a/lib/podcast_feed_web/views/error_helpers.ex b/lib/openpod_web/views/error_helpers.ex similarity index 87% rename from lib/podcast_feed_web/views/error_helpers.ex rename to lib/openpod_web/views/error_helpers.ex index 6a57e2a..7924c88 100644 --- a/lib/podcast_feed_web/views/error_helpers.ex +++ b/lib/openpod_web/views/error_helpers.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeedWeb.ErrorHelpers do +defmodule OpenpodWeb.ErrorHelpers do @moduledoc """ Conveniences for translating and building error messages. """ @@ -39,9 +39,9 @@ defmodule PodcastFeedWeb.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(PodcastFeedWeb.Gettext, "errors", msg, msg, count, opts) + Gettext.dngettext(OpenpodWeb.Gettext, "errors", msg, msg, count, opts) else - Gettext.dgettext(PodcastFeedWeb.Gettext, "errors", msg, opts) + Gettext.dgettext(OpenpodWeb.Gettext, "errors", msg, opts) end end end diff --git a/lib/podcast_feed_web/views/error_view.ex b/lib/openpod_web/views/error_view.ex similarity index 86% rename from lib/podcast_feed_web/views/error_view.ex rename to lib/openpod_web/views/error_view.ex index 67edb73..e963b42 100644 --- a/lib/podcast_feed_web/views/error_view.ex +++ b/lib/openpod_web/views/error_view.ex @@ -1,5 +1,5 @@ -defmodule PodcastFeedWeb.ErrorView do - use PodcastFeedWeb, :view +defmodule OpenpodWeb.ErrorView do + use OpenpodWeb, :view # If you want to customize a particular status code # for a certain format, you may uncomment below. diff --git a/lib/podcast_feed_web/views/feed_view.ex b/lib/openpod_web/views/feed_view.ex similarity index 73% rename from lib/podcast_feed_web/views/feed_view.ex rename to lib/openpod_web/views/feed_view.ex index 36b067c..0523e7c 100644 --- a/lib/podcast_feed_web/views/feed_view.ex +++ b/lib/openpod_web/views/feed_view.ex @@ -1,5 +1,5 @@ -defmodule PodcastFeedWeb.FeedView do - use PodcastFeedWeb, :view +defmodule OpenpodWeb.FeedView do + use OpenpodWeb, :view def format_length(length) do min = length / 60 |> trunc() diff --git a/lib/openpod_web/views/layout_view.ex b/lib/openpod_web/views/layout_view.ex new file mode 100644 index 0000000..6ff047b --- /dev/null +++ b/lib/openpod_web/views/layout_view.ex @@ -0,0 +1,3 @@ +defmodule OpenpodWeb.LayoutView do + use OpenpodWeb, :view +end diff --git a/lib/openpod_web/views/page_view.ex b/lib/openpod_web/views/page_view.ex new file mode 100644 index 0000000..a259a89 --- /dev/null +++ b/lib/openpod_web/views/page_view.ex @@ -0,0 +1,3 @@ +defmodule OpenpodWeb.PageView do + use OpenpodWeb, :view +end diff --git a/lib/podcast_feed_web/controllers/page_controller.ex b/lib/podcast_feed_web/controllers/page_controller.ex deleted file mode 100644 index 93492dc..0000000 --- a/lib/podcast_feed_web/controllers/page_controller.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule PodcastFeedWeb.PageController do - use PodcastFeedWeb, :controller - - def index(conn, _params) do - render(conn, "index.html") - end -end diff --git a/lib/podcast_feed_web/views/layout_view.ex b/lib/podcast_feed_web/views/layout_view.ex deleted file mode 100644 index 4001e53..0000000 --- a/lib/podcast_feed_web/views/layout_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule PodcastFeedWeb.LayoutView do - use PodcastFeedWeb, :view -end diff --git a/lib/podcast_feed_web/views/page_view.ex b/lib/podcast_feed_web/views/page_view.ex deleted file mode 100644 index afddd5c..0000000 --- a/lib/podcast_feed_web/views/page_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule PodcastFeedWeb.PageView do - use PodcastFeedWeb, :view -end diff --git a/mix.exs b/mix.exs index 9861253..f5c27ef 100644 --- a/mix.exs +++ b/mix.exs @@ -1,9 +1,9 @@ -defmodule PodcastFeed.MixProject do +defmodule Openpod.MixProject do use Mix.Project def project do [ - app: :podcast_feed, + app: :openpod, version: "0.1.0", elixir: "~> 1.10", elixirc_paths: elixirc_paths(Mix.env()), @@ -21,7 +21,7 @@ defmodule PodcastFeed.MixProject do # Type `mix help compile.app` for more information. def application do [ - mod: {PodcastFeed.Application, []}, + mod: {Openpod.Application, []}, extra_applications: [:logger, :runtime_tools, :elixir_xml_to_map] ] end diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index bb74a43..283ea01 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -5,7 +5,7 @@ # Inside the script, you can read and write to any of your # repositories directly: # -# PodcastFeed.Repo.insert!(%PodcastFeed.SomeSchema{}) +# Openpod.Repo.insert!(%Openpod.SomeSchema{}) # # We recommend using the bang functions (`insert!`, `update!` # and so on) as they will fail if something goes wrong. diff --git a/test/podcast_feed/provider/archive/parser_test.exs b/test/openpod/provider/archive/parser_test.exs similarity index 94% rename from test/podcast_feed/provider/archive/parser_test.exs rename to test/openpod/provider/archive/parser_test.exs index 2ccaeab..4d60a45 100644 --- a/test/podcast_feed/provider/archive/parser_test.exs +++ b/test/openpod/provider/archive/parser_test.exs @@ -1,7 +1,7 @@ -defmodule PodcastFeed.Provider.Archive.ParserTest do +defmodule Openpod.Provider.Archive.ParserTest do use ExUnit.Case - alias PodcastFeed.Provider.Archive.Parser + alias Openpod.Provider.Archive.Parser setup_all do json_metadata = "{\"created\":1590247789,\"d1\":\"ia601402.us.archive.org\",\"d2\":\"ia801402.us.archive.org\",\"dir\":\"/8/items/incontri-a-piano-terra\",\"files\":[{\"name\": \"metadata.json\",\"source\": \"original\",\"mtime\": \"1590258296\",\"size\": \"315\",\"md5\": \"a0c0e219cf3f13e54f2a4b3efef8e5c8\",\"crc32\": \"2d181b5c\",\"sha1\": \"8244b579a759edddd01c905dd11f8565e83d0898\",\"format\": \"JSON\"},{\"name\": \"cover.jpg\",\"source\": \"original\",\"mtime\": \"1590258445\",\"size\": \"10650\",\"md5\": \"15687b23e11f0099abbfe64eb1685c31\",\"crc32\": \"fbb1516a\",\"sha1\": \"98fa929c7554241cfa92bea8eba69b39c5d47603\",\"format\": \"JPEG\",\"rotation\": \"0\"},{\"name\":\"Confini mobili sulle alpi.mp3\",\"source\":\"original\",\"mtime\":\"1590135989\",\"size\":\"46933494\",\"md5\":\"e832ee9381a4f8af2d9727e2f49126ae\",\"crc32\":\"d709dd90\",\"sha1\":\"89c820a2dfd63cfbbf7aeefd191c653756b33fe3\",\"format\":\"VBR MP3\",\"length\":\"3902.35\",\"height\":\"0\",\"width\":\"0\",\"title\":\"Confini mobili sulle alpi (italian limes)\",\"creator\":\"APE Milano\",\"album\":\"Incontri a Piano Terra\",\"track\":\"02\",\"artist\":\"APE Milano\",\"genre\":\"podcast\"},{\"name\":\"Confini mobili sulle alpi.png\",\"source\":\"derivative\",\"format\":\"PNG\",\"original\":\"Confini mobili sulle alpi.mp3\",\"mtime\":\"1590137809\",\"size\":\"34656\",\"md5\":\"63893f9b00402a107682b5317e808523\",\"crc32\":\"b59ff609\",\"sha1\":\"a396716431cd0acedd243030093d0b31d792cfb3\"},{\"name\":\"Confini mobili sulle alpi_spectrogram.png\",\"source\":\"derivative\",\"format\":\"Spectrogram\",\"original\":\"Confini mobili sulle alpi.mp3\",\"mtime\":\"1590137854\",\"size\":\"273188\",\"md5\":\"557337665c6d9f962b2e91d169f25e1b\",\"crc32\":\"08b4b57c\",\"sha1\":\"88e088f9c4954aa8f0849b7e0d69cee8d7d42327\"}],\"files_count\":31,\"item_last_updated\":1590160774,\"item_size\":244544362,\"metadata\":{\"identifier\":\"incontri-a-piano-terra\",\"mediatype\":\"audio\",\"collection\":\"opensource_audio\",\"creator\":\"APE Milano\",\"description\":\"Qualche registrazione delle attivit\\u00e0 sociali che promuoviamo al Piano Terra di Milano\",\"language\":\"ita\",\"licenseurl\":\"https://creativecommons.org/licenses/by-nc-nd/4.0/\",\"scanner\":\"Internet Archive HTML5 Uploader 1.6.4\",\"subject\":[\"ape milano\",\"podcast\",\"montagna\"],\"title\":\"Incontri a Piano Terra\",\"uploader\":\"milanoape@gmail.com\",\"publicdate\":\"2020-05-22 08:30:21\",\"addeddate\":\"2020-05-22 08:30:21\",\"curation\":\"[curator]validator@archive.org[/curator][date]20200522085526[/date][comment]checked for malware[/comment]\",\"op_link\":\"http://www.ape-alveare.it/\",\"op_category\":\"Montagna\",\"op_explicit\":\"no\"},\"server\":\"ia601402.us.archive.org\",\"uniq\":122833277,\"workable_servers\":[\"ia601402.us.archive.org\",\"ia801402.us.archive.org\"]}" @@ -15,7 +15,7 @@ defmodule PodcastFeed.Provider.Archive.ParserTest do end test "podcast data are correctly converted", state do - %{podcast: podcast} = Parser.to_podcast_feed_data(state[:token]) + %{podcast: podcast} = Parser.to_openpod_data(state[:token]) assert %{ title: "Incontri a Piano Terra", @@ -44,7 +44,7 @@ defmodule PodcastFeed.Provider.Archive.ParserTest do test "podcast subject metadata can also be a string", state do token = state[:token] |> Map.update!(:archive_metadata, fn metadata -> put_in(metadata, ["metadata", "subject"], "foo;bar;baz") end) - %{podcast: podcast} = Parser.to_podcast_feed_data(token) + %{podcast: podcast} = Parser.to_openpod_data(token) assert %{ keywords: ["foo", "bar", "baz"], @@ -52,7 +52,7 @@ defmodule PodcastFeed.Provider.Archive.ParserTest do end test "items data are correctly converted", state do - %{items: items} = Parser.to_podcast_feed_data(state[:token]) + %{items: items} = Parser.to_openpod_data(state[:token]) assert [ %{ diff --git a/test/podcast_feed/utility/format_test.exs b/test/openpod/utility/format_test.exs similarity index 66% rename from test/podcast_feed/utility/format_test.exs rename to test/openpod/utility/format_test.exs index 12c4949..f97e979 100644 --- a/test/podcast_feed/utility/format_test.exs +++ b/test/openpod/utility/format_test.exs @@ -1,7 +1,7 @@ -defmodule PodcastFeed.Utility.FormatTest do +defmodule Openpod.Utility.FormatTest do use ExUnit.Case - alias PodcastFeed.Utility.Format + alias Openpod.Utility.Format test "Test placeholder are replaced" do assert "http://foo/bar" == Format.compile("http://{host}/{path}", host: "foo", path: "bar") diff --git a/test/podcast_feed_web/controllers/page_controller_test.exs b/test/openpod_web/controllers/page_controller_test.exs similarity index 64% rename from test/podcast_feed_web/controllers/page_controller_test.exs rename to test/openpod_web/controllers/page_controller_test.exs index b8ead4e..e9f5286 100644 --- a/test/podcast_feed_web/controllers/page_controller_test.exs +++ b/test/openpod_web/controllers/page_controller_test.exs @@ -1,5 +1,5 @@ -defmodule PodcastFeedWeb.PageControllerTest do - use PodcastFeedWeb.ConnCase +defmodule OpenpodWeb.PageControllerTest do + use OpenpodWeb.ConnCase # test "GET /", %{conn: conn} do # conn = get(conn, "/") diff --git a/test/openpod_web/views/error_view_test.exs b/test/openpod_web/views/error_view_test.exs new file mode 100644 index 0000000..73067bd --- /dev/null +++ b/test/openpod_web/views/error_view_test.exs @@ -0,0 +1,14 @@ +defmodule OpenpodWeb.ErrorViewTest do + use OpenpodWeb.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(OpenpodWeb.ErrorView, "404.html", []) == "Not Found" + end + + test "renders 500.html" do + assert render_to_string(OpenpodWeb.ErrorView, "500.html", []) == "Internal Server Error" + end +end diff --git a/test/podcast_feed_web/views/layout_view_test.exs b/test/openpod_web/views/layout_view_test.exs similarity index 69% rename from test/podcast_feed_web/views/layout_view_test.exs rename to test/openpod_web/views/layout_view_test.exs index ac7e229..00d5856 100644 --- a/test/podcast_feed_web/views/layout_view_test.exs +++ b/test/openpod_web/views/layout_view_test.exs @@ -1,5 +1,5 @@ -defmodule PodcastFeedWeb.LayoutViewTest do - use PodcastFeedWeb.ConnCase, async: true +defmodule OpenpodWeb.LayoutViewTest do + use OpenpodWeb.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/test/openpod_web/views/page_view_test.exs b/test/openpod_web/views/page_view_test.exs new file mode 100644 index 0000000..a568f1b --- /dev/null +++ b/test/openpod_web/views/page_view_test.exs @@ -0,0 +1,3 @@ +defmodule OpenpodWeb.PageViewTest do + use OpenpodWeb.ConnCase, async: true +end diff --git a/test/podcast_feed_web/views/error_view_test.exs b/test/podcast_feed_web/views/error_view_test.exs deleted file mode 100644 index 1f8b5c4..0000000 --- a/test/podcast_feed_web/views/error_view_test.exs +++ /dev/null @@ -1,14 +0,0 @@ -defmodule PodcastFeedWeb.ErrorViewTest do - use PodcastFeedWeb.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(PodcastFeedWeb.ErrorView, "404.html", []) == "Not Found" - end - - test "renders 500.html" do - assert render_to_string(PodcastFeedWeb.ErrorView, "500.html", []) == "Internal Server Error" - end -end diff --git a/test/podcast_feed_web/views/page_view_test.exs b/test/podcast_feed_web/views/page_view_test.exs deleted file mode 100644 index 0031e95..0000000 --- a/test/podcast_feed_web/views/page_view_test.exs +++ /dev/null @@ -1,3 +0,0 @@ -defmodule PodcastFeedWeb.PageViewTest do - use PodcastFeedWeb.ConnCase, async: true -end diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index e32c5f3..c1812db 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeedWeb.ChannelCase do +defmodule OpenpodWeb.ChannelCase do @moduledoc """ This module defines the test case to be used by channel tests. @@ -11,7 +11,7 @@ defmodule PodcastFeedWeb.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 PodcastFeedWeb.ChannelCase, async: true`, although + by setting `use OpenpodWeb.ChannelCase, async: true`, although this option is not recommended for other databases. """ @@ -21,18 +21,18 @@ defmodule PodcastFeedWeb.ChannelCase do quote do # Import conveniences for testing with channels import Phoenix.ChannelTest - import PodcastFeedWeb.ChannelCase + import OpenpodWeb.ChannelCase # The default endpoint for testing - @endpoint PodcastFeedWeb.Endpoint + @endpoint OpenpodWeb.Endpoint end end setup tags do - # :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) + # :ok = Ecto.Adapters.SQL.Sandbox.checkout(Openpod.Repo) # unless tags[:async] do - # Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) + # Ecto.Adapters.SQL.Sandbox.mode(Openpod.Repo, {:shared, self()}) # end :ok diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 632ea27..a9dae21 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeedWeb.ConnCase do +defmodule OpenpodWeb.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 PodcastFeedWeb.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 PodcastFeedWeb.ConnCase, async: true`, although + by setting `use OpenpodWeb.ConnCase, async: true`, although this option is not recommended for other databases. """ @@ -22,20 +22,20 @@ defmodule PodcastFeedWeb.ConnCase do # Import conveniences for testing with connections import Plug.Conn import Phoenix.ConnTest - import PodcastFeedWeb.ConnCase + import OpenpodWeb.ConnCase - alias PodcastFeedWeb.Router.Helpers, as: Routes + alias OpenpodWeb.Router.Helpers, as: Routes # The default endpoint for testing - @endpoint PodcastFeedWeb.Endpoint + @endpoint OpenpodWeb.Endpoint end end setup tags do - # :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) + # :ok = Ecto.Adapters.SQL.Sandbox.checkout(Openpod.Repo) # unless tags[:async] do - # Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) + # Ecto.Adapters.SQL.Sandbox.mode(Openpod.Repo, {:shared, self()}) # end {:ok, conn: Phoenix.ConnTest.build_conn()} diff --git a/test/support/data_case.ex b/test/support/data_case.ex index d6dc3a4..982d7fa 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -1,4 +1,4 @@ -defmodule PodcastFeed.DataCase do +defmodule Openpod.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. @@ -10,7 +10,7 @@ defmodule PodcastFeed.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 PodcastFeed.DataCase, async: true`, although + by setting `use Openpod.DataCase, async: true`, although this option is not recommended for other databases. """ @@ -18,20 +18,20 @@ defmodule PodcastFeed.DataCase do using do quote do - alias PodcastFeed.Repo + alias Openpod.Repo # import Ecto # import Ecto.Changeset # import Ecto.Query - import PodcastFeed.DataCase + import Openpod.DataCase end end setup tags do - # :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) + # :ok = Ecto.Adapters.SQL.Sandbox.checkout(Openpod.Repo) # unless tags[:async] do - # Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) + # Ecto.Adapters.SQL.Sandbox.mode(Openpod.Repo, {:shared, self()}) # end :ok diff --git a/test/test_helper.exs b/test/test_helper.exs index 5e46dbb..447c410 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1,2 @@ ExUnit.start() -# Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, :manual) \ No newline at end of file +# Ecto.Adapters.SQL.Sandbox.mode(Openpod.Repo, :manual) \ No newline at end of file