diff --git a/Dockerfile b/Dockerfile index 882eab3..1ead3b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -132,23 +132,23 @@ RUN mix deps.get --only prod # install brunch & co -COPY package.json /app/ -RUN npm install +COPY assets/package.json /app/assets/ +RUN cd assets && npm install # compile assets with brunch and generate digest file -COPY brunch-config.js /app/ -COPY web/static /app/web/static -RUN node_modules/brunch/bin/brunch build --production && mix phoenix.digest +COPY assets /app/assets +RUN cd assets && node_modules/brunch/bin/brunch build --production +RUN mix phoenix.digest # add Elixir source files COPY config/*.exs /app/config/ COPY lib/*.ex /app/lib COPY lib/asciinema /app/lib/asciinema +COPY lib/asciinema_web /app/lib/asciinema_web COPY priv/gettext /app/priv/gettext COPY priv/repo /app/priv/repo -COPY web /app/web # compile Elixir app diff --git a/app/assets/javascripts/widget.js b/app/assets/javascripts/widget.js index 5f5ebf4..e640f06 120000 --- a/app/assets/javascripts/widget.js +++ b/app/assets/javascripts/widget.js @@ -1 +1 @@ -../../../web/static/assets/js/embed.js \ No newline at end of file +../../../assets/static/js/embed.js \ No newline at end of file diff --git a/assets/.gitignore b/assets/.gitignore new file mode 100644 index 0000000..07e6e47 --- /dev/null +++ b/assets/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/brunch-config.js b/assets/brunch-config.js similarity index 56% rename from brunch-config.js rename to assets/brunch-config.js index 70e3a9a..d138f99 100644 --- a/brunch-config.js +++ b/assets/brunch-config.js @@ -14,8 +14,8 @@ exports.config = { // To change the order of concatenation of files, explicitly mention here order: { before: [ - "web/static/vendor/js/jquery-2.2.4.min.js", - "web/static/vendor/js/bootstrap.js" + "vendor/js/jquery-2.2.4.min.js", + "vendor/js/bootstrap.js" ] } }, @@ -23,19 +23,19 @@ exports.config = { joinTo: "css/app.css", order: { before: [ - "web/static/vendor/css/bootstrap.css", - "web/static/css/source-sans-pro.css", - "web/static/css/base.sass", - "web/static/css/header.sass", - "web/static/css/flash.sass", - "web/static/css/footer.sass", - "web/static/css/home.sass", - "web/static/css/asciicasts.sass", - "web/static/css/users.sass", - "web/static/css/preview.sass", - "web/static/css/player.sass", - "web/static/css/contributing.sass", - "web/static/css/simple-layout.sass", + "vendor/css/bootstrap.css", + "css/source-sans-pro.css", + "css/base.sass", + "css/header.sass", + "css/flash.sass", + "css/footer.sass", + "css/home.sass", + "css/asciicasts.sass", + "css/users.sass", + "css/preview.sass", + "css/player.sass", + "css/contributing.sass", + "css/simple-layout.sass", ] } }, @@ -46,34 +46,31 @@ exports.config = { conventions: { // This option sets where we should place non-css and non-js assets in. - // By default, we set this to "/web/static/assets". Files in this directory + // By default, we set this to "/assets/static". Files in this directory // will be copied to `paths.public`, which is "priv/static" by default. - assets: /^(web\/static\/assets)/ + assets: /^(static)/ }, // Phoenix paths configuration paths: { // Dependencies and current project directories to watch - watched: [ - "web/static", - "test/static" - ], + watched: ["static", "css", "js", "vendor"], // Where to compile files to - public: "priv/static" + public: "../priv/static" }, // Configure your plugins plugins: { babel: { // Do not use ES6 compiler in vendor code - ignore: [/web\/static\/vendor/] + ignore: [/vendor/] } }, modules: { autoRequire: { - "js/app.js": ["web/static/js/app"] + "js/app.js": ["js/app"] } }, diff --git a/web/static/css/asciicasts.sass b/assets/css/asciicasts.sass similarity index 100% rename from web/static/css/asciicasts.sass rename to assets/css/asciicasts.sass diff --git a/web/static/css/base.sass b/assets/css/base.sass similarity index 100% rename from web/static/css/base.sass rename to assets/css/base.sass diff --git a/web/static/css/contributing.sass b/assets/css/contributing.sass similarity index 100% rename from web/static/css/contributing.sass rename to assets/css/contributing.sass diff --git a/web/static/css/flash.sass b/assets/css/flash.sass similarity index 100% rename from web/static/css/flash.sass rename to assets/css/flash.sass diff --git a/web/static/css/footer.sass b/assets/css/footer.sass similarity index 100% rename from web/static/css/footer.sass rename to assets/css/footer.sass diff --git a/web/static/css/header.sass b/assets/css/header.sass similarity index 100% rename from web/static/css/header.sass rename to assets/css/header.sass diff --git a/web/static/css/home.sass b/assets/css/home.sass similarity index 100% rename from web/static/css/home.sass rename to assets/css/home.sass diff --git a/web/static/css/player.sass b/assets/css/player.sass similarity index 100% rename from web/static/css/player.sass rename to assets/css/player.sass diff --git a/web/static/css/preview.sass b/assets/css/preview.sass similarity index 100% rename from web/static/css/preview.sass rename to assets/css/preview.sass diff --git a/web/static/css/simple-layout.sass b/assets/css/simple-layout.sass similarity index 100% rename from web/static/css/simple-layout.sass rename to assets/css/simple-layout.sass diff --git a/web/static/css/source-sans-pro.css b/assets/css/source-sans-pro.css similarity index 100% rename from web/static/css/source-sans-pro.css rename to assets/css/source-sans-pro.css diff --git a/web/static/css/users.sass b/assets/css/users.sass similarity index 100% rename from web/static/css/users.sass rename to assets/css/users.sass diff --git a/web/static/js/app.js b/assets/js/app.js similarity index 100% rename from web/static/js/app.js rename to assets/js/app.js diff --git a/web/static/js/socket.js b/assets/js/socket.js similarity index 100% rename from web/static/js/socket.js rename to assets/js/socket.js diff --git a/package.json b/assets/package.json similarity index 58% rename from package.json rename to assets/package.json index 86fd5cc..c28a643 100644 --- a/package.json +++ b/assets/package.json @@ -6,16 +6,16 @@ "watch": "brunch watch --stdin" }, "dependencies": { - "phoenix": "file:deps/phoenix", - "phoenix_html": "file:deps/phoenix_html" + "phoenix": "file:../deps/phoenix", + "phoenix_html": "file:../deps/phoenix_html" }, "devDependencies": { - "babel-brunch": "~6.0.0", - "brunch": "2.7.4", - "clean-css-brunch": "~2.0.0", + "babel-brunch": "6.0.6", + "brunch": "2.10.7", + "clean-css-brunch": "2.10.0", "css-brunch": "~2.0.0", "sass-brunch": "^2.6.3", "javascript-brunch": "~2.0.0", - "uglify-js-brunch": "~2.0.1" + "uglify-js-brunch": "2.1.1" } } diff --git a/web/static/assets/fonts/SourceSansPro-Bold.ttf b/assets/static/fonts/SourceSansPro-Bold.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-Bold.ttf rename to assets/static/fonts/SourceSansPro-Bold.ttf diff --git a/web/static/assets/fonts/SourceSansPro-BoldItalic.ttf b/assets/static/fonts/SourceSansPro-BoldItalic.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-BoldItalic.ttf rename to assets/static/fonts/SourceSansPro-BoldItalic.ttf diff --git a/web/static/assets/fonts/SourceSansPro-Italic.ttf b/assets/static/fonts/SourceSansPro-Italic.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-Italic.ttf rename to assets/static/fonts/SourceSansPro-Italic.ttf diff --git a/web/static/assets/fonts/SourceSansPro-Light.ttf b/assets/static/fonts/SourceSansPro-Light.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-Light.ttf rename to assets/static/fonts/SourceSansPro-Light.ttf diff --git a/web/static/assets/fonts/SourceSansPro-LightItalic.ttf b/assets/static/fonts/SourceSansPro-LightItalic.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-LightItalic.ttf rename to assets/static/fonts/SourceSansPro-LightItalic.ttf diff --git a/web/static/assets/fonts/SourceSansPro-Regular.ttf b/assets/static/fonts/SourceSansPro-Regular.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-Regular.ttf rename to assets/static/fonts/SourceSansPro-Regular.ttf diff --git a/web/static/assets/fonts/SourceSansPro-Semibold.ttf b/assets/static/fonts/SourceSansPro-Semibold.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-Semibold.ttf rename to assets/static/fonts/SourceSansPro-Semibold.ttf diff --git a/web/static/assets/fonts/SourceSansPro-SemiboldItalic.ttf b/assets/static/fonts/SourceSansPro-SemiboldItalic.ttf similarity index 100% rename from web/static/assets/fonts/SourceSansPro-SemiboldItalic.ttf rename to assets/static/fonts/SourceSansPro-SemiboldItalic.ttf diff --git a/web/static/assets/fonts/glyphicons-halflings-regular.eot b/assets/static/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from web/static/assets/fonts/glyphicons-halflings-regular.eot rename to assets/static/fonts/glyphicons-halflings-regular.eot diff --git a/web/static/assets/fonts/glyphicons-halflings-regular.svg b/assets/static/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from web/static/assets/fonts/glyphicons-halflings-regular.svg rename to assets/static/fonts/glyphicons-halflings-regular.svg diff --git a/web/static/assets/fonts/glyphicons-halflings-regular.ttf b/assets/static/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from web/static/assets/fonts/glyphicons-halflings-regular.ttf rename to assets/static/fonts/glyphicons-halflings-regular.ttf diff --git a/web/static/assets/fonts/glyphicons-halflings-regular.woff b/assets/static/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from web/static/assets/fonts/glyphicons-halflings-regular.woff rename to assets/static/fonts/glyphicons-halflings-regular.woff diff --git a/web/static/assets/images/brightbox.png b/assets/static/images/brightbox.png similarity index 100% rename from web/static/assets/images/brightbox.png rename to assets/static/images/brightbox.png diff --git a/web/static/assets/images/favicon.png b/assets/static/images/favicon.png similarity index 100% rename from web/static/assets/images/favicon.png rename to assets/static/images/favicon.png diff --git a/web/static/assets/images/home-bg.jpg b/assets/static/images/home-bg.jpg similarity index 100% rename from web/static/assets/images/home-bg.jpg rename to assets/static/images/home-bg.jpg diff --git a/web/static/assets/images/logo-red.svg b/assets/static/images/logo-red.svg similarity index 100% rename from web/static/assets/images/logo-red.svg rename to assets/static/images/logo-red.svg diff --git a/web/static/assets/js/embed.js b/assets/static/js/embed.js similarity index 100% rename from web/static/assets/js/embed.js rename to assets/static/js/embed.js diff --git a/web/static/assets/robots.txt b/assets/static/robots.txt similarity index 100% rename from web/static/assets/robots.txt rename to assets/static/robots.txt diff --git a/web/static/vendor/css/bootstrap.css b/assets/vendor/css/bootstrap.css similarity index 100% rename from web/static/vendor/css/bootstrap.css rename to assets/vendor/css/bootstrap.css diff --git a/web/static/vendor/fonts/glyphicons-halflings-regular.eot b/assets/vendor/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from web/static/vendor/fonts/glyphicons-halflings-regular.eot rename to assets/vendor/fonts/glyphicons-halflings-regular.eot diff --git a/web/static/vendor/fonts/glyphicons-halflings-regular.svg b/assets/vendor/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from web/static/vendor/fonts/glyphicons-halflings-regular.svg rename to assets/vendor/fonts/glyphicons-halflings-regular.svg diff --git a/web/static/vendor/fonts/glyphicons-halflings-regular.ttf b/assets/vendor/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from web/static/vendor/fonts/glyphicons-halflings-regular.ttf rename to assets/vendor/fonts/glyphicons-halflings-regular.ttf diff --git a/web/static/vendor/fonts/glyphicons-halflings-regular.woff b/assets/vendor/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from web/static/vendor/fonts/glyphicons-halflings-regular.woff rename to assets/vendor/fonts/glyphicons-halflings-regular.woff diff --git a/web/static/vendor/fonts/glyphicons-halflings-regular.woff2 b/assets/vendor/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from web/static/vendor/fonts/glyphicons-halflings-regular.woff2 rename to assets/vendor/fonts/glyphicons-halflings-regular.woff2 diff --git a/web/static/vendor/js/bootstrap.js b/assets/vendor/js/bootstrap.js similarity index 100% rename from web/static/vendor/js/bootstrap.js rename to assets/vendor/js/bootstrap.js diff --git a/web/static/vendor/js/jquery-2.2.4.min.js b/assets/vendor/js/jquery-2.2.4.min.js similarity index 100% rename from web/static/vendor/js/jquery-2.2.4.min.js rename to assets/vendor/js/jquery-2.2.4.min.js diff --git a/config/config.exs b/config/config.exs index 50014f8..7fa5a76 100644 --- a/config/config.exs +++ b/config/config.exs @@ -10,10 +10,10 @@ config :asciinema, ecto_repos: [Asciinema.Repo] # Configures the endpoint -config :asciinema, Asciinema.Endpoint, +config :asciinema, AsciinemaWeb.Endpoint, url: [host: "localhost"], secret_key_base: System.get_env("SECRET_KEY_BASE"), - render_errors: [view: Asciinema.ErrorView, accepts: ~w(html json)], + render_errors: [view: AsciinemaWeb.ErrorView, accepts: ~w(html json)], pubsub: [name: Asciinema.PubSub, adapter: Phoenix.PubSub.PG2] diff --git a/config/dev.exs b/config/dev.exs index 52b31d9..887f997 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -6,24 +6,24 @@ use Mix.Config # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with brunch.io to recompile .js and .css sources. -config :asciinema, Asciinema.Endpoint, +config :asciinema, AsciinemaWeb.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, secret_key_base: System.get_env("SECRET_KEY_BASE") || "60BnXnzGGwwiZj91YA9XYKF9BCiM7lQ/1um8VXcWWLSdUp9OcPZV6YnQv7eFTYSY", watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin", - cd: Path.expand("../", __DIR__)]] + cd: Path.expand("../assets", __DIR__)]] # Watch static and templates for browser reloading. -config :asciinema, Asciinema.Endpoint, +config :asciinema, AsciinemaWeb.Endpoint, live_reload: [ patterns: [ ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, ~r{priv/gettext/.*(po)$}, - ~r{web/views/.*(ex)$}, - ~r{web/templates/.*(eex|md)$} + ~r{lib/asciinema_web/views/.*(ex)$}, + ~r{lib/asciinema_web/templates/.*(eex|md)$} ] ] diff --git a/config/prod.exs b/config/prod.exs index 558a7e4..711c48d 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -11,12 +11,12 @@ use Mix.Config # containing the digested version of static files. This # manifest is generated by the mix phoenix.digest task # which you typically run after static files are built. -config :asciinema, Asciinema.Endpoint, +config :asciinema, AsciinemaWeb.Endpoint, http: [port: {:system, "PORT"}], url: [scheme: System.get_env("URL_SCHEME") || "https", host: System.get_env("URL_HOST") || "asciinema.org", port: String.to_integer(System.get_env("URL_PORT") || "443")], - cache_static_manifest: "priv/static/manifest.json" + cache_static_manifest: "priv/static/cache_manifest.json" # Do not print debug messages in production config :logger, level: :info @@ -26,7 +26,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 :asciinema, Asciinema.Endpoint, +# config :asciinema, AsciinemaWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [port: 443, @@ -40,7 +40,7 @@ config :logger, level: :info # We also recommend setting `force_ssl`, ensuring no data is # ever sent via http, always redirecting to https: # -# config :asciinema, Asciinema.Endpoint, +# config :asciinema, AsciinemaWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. @@ -55,7 +55,7 @@ config :logger, level: :info # Alternatively, you can configure exactly which server to # start per endpoint: # -# config :asciinema, Asciinema.Endpoint, server: true +# config :asciinema, AsciinemaWeb.Endpoint, server: true # config :asciinema, Asciinema.Repo, diff --git a/config/test.exs b/config/test.exs index 59a7ff1..1f23027 100644 --- a/config/test.exs +++ b/config/test.exs @@ -2,7 +2,7 @@ use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. -config :asciinema, Asciinema.Endpoint, +config :asciinema, AsciinemaWeb.Endpoint, http: [port: 4001], secret_key_base: "ssecretkeybasesecretkeybasesecretkeybasesecretkeybaseecretkeybase", server: false diff --git a/lib/asciinema.ex b/lib/asciinema/application.ex similarity index 78% rename from lib/asciinema.ex rename to lib/asciinema/application.ex index bcf5362..c9081f0 100644 --- a/lib/asciinema.ex +++ b/lib/asciinema/application.ex @@ -1,4 +1,4 @@ -defmodule Asciinema do +defmodule Asciinema.Application do use Application # See http://elixir-lang.org/docs/stable/elixir/Application.html @@ -13,7 +13,7 @@ defmodule Asciinema do # Start the Ecto repository supervisor(Asciinema.Repo, []), # Start the endpoint when the application starts - supervisor(Asciinema.Endpoint, []), + supervisor(AsciinemaWeb.Endpoint, []), # Start your own worker by calling: Asciinema.Worker.start_link(arg1, arg2, arg3) # worker(Asciinema.Worker, [arg1, arg2, arg3]), :poolboy.child_spec(:worker, Asciinema.PngGenerator.A2png.poolboy_config(), []), @@ -27,11 +27,4 @@ defmodule Asciinema do opts = [strategy: :one_for_one, name: Asciinema.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 - Asciinema.Endpoint.config_change(changed, removed) - :ok - end end diff --git a/web/models/asciicast.ex b/lib/asciinema/asciicasts/asciicast.ex similarity index 95% rename from web/models/asciicast.ex rename to lib/asciinema/asciicasts/asciicast.ex index 29df450..f32da1e 100644 --- a/web/models/asciicast.ex +++ b/lib/asciinema/asciicasts/asciicast.ex @@ -1,6 +1,8 @@ -defmodule Asciinema.Asciicast do - use Asciinema.Web, :model - alias Asciinema.{User, Asciicast} +defmodule Asciinema.Asciicasts.Asciicast do + use Ecto.Schema + import Ecto.Changeset + alias Asciinema.Users.User + alias Asciinema.Asciicasts.Asciicast alias Asciinema.PngGenerator.PngParams @default_png_scale 2 diff --git a/lib/asciinema/asciicasts.ex b/lib/asciinema/asciicasts/asciicasts.ex similarity index 98% rename from lib/asciinema/asciicasts.ex rename to lib/asciinema/asciicasts/asciicasts.ex index 0966a93..02885a2 100644 --- a/lib/asciinema/asciicasts.ex +++ b/lib/asciinema/asciicasts/asciicasts.ex @@ -1,7 +1,7 @@ defmodule Asciinema.Asciicasts do import Ecto.Query, warn: false - alias Asciinema.{Repo, Asciicast, FileStore, StringUtils, Vt} - alias Asciinema.Asciicasts.{SnapshotUpdater, FramesGenerator} + alias Asciinema.{Repo, FileStore, StringUtils, Vt} + alias Asciinema.Asciicasts.{Asciicast, SnapshotUpdater, FramesGenerator} def get_asciicast!(id) when is_integer(id) do Repo.get!(Asciicast, id) diff --git a/lib/asciinema/asciicasts/frames_generator.ex b/lib/asciinema/asciicasts/frames_generator.ex index b742e94..0bf672a 100644 --- a/lib/asciinema/asciicasts/frames_generator.ex +++ b/lib/asciinema/asciicasts/frames_generator.ex @@ -1,5 +1,5 @@ defmodule Asciinema.Asciicasts.FramesGenerator do - alias Asciinema.Asciicast + alias Asciinema.Asciicasts.Asciicast @doc "Generates frames file for given asciicast" @callback generate_frames(asciicast :: %Asciicast{}) :: :ok | {:error, term} diff --git a/lib/asciinema/asciicasts/frames_generator/sidekiq.ex b/lib/asciinema/asciicasts/frames_generator/sidekiq.ex index 06b3e35..b6a67c5 100644 --- a/lib/asciinema/asciicasts/frames_generator/sidekiq.ex +++ b/lib/asciinema/asciicasts/frames_generator/sidekiq.ex @@ -1,5 +1,5 @@ defmodule Asciinema.Asciicasts.FramesGenerator.Sidekiq do - alias Asciinema.Asciicast + alias Asciinema.Asciicasts.Asciicast alias Asciinema.SidekiqClient def generate_frames(%Asciicast{id: id}) do diff --git a/lib/asciinema/asciicasts/snapshot_updater.ex b/lib/asciinema/asciicasts/snapshot_updater.ex index fc6f6c2..824b249 100644 --- a/lib/asciinema/asciicasts/snapshot_updater.ex +++ b/lib/asciinema/asciicasts/snapshot_updater.ex @@ -1,5 +1,5 @@ defmodule Asciinema.Asciicasts.SnapshotUpdater do - alias Asciinema.Asciicast + alias Asciinema.Asciicasts.Asciicast @doc "Generates poster for given asciicast" @callback update_snapshot(asciicast :: %Asciicast{}) :: :ok | {:error, term} diff --git a/lib/asciinema/asciicasts/snapshot_updater/exq.ex b/lib/asciinema/asciicasts/snapshot_updater/exq.ex index af5bad8..04a828f 100644 --- a/lib/asciinema/asciicasts/snapshot_updater/exq.ex +++ b/lib/asciinema/asciicasts/snapshot_updater/exq.ex @@ -1,5 +1,6 @@ defmodule Asciinema.Asciicasts.SnapshotUpdater.Exq do - alias Asciinema.{Repo, Asciicasts, Asciicast} + alias Asciinema.{Repo, Asciicasts} + alias Asciinema.Asciicasts.Asciicast def update_snapshot(%Asciicast{id: id}) do {:ok, _jid} = Exq.enqueue(Exq, "default", __MODULE__, [id]) diff --git a/lib/asciinema/asciicasts/snapshot_updater/sync.ex b/lib/asciinema/asciicasts/snapshot_updater/sync.ex index 699ecfe..4c1457c 100644 --- a/lib/asciinema/asciicasts/snapshot_updater/sync.ex +++ b/lib/asciinema/asciicasts/snapshot_updater/sync.ex @@ -1,5 +1,6 @@ defmodule Asciinema.Asciicasts.SnapshotUpdater.Sync do - alias Asciinema.{Asciicast, Asciicasts} + alias Asciinema.Asciicasts + alias Asciinema.Asciicasts.Asciicast def update_snapshot(%Asciicast{} = asciicast) do {:ok, _} = Asciicasts.update_snapshot(asciicast) diff --git a/lib/asciinema/email.ex b/lib/asciinema/email.ex index 79d784e..fa9329a 100644 --- a/lib/asciinema/email.ex +++ b/lib/asciinema/email.ex @@ -1,5 +1,5 @@ defmodule Asciinema.Email do - use Bamboo.Phoenix, view: Asciinema.EmailView + use Bamboo.Phoenix, view: AsciinemaWeb.EmailView import Bamboo.Email def signup_email(email_address, signup_url) do diff --git a/lib/asciinema/file_store/local.ex b/lib/asciinema/file_store/local.ex index 040ca2a..731b0cc 100644 --- a/lib/asciinema/file_store/local.ex +++ b/lib/asciinema/file_store/local.ex @@ -1,7 +1,6 @@ defmodule Asciinema.FileStore.Local do use Asciinema.FileStore import Plug.Conn - alias Plug.MIME def put_file(dst_path, src_local_path, _content_type, _compress \\ false) do full_dst_path = base_path() <> dst_path @@ -24,7 +23,7 @@ defmodule Asciinema.FileStore.Local do defp do_serve_file(conn, path) do conn - |> put_resp_header("content-type", MIME.path(path)) + |> put_resp_header("content-type", MIME.from_path(path)) |> send_file(200, base_path() <> path) |> halt end diff --git a/lib/asciinema/png_generator.ex b/lib/asciinema/png_generator.ex index a049658..1bd94f3 100644 --- a/lib/asciinema/png_generator.ex +++ b/lib/asciinema/png_generator.ex @@ -1,5 +1,5 @@ defmodule Asciinema.PngGenerator do - alias Asciinema.Asciicast + alias Asciinema.Asciicasts.Asciicast alias Asciinema.PngGenerator.PngParams @doc "Generates PNG image from asciicast and returns path to it" diff --git a/lib/asciinema/png_generator/a2png.ex b/lib/asciinema/png_generator/a2png.ex index 0cccd9e..1c2fd84 100644 --- a/lib/asciinema/png_generator/a2png.ex +++ b/lib/asciinema/png_generator/a2png.ex @@ -1,7 +1,7 @@ defmodule Asciinema.PngGenerator.A2png do @behaviour Asciinema.PngGenerator use GenServer - alias Asciinema.Asciicast + alias Asciinema.Asciicasts.Asciicast alias Asciinema.PngGenerator.PngParams @pool_name :worker diff --git a/web/models/api_token.ex b/lib/asciinema/users/api_token.ex similarity index 79% rename from web/models/api_token.ex rename to lib/asciinema/users/api_token.ex index e0c0906..bb6a271 100644 --- a/web/models/api_token.ex +++ b/lib/asciinema/users/api_token.ex @@ -1,6 +1,7 @@ -defmodule Asciinema.ApiToken do - use Asciinema.Web, :model - alias Asciinema.{ApiToken, User} +defmodule Asciinema.Users.ApiToken do + use Ecto.Schema + import Ecto.Changeset + alias Asciinema.Users.{ApiToken, User} schema "api_tokens" do field :token, :string @@ -8,7 +9,7 @@ defmodule Asciinema.ApiToken do timestamps(inserted_at: :created_at) - belongs_to :user, Asciinema.User + belongs_to :user, User end @uuid4 ~r/\A[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\z/ diff --git a/web/models/user.ex b/lib/asciinema/users/user.ex similarity index 85% rename from web/models/user.ex rename to lib/asciinema/users/user.ex index d007e05..421ed7e 100644 --- a/web/models/user.ex +++ b/lib/asciinema/users/user.ex @@ -1,6 +1,7 @@ -defmodule Asciinema.User do - use Asciinema.Web, :model - alias Asciinema.User +defmodule Asciinema.Users.User do + use Ecto.Schema + import Ecto.Changeset + alias Asciinema.Users.User @valid_email_re ~r/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i @@ -16,8 +17,8 @@ defmodule Asciinema.User do timestamps(inserted_at: :created_at) - has_many :asciicasts, Asciinema.Asciicast - has_many :api_tokens, Asciinema.ApiToken + has_many :asciicasts, Asciinema.Asciicasts.Asciicast + has_many :api_tokens, Asciinema.Users.ApiToken end def changeset(struct, params \\ %{}) do diff --git a/lib/asciinema/users.ex b/lib/asciinema/users/users.ex similarity index 90% rename from lib/asciinema/users.ex rename to lib/asciinema/users/users.ex index 71e325d..12f48a5 100644 --- a/lib/asciinema/users.ex +++ b/lib/asciinema/users/users.ex @@ -1,7 +1,8 @@ defmodule Asciinema.Users do import Ecto.Query, warn: false import Ecto, only: [assoc: 2] - alias Asciinema.{Repo, User, ApiToken, Asciicasts, Email, Mailer, Auth} + alias Asciinema.Users.{User, ApiToken} + alias Asciinema.{Repo, Asciicasts, Email, Mailer} def create_asciinema_user!() do attrs = %{username: "asciinema", @@ -80,20 +81,20 @@ defmodule Asciinema.Users do end defp signup_url(email) do - token = Phoenix.Token.sign(Asciinema.Endpoint, "signup", email) - Asciinema.Router.Helpers.users_url(Asciinema.Endpoint, :new, t: token) + token = Phoenix.Token.sign(AsciinemaWeb.Endpoint, "signup", email) + AsciinemaWeb.Router.Helpers.users_url(AsciinemaWeb.Endpoint, :new, t: token) end defp login_url(%User{id: id, last_login_at: last_login_at}) do last_login_at = last_login_at && Timex.to_unix(last_login_at) - token = Phoenix.Token.sign(Asciinema.Endpoint, "login", {id, last_login_at}) - Asciinema.Router.Helpers.session_url(Asciinema.Endpoint, :new, t: token) + token = Phoenix.Token.sign(AsciinemaWeb.Endpoint, "login", {id, last_login_at}) + AsciinemaWeb.Router.Helpers.session_url(AsciinemaWeb.Endpoint, :new, t: token) end @login_token_max_age 15 * 60 # 15 minutes alias Phoenix.Token - alias Asciinema.Endpoint + alias AsciinemaWeb.Endpoint def verify_signup_token(token) do with {:ok, email} <- Token.verify(Endpoint, "signup", token, max_age: @login_token_max_age), @@ -124,11 +125,6 @@ defmodule Asciinema.Users do end end - def log_in(conn, %User{} = user) do - user = user |> User.login_changeset |> Repo.update! - Auth.login(conn, user) - end - def authenticate(api_token) do q = from u in User, join: at in ApiToken, diff --git a/web/web.ex b/lib/asciinema_web.ex similarity index 62% rename from web/web.ex rename to lib/asciinema_web.ex index a63e8c6..8f6e2b4 100644 --- a/web/web.ex +++ b/lib/asciinema_web.ex @@ -1,12 +1,12 @@ -defmodule Asciinema.Web do +defmodule AsciinemaWeb do @moduledoc """ A module that keeps using definitions for controllers, views and so on. This can be used in your application as: - use Asciinema.Web, :controller - use Asciinema.Web, :view + use AsciinemaWeb, :controller + use AsciinemaWeb, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused @@ -16,35 +16,25 @@ defmodule Asciinema.Web do below. """ - def model do - quote do - use Ecto.Schema - @timestamps_opts inserted_at: :created_at - - import Ecto - import Ecto.Changeset - import Ecto.Query - end - end - def controller do quote do - use Phoenix.Controller + use Phoenix.Controller, namespace: AsciinemaWeb alias Asciinema.Repo import Ecto import Ecto.Query - import Asciinema.Router.Helpers - import Asciinema.Router.Helpers.Extra - import Asciinema.Gettext - import Asciinema.Rails.Flash + import AsciinemaWeb.Router.Helpers + import AsciinemaWeb.Router.Helpers.Extra + import AsciinemaWeb.Gettext + import AsciinemaWeb.Rails.Flash end end def view do quote do - use Phoenix.View, root: "web/templates" + use Phoenix.View, root: "lib/asciinema_web/templates", + namespace: AsciinemaWeb # Import convenience functions from controllers import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1] @@ -52,10 +42,10 @@ defmodule Asciinema.Web do # Use all HTML functionality (forms, tags, etc) use Phoenix.HTML - import Asciinema.Router.Helpers - import Asciinema.Router.Helpers.Extra - import Asciinema.ErrorHelpers - import Asciinema.Gettext + import AsciinemaWeb.Router.Helpers + import AsciinemaWeb.Router.Helpers.Extra + import AsciinemaWeb.ErrorHelpers + import AsciinemaWeb.Gettext end end @@ -73,7 +63,7 @@ defmodule Asciinema.Web do alias Asciinema.Repo import Ecto import Ecto.Query - import Asciinema.Gettext + import AsciinemaWeb.Gettext end end diff --git a/lib/asciinema/auth.ex b/lib/asciinema_web/auth.ex similarity index 77% rename from lib/asciinema/auth.ex rename to lib/asciinema_web/auth.ex index 129e30c..d19d1e8 100644 --- a/lib/asciinema/auth.ex +++ b/lib/asciinema_web/auth.ex @@ -1,6 +1,7 @@ -defmodule Asciinema.Auth do +defmodule AsciinemaWeb.Auth do import Plug.Conn - alias Asciinema.{Repo, User} + alias Asciinema.Users.User + alias Asciinema.Repo @user_key "warden.user.user.key" @one_year_in_secs 31557600 @@ -18,10 +19,12 @@ defmodule Asciinema.Auth do assign(conn, :current_user, user) end - def login(conn, %User{id: id, auth_token: auth_token} = user) do + def log_in(conn, %User{} = user) do + user = user |> User.login_changeset |> Repo.update! + conn - |> put_session(@user_key, id) - |> put_resp_cookie("auth_token", auth_token, max_age: @one_year_in_secs) + |> put_session(@user_key, user.id) + |> put_resp_cookie("auth_token", user.auth_token, max_age: @one_year_in_secs) |> assign(:current_user, user) end diff --git a/web/channels/user_socket.ex b/lib/asciinema_web/channels/user_socket.ex similarity index 89% rename from web/channels/user_socket.ex rename to lib/asciinema_web/channels/user_socket.ex index 8570f48..7484457 100644 --- a/web/channels/user_socket.ex +++ b/lib/asciinema_web/channels/user_socket.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.UserSocket do +defmodule AsciinemaWeb.UserSocket do use Phoenix.Socket ## Channels @@ -30,7 +30,7 @@ defmodule Asciinema.UserSocket do # Would allow you to broadcast a "disconnect" event and terminate # all active sockets and channels for a given user: # - # Asciinema.Endpoint.broadcast("users_socket:#{user.id}", "disconnect", %{}) + # AsciinemaWeb.Endpoint.broadcast("users_socket:#{user.id}", "disconnect", %{}) # # Returning `nil` makes this socket anonymous. def id(_socket), do: nil diff --git a/web/controllers/api/asciicast_controller.ex b/lib/asciinema_web/controllers/api/asciicast_controller.ex similarity index 91% rename from web/controllers/api/asciicast_controller.ex rename to lib/asciinema_web/controllers/api/asciicast_controller.ex index 70c46f0..6f557a6 100644 --- a/web/controllers/api/asciicast_controller.ex +++ b/lib/asciinema_web/controllers/api/asciicast_controller.ex @@ -1,7 +1,8 @@ -defmodule Asciinema.Api.AsciicastController do - use Asciinema.Web, :controller - import Asciinema.Auth, only: [get_basic_auth: 1, put_basic_auth: 3] - alias Asciinema.{Asciicasts, Users, User} +defmodule AsciinemaWeb.Api.AsciicastController do + use AsciinemaWeb, :controller + import AsciinemaWeb.Auth, only: [get_basic_auth: 1, put_basic_auth: 3] + alias Asciinema.{Asciicasts, Users} + alias Asciinema.Users.User plug :parse_v0_params plug :authenticate diff --git a/web/controllers/asciicast_animation_controller.ex b/lib/asciinema_web/controllers/asciicast_animation_controller.ex similarity index 73% rename from web/controllers/asciicast_animation_controller.ex rename to lib/asciinema_web/controllers/asciicast_animation_controller.ex index f7dfa2a..c664df7 100644 --- a/web/controllers/asciicast_animation_controller.ex +++ b/lib/asciinema_web/controllers/asciicast_animation_controller.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.AsciicastAnimationController do - use Asciinema.Web, :controller +defmodule AsciinemaWeb.AsciicastAnimationController do + use AsciinemaWeb, :controller alias Asciinema.Asciicasts def show(conn, %{"id" => id}) do diff --git a/web/controllers/asciicast_embed_controller.ex b/lib/asciinema_web/controllers/asciicast_embed_controller.ex similarity index 77% rename from web/controllers/asciicast_embed_controller.ex rename to lib/asciinema_web/controllers/asciicast_embed_controller.ex index 809c17d..8ee75d1 100644 --- a/web/controllers/asciicast_embed_controller.ex +++ b/lib/asciinema_web/controllers/asciicast_embed_controller.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.AsciicastEmbedController do - use Asciinema.Web, :controller +defmodule AsciinemaWeb.AsciicastEmbedController do + use AsciinemaWeb, :controller @max_age 60 diff --git a/web/controllers/asciicast_file_controller.ex b/lib/asciinema_web/controllers/asciicast_file_controller.ex similarity index 76% rename from web/controllers/asciicast_file_controller.ex rename to lib/asciinema_web/controllers/asciicast_file_controller.ex index c71e02b..88515c3 100644 --- a/web/controllers/asciicast_file_controller.ex +++ b/lib/asciinema_web/controllers/asciicast_file_controller.ex @@ -1,6 +1,7 @@ -defmodule Asciinema.AsciicastFileController do - use Asciinema.Web, :controller - alias Asciinema.{Asciicasts, Asciicast} +defmodule AsciinemaWeb.AsciicastFileController do + use AsciinemaWeb, :controller + alias Asciinema.Asciicasts + alias Asciinema.Asciicasts.Asciicast def show(conn, %{"id" => id} = params) do asciicast = Asciicasts.get_asciicast!(id) diff --git a/web/controllers/asciicast_image_controller.ex b/lib/asciinema_web/controllers/asciicast_image_controller.ex similarity index 71% rename from web/controllers/asciicast_image_controller.ex rename to lib/asciinema_web/controllers/asciicast_image_controller.ex index 8402a84..7a02702 100644 --- a/web/controllers/asciicast_image_controller.ex +++ b/lib/asciinema_web/controllers/asciicast_image_controller.ex @@ -1,7 +1,7 @@ -defmodule Asciinema.AsciicastImageController do - use Asciinema.Web, :controller - alias Asciinema.{Asciicasts, Asciicast, PngGenerator} - alias Plug.MIME +defmodule AsciinemaWeb.AsciicastImageController do + use AsciinemaWeb, :controller + alias Asciinema.{Asciicasts, PngGenerator} + alias Asciinema.Asciicasts.Asciicast @max_age 604800 # 7 days @@ -13,7 +13,7 @@ defmodule Asciinema.AsciicastImageController do case PngGenerator.generate(asciicast, png_params) do {:ok, png_path} -> conn - |> put_resp_header("content-type", MIME.path(png_path)) + |> put_resp_header("content-type", MIME.from_path(png_path)) |> put_resp_header("cache-control", "public, max-age=#{@max_age}") |> send_file(200, png_path) |> halt diff --git a/web/controllers/doc_controller.ex b/lib/asciinema_web/controllers/doc_controller.ex similarity index 83% rename from web/controllers/doc_controller.ex rename to lib/asciinema_web/controllers/doc_controller.ex index b700884..7a1df9b 100644 --- a/web/controllers/doc_controller.ex +++ b/lib/asciinema_web/controllers/doc_controller.ex @@ -1,6 +1,6 @@ -defmodule Asciinema.DocController do - use Asciinema.Web, :controller - alias Asciinema.{DocView, ErrorView} +defmodule AsciinemaWeb.DocController do + use AsciinemaWeb, :controller + alias AsciinemaWeb.{DocView, ErrorView} @topics ["how-it-works", "getting-started", "installation", "usage", "config", "embedding", "faq"] diff --git a/web/controllers/login_controller.ex b/lib/asciinema_web/controllers/login_controller.ex similarity index 90% rename from web/controllers/login_controller.ex rename to lib/asciinema_web/controllers/login_controller.ex index 86a153f..fbd8d70 100644 --- a/web/controllers/login_controller.ex +++ b/lib/asciinema_web/controllers/login_controller.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.LoginController do - use Asciinema.Web, :controller +defmodule AsciinemaWeb.LoginController do + use AsciinemaWeb, :controller alias Asciinema.Users def new(conn, _params) do diff --git a/web/controllers/session_controller.ex b/lib/asciinema_web/controllers/session_controller.ex similarity index 90% rename from web/controllers/session_controller.ex rename to lib/asciinema_web/controllers/session_controller.ex index 1dafc22..d48a0de 100644 --- a/web/controllers/session_controller.ex +++ b/lib/asciinema_web/controllers/session_controller.ex @@ -1,7 +1,9 @@ -defmodule Asciinema.SessionController do - use Asciinema.Web, :controller - import Asciinema.UserView, only: [profile_path: 1] - alias Asciinema.{Users, User} +defmodule AsciinemaWeb.SessionController do + use AsciinemaWeb, :controller + import AsciinemaWeb.UserView, only: [profile_path: 1] + alias Asciinema.Users + alias AsciinemaWeb.Auth + alias Asciinema.Users.User def new(conn, %{"t" => login_token}) do conn @@ -34,7 +36,7 @@ defmodule Asciinema.SessionController do case Users.verify_login_token(login_token) do {:ok, user} -> conn - |> Users.log_in(user) + |> Auth.log_in(user) |> put_rails_flash(:notice, "Welcome back!") |> redirect_to_profile {:error, :token_invalid} -> @@ -58,12 +60,12 @@ defmodule Asciinema.SessionController do case {current_user, logging_user} do {nil, %User{email: nil}} -> conn - |> Users.log_in(logging_user) + |> Auth.log_in(logging_user) |> put_rails_flash(:notice, "Welcome! Setting username and email will help you with logging in later.") |> redirect_to_edit_profile {nil, %User{}} -> conn - |> Users.log_in(logging_user) + |> Auth.log_in(logging_user) |> put_rails_flash(:notice, "Welcome back!") |> redirect_to_profile {%User{id: id, email: nil}, %User{id: id}} -> @@ -78,7 +80,7 @@ defmodule Asciinema.SessionController do {%User{email: nil}, %User{}} -> Users.merge!(logging_user, current_user) conn - |> Users.log_in(logging_user) + |> Auth.log_in(logging_user) |> put_rails_flash(:notice, "Recorder token has been added to your account.") |> redirect_to_profile {%User{}, %User{email: nil}} -> diff --git a/web/controllers/user_controller.ex b/lib/asciinema_web/controllers/user_controller.ex similarity index 89% rename from web/controllers/user_controller.ex rename to lib/asciinema_web/controllers/user_controller.ex index f03064d..89a36ac 100644 --- a/web/controllers/user_controller.ex +++ b/lib/asciinema_web/controllers/user_controller.ex @@ -1,6 +1,7 @@ -defmodule Asciinema.UserController do - use Asciinema.Web, :controller +defmodule AsciinemaWeb.UserController do + use AsciinemaWeb, :controller alias Asciinema.Users + alias AsciinemaWeb.Auth def new(conn, %{"t" => signup_token}) do conn @@ -18,7 +19,7 @@ defmodule Asciinema.UserController do case Users.verify_signup_token(signup_token) do {:ok, user} -> conn - |> Users.log_in(user) + |> Auth.log_in(user) |> put_rails_flash(:info, "Welcome to asciinema!") |> redirect(to: "/username/new") {:error, :token_invalid} -> diff --git a/lib/asciinema/endpoint.ex b/lib/asciinema_web/endpoint.ex similarity index 88% rename from lib/asciinema/endpoint.ex rename to lib/asciinema_web/endpoint.ex index f221ed4..5603ef2 100644 --- a/lib/asciinema/endpoint.ex +++ b/lib/asciinema_web/endpoint.ex @@ -1,7 +1,7 @@ -defmodule Asciinema.Endpoint do +defmodule AsciinemaWeb.Endpoint do use Phoenix.Endpoint, otp_app: :asciinema - socket "/socket", Asciinema.UserSocket + socket "/socket", AsciinemaWeb.UserSocket # Serve at "/" the static files from "priv/static" directory. # @@ -41,7 +41,7 @@ defmodule Asciinema.Endpoint do key_digest: :sha, serializer: Poison - plug Asciinema.TrailingFormat + plug AsciinemaWeb.TrailingFormat - plug Asciinema.Router + plug AsciinemaWeb.Router end diff --git a/web/gettext.ex b/lib/asciinema_web/gettext.ex similarity index 95% rename from web/gettext.ex rename to lib/asciinema_web/gettext.ex index 6b4b799..126dc97 100644 --- a/web/gettext.ex +++ b/lib/asciinema_web/gettext.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.Gettext do +defmodule AsciinemaWeb.Gettext do @moduledoc """ A module providing Internationalization with a gettext-based API. diff --git a/lib/asciinema/rails/flash.ex b/lib/asciinema_web/rails/flash.ex similarity index 87% rename from lib/asciinema/rails/flash.ex rename to lib/asciinema_web/rails/flash.ex index 1cd13d9..477209e 100644 --- a/lib/asciinema/rails/flash.ex +++ b/lib/asciinema_web/rails/flash.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.Rails.Flash do +defmodule AsciinemaWeb.Rails.Flash do import Plug.Conn def put_rails_flash(conn, key, value) do diff --git a/web/router.ex b/lib/asciinema_web/router.ex similarity index 87% rename from web/router.ex rename to lib/asciinema_web/router.ex index 487235b..8632840 100644 --- a/web/router.ex +++ b/lib/asciinema_web/router.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.Router do - use Asciinema.Web, :router +defmodule AsciinemaWeb.Router do + use AsciinemaWeb, :router pipeline :browser do plug :accepts, ["html"] @@ -7,14 +7,14 @@ defmodule Asciinema.Router do plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers - plug Asciinema.Auth + plug AsciinemaWeb.Auth end pipeline :asciicast_embed_script do plug :accepts, ["js"] end - scope "/", Asciinema do + scope "/", AsciinemaWeb do pipe_through :asciicast_embed_script # rewritten by TrailingFormat from /a/123.js to /a/123/js @@ -25,7 +25,7 @@ defmodule Asciinema.Router do plug :accepts, ["json"] end - scope "/", Asciinema do + scope "/", AsciinemaWeb do pipe_through :asciicast_file # rewritten by TrailingFormat from /a/123.json to /a/123/json @@ -36,7 +36,7 @@ defmodule Asciinema.Router do plug :accepts, ["png"] end - scope "/", Asciinema do + scope "/", AsciinemaWeb do pipe_through :asciicast_image # rewritten by TrailingFormat from /a/123.png to /a/123/png @@ -47,14 +47,14 @@ defmodule Asciinema.Router do plug :accepts, ["html"] end - scope "/", Asciinema do + scope "/", AsciinemaWeb do pipe_through :asciicast_animation # rewritten by TrailingFormat from /a/123.gif to /a/123/gif get "/a/:id/gif", AsciicastAnimationController, :show end - scope "/", Asciinema do + scope "/", AsciinemaWeb do pipe_through :browser # Use the default browser stack get "/a/:id", AsciicastController, :show @@ -71,7 +71,7 @@ defmodule Asciinema.Router do get "/connect/:api_token", SessionController, :create, as: :connect end - scope "/api", Asciinema.Api, as: :api do + scope "/api", AsciinemaWeb.Api, as: :api do post "/asciicasts", AsciicastController, :create end @@ -81,8 +81,8 @@ defmodule Asciinema.Router do # end end -defmodule Asciinema.Router.Helpers.Extra do - alias Asciinema.Router.Helpers, as: H +defmodule AsciinemaWeb.Router.Helpers.Extra do + alias AsciinemaWeb.Router.Helpers, as: H def user_path(_conn, :edit) do "/user/edit" diff --git a/web/templates/asciicast_animation/show.html.eex b/lib/asciinema_web/templates/asciicast_animation/show.html.eex similarity index 100% rename from web/templates/asciicast_animation/show.html.eex rename to lib/asciinema_web/templates/asciicast_animation/show.html.eex diff --git a/web/templates/doc/config.html.md b/lib/asciinema_web/templates/doc/config.html.md similarity index 100% rename from web/templates/doc/config.html.md rename to lib/asciinema_web/templates/doc/config.html.md diff --git a/web/templates/doc/embedding.html.md b/lib/asciinema_web/templates/doc/embedding.html.md similarity index 100% rename from web/templates/doc/embedding.html.md rename to lib/asciinema_web/templates/doc/embedding.html.md diff --git a/web/templates/doc/faq.html.md b/lib/asciinema_web/templates/doc/faq.html.md similarity index 100% rename from web/templates/doc/faq.html.md rename to lib/asciinema_web/templates/doc/faq.html.md diff --git a/web/templates/doc/getting-started.html.eex b/lib/asciinema_web/templates/doc/getting-started.html.eex similarity index 100% rename from web/templates/doc/getting-started.html.eex rename to lib/asciinema_web/templates/doc/getting-started.html.eex diff --git a/web/templates/doc/how-it-works.html.md b/lib/asciinema_web/templates/doc/how-it-works.html.md similarity index 100% rename from web/templates/doc/how-it-works.html.md rename to lib/asciinema_web/templates/doc/how-it-works.html.md diff --git a/web/templates/doc/installation.html.md b/lib/asciinema_web/templates/doc/installation.html.md similarity index 100% rename from web/templates/doc/installation.html.md rename to lib/asciinema_web/templates/doc/installation.html.md diff --git a/web/templates/doc/quick_install.html.eex b/lib/asciinema_web/templates/doc/quick_install.html.eex similarity index 100% rename from web/templates/doc/quick_install.html.eex rename to lib/asciinema_web/templates/doc/quick_install.html.eex diff --git a/web/templates/doc/topic_link.html.eex b/lib/asciinema_web/templates/doc/topic_link.html.eex similarity index 100% rename from web/templates/doc/topic_link.html.eex rename to lib/asciinema_web/templates/doc/topic_link.html.eex diff --git a/web/templates/doc/topics.html.eex b/lib/asciinema_web/templates/doc/topics.html.eex similarity index 100% rename from web/templates/doc/topics.html.eex rename to lib/asciinema_web/templates/doc/topics.html.eex diff --git a/web/templates/doc/usage.html.md b/lib/asciinema_web/templates/doc/usage.html.md similarity index 100% rename from web/templates/doc/usage.html.md rename to lib/asciinema_web/templates/doc/usage.html.md diff --git a/web/templates/doc/wrapper.html.eex b/lib/asciinema_web/templates/doc/wrapper.html.eex similarity index 100% rename from web/templates/doc/wrapper.html.eex rename to lib/asciinema_web/templates/doc/wrapper.html.eex diff --git a/web/templates/email/login.text.eex b/lib/asciinema_web/templates/email/login.text.eex similarity index 100% rename from web/templates/email/login.text.eex rename to lib/asciinema_web/templates/email/login.text.eex diff --git a/web/templates/email/signup.text.eex b/lib/asciinema_web/templates/email/signup.text.eex similarity index 100% rename from web/templates/email/signup.text.eex rename to lib/asciinema_web/templates/email/signup.text.eex diff --git a/web/templates/error/404.html.eex b/lib/asciinema_web/templates/error/404.html.eex similarity index 100% rename from web/templates/error/404.html.eex rename to lib/asciinema_web/templates/error/404.html.eex diff --git a/web/templates/layout/app.html.eex b/lib/asciinema_web/templates/layout/app.html.eex similarity index 100% rename from web/templates/layout/app.html.eex rename to lib/asciinema_web/templates/layout/app.html.eex diff --git a/lib/asciinema_web/templates/layout/docs.html.eex b/lib/asciinema_web/templates/layout/docs.html.eex new file mode 100644 index 0000000..9f67f2f --- /dev/null +++ b/lib/asciinema_web/templates/layout/docs.html.eex @@ -0,0 +1 @@ +<%= render @view_module, "wrapper.html", Map.merge(assigns, %{layout: {AsciinemaWeb.LayoutView, "app.html"}, topic_template: @view_template}) %> diff --git a/web/templates/layout/flash.html.eex b/lib/asciinema_web/templates/layout/flash.html.eex similarity index 100% rename from web/templates/layout/flash.html.eex rename to lib/asciinema_web/templates/layout/flash.html.eex diff --git a/web/templates/layout/footer.html.eex b/lib/asciinema_web/templates/layout/footer.html.eex similarity index 100% rename from web/templates/layout/footer.html.eex rename to lib/asciinema_web/templates/layout/footer.html.eex diff --git a/web/templates/layout/header.html.eex b/lib/asciinema_web/templates/layout/header.html.eex similarity index 100% rename from web/templates/layout/header.html.eex rename to lib/asciinema_web/templates/layout/header.html.eex diff --git a/web/templates/layout/simple.html.eex b/lib/asciinema_web/templates/layout/simple.html.eex similarity index 100% rename from web/templates/layout/simple.html.eex rename to lib/asciinema_web/templates/layout/simple.html.eex diff --git a/web/templates/login/new.html.eex b/lib/asciinema_web/templates/login/new.html.eex similarity index 100% rename from web/templates/login/new.html.eex rename to lib/asciinema_web/templates/login/new.html.eex diff --git a/web/templates/login/sent.html.eex b/lib/asciinema_web/templates/login/sent.html.eex similarity index 100% rename from web/templates/login/sent.html.eex rename to lib/asciinema_web/templates/login/sent.html.eex diff --git a/web/templates/session/new.html.eex b/lib/asciinema_web/templates/session/new.html.eex similarity index 100% rename from web/templates/session/new.html.eex rename to lib/asciinema_web/templates/session/new.html.eex diff --git a/web/templates/user/new.html.eex b/lib/asciinema_web/templates/user/new.html.eex similarity index 100% rename from web/templates/user/new.html.eex rename to lib/asciinema_web/templates/user/new.html.eex diff --git a/lib/asciinema/trailing_format.ex b/lib/asciinema_web/trailing_format.ex similarity index 93% rename from lib/asciinema/trailing_format.ex rename to lib/asciinema_web/trailing_format.ex index e214f1f..21a872c 100644 --- a/lib/asciinema/trailing_format.ex +++ b/lib/asciinema_web/trailing_format.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.TrailingFormat do +defmodule AsciinemaWeb.TrailingFormat do @known_extensions ["js", "json", "png", "gif"] def init(opts), do: opts diff --git a/web/views/api/asciicast_view.ex b/lib/asciinema_web/views/api/asciicast_view.ex similarity index 75% rename from web/views/api/asciicast_view.ex rename to lib/asciinema_web/views/api/asciicast_view.ex index 7286e0b..fdfbddd 100644 --- a/web/views/api/asciicast_view.ex +++ b/lib/asciinema_web/views/api/asciicast_view.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.Api.AsciicastView do - use Asciinema.Web, :view +defmodule AsciinemaWeb.Api.AsciicastView do + use AsciinemaWeb, :view def translate_errors(changeset) do Ecto.Changeset.traverse_errors(changeset, &translate_error/1) diff --git a/lib/asciinema_web/views/asciicast_animation_view.ex b/lib/asciinema_web/views/asciicast_animation_view.ex new file mode 100644 index 0000000..9b9d7d7 --- /dev/null +++ b/lib/asciinema_web/views/asciicast_animation_view.ex @@ -0,0 +1,3 @@ +defmodule AsciinemaWeb.AsciicastAnimationView do + use AsciinemaWeb, :view +end diff --git a/web/views/doc_view.ex b/lib/asciinema_web/views/doc_view.ex similarity index 89% rename from web/views/doc_view.ex rename to lib/asciinema_web/views/doc_view.ex index 606faef..aac0c2d 100644 --- a/web/views/doc_view.ex +++ b/lib/asciinema_web/views/doc_view.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.DocView do - use Asciinema.Web, :view +defmodule AsciinemaWeb.DocView do + use AsciinemaWeb, :view @titles %{ :"how-it-works" => "How it works", diff --git a/lib/asciinema_web/views/email_view.ex b/lib/asciinema_web/views/email_view.ex new file mode 100644 index 0000000..52445ff --- /dev/null +++ b/lib/asciinema_web/views/email_view.ex @@ -0,0 +1,3 @@ +defmodule AsciinemaWeb.EmailView do + use AsciinemaWeb, :view +end diff --git a/web/views/error_helpers.ex b/lib/asciinema_web/views/error_helpers.ex similarity index 85% rename from web/views/error_helpers.ex rename to lib/asciinema_web/views/error_helpers.ex index 64456cd..a2e5063 100644 --- a/web/views/error_helpers.ex +++ b/lib/asciinema_web/views/error_helpers.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.ErrorHelpers do +defmodule AsciinemaWeb.ErrorHelpers do @moduledoc """ Conveniences for translating and building error messages. """ @@ -32,9 +32,9 @@ defmodule Asciinema.ErrorHelpers do # dgettext "errors", "is invalid" # if count = opts[:count] do - Gettext.dngettext(Asciinema.Gettext, "errors", msg, msg, count, opts) + Gettext.dngettext(AsciinemaWeb.Gettext, "errors", msg, msg, count, opts) else - Gettext.dgettext(Asciinema.Gettext, "errors", msg, opts) + Gettext.dgettext(AsciinemaWeb.Gettext, "errors", msg, opts) end end end diff --git a/web/views/error_view.ex b/lib/asciinema_web/views/error_view.ex similarity index 80% rename from web/views/error_view.ex rename to lib/asciinema_web/views/error_view.ex index 050ea0e..29a6c62 100644 --- a/web/views/error_view.ex +++ b/lib/asciinema_web/views/error_view.ex @@ -1,5 +1,5 @@ -defmodule Asciinema.ErrorView do - use Asciinema.Web, :view +defmodule AsciinemaWeb.ErrorView do + use AsciinemaWeb, :view def render("500.html", _assigns) do "Internal server error" diff --git a/web/views/layout_view.ex b/lib/asciinema_web/views/layout_view.ex similarity index 63% rename from web/views/layout_view.ex rename to lib/asciinema_web/views/layout_view.ex index 39aa40c..a13edbf 100644 --- a/web/views/layout_view.ex +++ b/lib/asciinema_web/views/layout_view.ex @@ -1,6 +1,6 @@ -defmodule Asciinema.LayoutView do - use Asciinema.Web, :view - import Asciinema.UserView, only: [avatar_url: 1, profile_path: 1] +defmodule AsciinemaWeb.LayoutView do + use AsciinemaWeb, :view + import AsciinemaWeb.UserView, only: [avatar_url: 1, profile_path: 1] def page_title(conn) do case conn.assigns[:page_title] do diff --git a/lib/asciinema_web/views/login_view.ex b/lib/asciinema_web/views/login_view.ex new file mode 100644 index 0000000..c139640 --- /dev/null +++ b/lib/asciinema_web/views/login_view.ex @@ -0,0 +1,3 @@ +defmodule AsciinemaWeb.LoginView do + use AsciinemaWeb, :view +end diff --git a/lib/asciinema_web/views/session_view.ex b/lib/asciinema_web/views/session_view.ex new file mode 100644 index 0000000..85c7cc4 --- /dev/null +++ b/lib/asciinema_web/views/session_view.ex @@ -0,0 +1,3 @@ +defmodule AsciinemaWeb.SessionView do + use AsciinemaWeb, :view +end diff --git a/web/views/user_view.ex b/lib/asciinema_web/views/user_view.ex similarity index 77% rename from web/views/user_view.ex rename to lib/asciinema_web/views/user_view.ex index c9e4eba..0f55f4a 100644 --- a/web/views/user_view.ex +++ b/lib/asciinema_web/views/user_view.ex @@ -1,6 +1,7 @@ -defmodule Asciinema.UserView do - use Asciinema.Web, :view - alias Asciinema.{Gravatar, User} +defmodule AsciinemaWeb.UserView do + use AsciinemaWeb, :view + alias Asciinema.Users.User + alias Asciinema.Gravatar def avatar_url(user) do username = user_username(user) diff --git a/mix.exs b/mix.exs index 11977b0..dc485a7 100644 --- a/mix.exs +++ b/mix.exs @@ -17,7 +17,7 @@ defmodule Asciinema.Mixfile do # # Type `mix help compile.app` for more information. def application do - [mod: {Asciinema, []}, + [mod: {Asciinema.Application, []}, applications: [ :bamboo, :bamboo_smtp, @@ -44,8 +44,8 @@ defmodule Asciinema.Mixfile do end # Specifies which paths to compile per environment. - defp elixirc_paths(:test), do: ["lib", "web", "test/support"] - defp elixirc_paths(_), do: ["lib", "web"] + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # @@ -61,9 +61,9 @@ defmodule Asciinema.Mixfile do {:exq, "~> 0.9.0"}, {:exq_ui, "~> 0.9.0"}, {:gettext, "~> 0.11"}, - {:phoenix, "~> 1.2.1"}, + {:phoenix, "~> 1.3.0"}, {:phoenix_ecto, "~> 3.0"}, - {:phoenix_html, "~> 2.6"}, + {:phoenix_html, "~> 2.10"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:phoenix_markdown, "~> 0.1"}, {:phoenix_pubsub, "~> 1.0"}, diff --git a/mix.lock b/mix.lock index c174592..aa0b313 100644 --- a/mix.lock +++ b/mix.lock @@ -7,39 +7,39 @@ "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, "cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"}, - "db_connection": {:hex, :db_connection, "1.0.0-rc.5", "1d9ab6e01387bdf2de7a16c56866971f7c2f75aea7c69cae2a0346e4b537ae0d", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0.0-beta.3", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, - "decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], [], "hexpm"}, + "db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, + "decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], [], "hexpm"}, "earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "2.0.4", "03fd3b9aa508b1383eb38c00ac389953ed22af53811aa2e504975a3e814a8d97", [:mix], [{:db_connection, "~> 1.0-rc.2", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.11.2", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, + "ecto": {:hex, :ecto, "2.1.4", "d1ba932813ec0e0d9db481ef2c17777f1cefb11fc90fa7c142ff354972dfba7e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "ex_aws": {:hex, :ex_aws, "1.1.2", "b78416d0a84efe92c22e5df8ba7ca028d63b2b4228f95871a1ecf10324b6493b", [:mix], [{:configparser_ex, "~> 0.2.1", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "1.6.3 or 1.6.5 or 1.7.1", [hex: :hackney, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: true]}, {:poison, ">= 1.2.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.6", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:xml_builder, "~> 0.0.6", [hex: :xml_builder, repo: "hexpm", optional: true]}], "hexpm"}, "exq": {:hex, :exq, "0.9.0", "3feeb085fcd94a687033211e10c78cf9dca1de062aac3fa9a4b1f808cdcea522", [:mix], [{:poison, ">= 1.2.0 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}, {:redix, ">= 0.5.0", [hex: :redix, repo: "hexpm", optional: false]}, {:uuid, ">= 1.0.0", [hex: :uuid, repo: "hexpm", optional: false]}], "hexpm"}, "exq_ui": {:hex, :exq_ui, "0.9.0", "e97e9fa9009f30d2926b51a166e40a3a521e83f61f3f333fede8335b2aa57f09", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:exq, "~> 0.9", [hex: :exq, repo: "hexpm", optional: false]}, {:plug, ">= 0.8.1 and < 2.0.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.12.0", "97d44903f5ca18ca85cb39aee7d9c77e98d79804bbdef56078adcf905cb2ef00", [:rebar3], [], "hexpm"}, - "gettext": {:hex, :gettext, "0.11.0", "80c1dd42d270482418fa158ec5ba073d2980e3718bacad86f3d4ad71d5667679", [:mix], [], "hexpm"}, + "gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], [], "hexpm"}, "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "httpoison": {:hex, :httpoison, "0.11.1", "d06c571274c0e77b6cc50e548db3fd7779f611fbed6681fd60a331f66c143a0b", [:mix], [{:hackney, "~> 1.7.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], [], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, - "phoenix": {:hex, :phoenix, "1.2.3", "b68dd6a7e6ff3eef38ad59771007d2f3f344988ea6e658e9b2c6ffb2ef494810", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.4 or ~> 1.3.3 or ~> 1.2.4 or ~> 1.1.8 or ~> 1.0.5", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "3.0.1", "42eb486ef732cf209d0a353e791806721f33ff40beab0a86f02070a5649ed00a", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.6", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_html": {:hex, :phoenix_html, "2.9.3", "1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.5", "829218c4152ba1e9848e2bf8e161fcde6b4ec679a516259442561d21fde68d0b", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix": {:hex, :phoenix, "1.3.0", "1c01124caa1b4a7af46f2050ff11b267baa3edb441b45dbf243e979cd4c5891b", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_ecto": {:hex, :phoenix_ecto, "3.2.3", "450c749876ff1de4a78fdb305a142a76817c77a1cd79aeca29e5fc9a6c630b26", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_html": {:hex, :phoenix_html, "2.10.2", "0249cc636c9fb4ac4c84a6075e3e352ca5e31fd4756142bc9e31d73fd507a62a", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.8", "4333f9c74190f485a74866beff2f9304f069d53f047f5fbb0fb8d1ee4c495f73", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_markdown": {:hex, :phoenix_markdown, "0.1.4", "246727d998997c6b90374a678bbdca5b300dcbbfecb29dbcca8a7891751f6cd5", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.1", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.3", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.1", "c10ddf6237007c804bf2b8f3c4d5b99009b42eca3a0dfac04ea2d8001186056a", [:mix], [], "hexpm"}, - "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"}, + "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "plug_rails_cookie_session_store": {:hex, :plug_rails_cookie_session_store, "0.1.0", "8d87967eb2d4d25837e1b5778265aebf8ac797291d6ff65dbd828c4ffa7f0955", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:plug, ">= 0.9.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "plugsnag": {:git, "https://github.com/sickill/plugsnag.git", "a5d8dcc370f52cec9fcf21acb42e2b293b003b37", []}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], [], "hexpm"}, "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"}, "porcelain": {:hex, :porcelain, "2.0.3", "2d77b17d1f21fed875b8c5ecba72a01533db2013bd2e5e62c6d286c029150fdc", [:mix], [], "hexpm"}, - "postgrex": {:hex, :postgrex, "0.11.2", "139755c1359d3c5c6d6e8b1ea72556d39e2746f61c6ddfb442813c91f53487e8", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.0-rc", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"}, + "postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"}, "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"}, "redix": {:hex, :redix, "0.6.1", "20986b0e02f02b13e6f53c79a1ae70aa83147488c408f40275ec261f5bb0a6d0", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, - "timex": {:hex, :timex, "3.1.15", "94abaec8fef2436ced4d0e1b4ed50c8eaa5fb9138fc0699946ddee7abf5aaff2", [:mix], [{:combine, "~> 0.7", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm"}, - "timex_ecto": {:hex, :timex_ecto, "3.0.5", "3ec6c25e10d2c0020958e5df64d2b5e690e441faa2c2259da8bc6bd3d7f39256", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:timex, "~> 3.0", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"}, + "timex": {:hex, :timex, "3.1.24", "d198ae9783ac807721cca0c5535384ebdf99da4976be8cefb9665a9262a1e9e3", [:mix], [{:combine, "~> 0.7", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm"}, + "timex_ecto": {:hex, :timex_ecto, "3.1.1", "37d54f6879d96a6789bb497296531cfb853631de78e152969d95cff03c1368dd", [:mix], [{:ecto, "~> 2.1.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:timex, "~> 3.0", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"}, "tzdata": {:hex, :tzdata, "0.5.12", "1c17b68692c6ba5b6ab15db3d64cc8baa0f182043d5ae9d4b6d35d70af76f67b", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "uuid": {:hex, :uuid, "1.1.7", "007afd58273bc0bc7f849c3bdc763e2f8124e83b957e515368c498b641f7ab69", [:mix], [], "hexpm"}} diff --git a/test/asciinema/asciicasts_test.exs b/test/asciinema/asciicasts_test.exs index 3418af5..2723ae6 100644 --- a/test/asciinema/asciicasts_test.exs +++ b/test/asciinema/asciicasts_test.exs @@ -1,6 +1,7 @@ defmodule Asciinema.AsciicastsTest do use Asciinema.DataCase - alias Asciinema.{Asciicasts, Asciicast} + alias Asciinema.Asciicasts + alias Asciinema.Asciicasts.Asciicast describe "create_asciicast/3" do test "json file, v0 format with uname" do diff --git a/test/controllers/api/asciicast_controller_test.exs b/test/controllers/api/asciicast_controller_test.exs index 9c85d1f..2813db8 100644 --- a/test/controllers/api/asciicast_controller_test.exs +++ b/test/controllers/api/asciicast_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.Api.AsciicastControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase alias Asciinema.Users setup %{conn: conn} = context do diff --git a/test/controllers/asciicast_animation_controller_test.exs b/test/controllers/asciicast_animation_controller_test.exs index 42a0662..63ce746 100644 --- a/test/controllers/asciicast_animation_controller_test.exs +++ b/test/controllers/asciicast_animation_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.AsciicastAnimationControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase test "shows GIF generation instructions", %{conn: conn} do asciicast = fixture(:asciicast) diff --git a/test/controllers/asciicast_embed_controller_test.exs b/test/controllers/asciicast_embed_controller_test.exs index 9741b10..fabfff1 100644 --- a/test/controllers/asciicast_embed_controller_test.exs +++ b/test/controllers/asciicast_embed_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.AsciicastEmbedControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase test "serves embed js", %{conn: conn} do conn = get conn, "/a/12345.js" diff --git a/test/controllers/asciicast_file_controller_test.exs b/test/controllers/asciicast_file_controller_test.exs index 5c091e0..68d7a66 100644 --- a/test/controllers/asciicast_file_controller_test.exs +++ b/test/controllers/asciicast_file_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.AsciicastFileControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase test "renders asciicast file", %{conn: conn} do asciicast = fixture(:asciicast) diff --git a/test/controllers/asciicast_image_controller_test.exs b/test/controllers/asciicast_image_controller_test.exs index c7ed7d8..ae7c0d2 100644 --- a/test/controllers/asciicast_image_controller_test.exs +++ b/test/controllers/asciicast_image_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.AsciicastImageControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase @tag :a2png diff --git a/test/controllers/doc_controller_test.exs b/test/controllers/doc_controller_test.exs index b60cc0b..78b3d67 100644 --- a/test/controllers/doc_controller_test.exs +++ b/test/controllers/doc_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.DocControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase test "GET /docs", %{conn: conn} do conn = get conn, "/docs" diff --git a/test/controllers/login_controller_test.exs b/test/controllers/login_controller_test.exs index 2b76d01..fd98055 100644 --- a/test/controllers/login_controller_test.exs +++ b/test/controllers/login_controller_test.exs @@ -1,5 +1,5 @@ defmodule Asciinema.LoginControllerTest do - use Asciinema.ConnCase + use AsciinemaWeb.ConnCase test "with valid email", %{conn: conn} do conn = post conn, "/login", %{login: %{email: "new@example.com"}} diff --git a/test/controllers/session_controller_test.exs b/test/controllers/session_controller_test.exs index cffbbf5..72100d8 100644 --- a/test/controllers/session_controller_test.exs +++ b/test/controllers/session_controller_test.exs @@ -1,6 +1,7 @@ defmodule Asciinema.SessionControllerTest do - use Asciinema.ConnCase - alias Asciinema.{Users, User, ApiToken} + use AsciinemaWeb.ConnCase + alias Asciinema.Users + alias Asciinema.Users.{User, ApiToken} @revoked_token "eb927b31-9ca3-4a6a-8a0c-dfba318e2e84" @regular_user_token "c4ecd96a-9a16-464d-be6a-bc1f3c50c4ae" diff --git a/test/models/user_test.exs b/test/models/user_test.exs deleted file mode 100644 index 498d5a7..0000000 --- a/test/models/user_test.exs +++ /dev/null @@ -1,18 +0,0 @@ -defmodule Asciinema.UserTest do - use Asciinema.ModelCase - - alias Asciinema.User - - @valid_attrs %{email: "test@example.com"} - @invalid_attrs %{} - - test "signup changeset with valid attributes" do - changeset = User.signup_changeset(@valid_attrs) - assert changeset.valid? - end - - test "signup changeset with invalid attributes" do - changeset = User.signup_changeset(@invalid_attrs) - refute changeset.valid? - end -end diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index 85af6ff..628a563 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.ChannelCase do +defmodule AsciinemaWeb.ChannelCase do @moduledoc """ This module defines the test case to be used by channel tests. @@ -27,7 +27,7 @@ defmodule Asciinema.ChannelCase do # The default endpoint for testing - @endpoint Asciinema.Endpoint + @endpoint AsciinemaWeb.Endpoint end end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 8145cbb..1c11d93 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -1,4 +1,4 @@ -defmodule Asciinema.ConnCase do +defmodule AsciinemaWeb.ConnCase do @moduledoc """ This module defines the test case to be used by tests that require setting up a connection. @@ -25,12 +25,12 @@ defmodule Asciinema.ConnCase do import Ecto.Changeset import Ecto.Query - import Asciinema.Router.Helpers - import Asciinema.Router.Helpers.Extra + import AsciinemaWeb.Router.Helpers + import AsciinemaWeb.Router.Helpers.Extra import Asciinema.Fixtures # The default endpoint for testing - @endpoint Asciinema.Endpoint + @endpoint AsciinemaWeb.Endpoint end end diff --git a/test/support/fixtures.ex b/test/support/fixtures.ex index 5b547ad..54363e8 100644 --- a/test/support/fixtures.ex +++ b/test/support/fixtures.ex @@ -1,5 +1,6 @@ defmodule Asciinema.Fixtures do - alias Asciinema.{Repo, Asciicasts, User} + alias Asciinema.{Repo, Asciicasts} + alias Asciinema.Users.User def fixture(what, attrs \\ %{}) diff --git a/test/support/model_case.ex b/test/support/model_case.ex deleted file mode 100644 index 4199feb..0000000 --- a/test/support/model_case.ex +++ /dev/null @@ -1,65 +0,0 @@ -defmodule Asciinema.ModelCase do - @moduledoc """ - This module defines the test case to be used by - model tests. - - You may define functions here to be used as helpers in - your model tests. See `errors_on/2`'s definition as reference. - - Finally, if the test case interacts with the database, - it cannot be async. For this reason, every test runs - inside a transaction which is reset at the beginning - of the test unless the test case is marked as async. - """ - - use ExUnit.CaseTemplate - - using do - quote do - alias Asciinema.Repo - - import Ecto - import Ecto.Changeset - import Ecto.Query - import Asciinema.ModelCase - end - end - - setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Asciinema.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Asciinema.Repo, {:shared, self()}) - end - - :ok - end - - @doc """ - Helper for returning list of errors in a struct when given certain data. - - ## Examples - - Given a User schema that lists `:name` as a required field and validates - `:password` to be safe, it would return: - - iex> errors_on(%User{}, %{password: "password"}) - [password: "is unsafe", name: "is blank"] - - You could then write your assertion like: - - assert {:password, "is unsafe"} in errors_on(%User{}, %{password: "password"}) - - You can also create the changeset manually and retrieve the errors - field directly: - - iex> changeset = User.changeset(%User{}, password: "password") - iex> {:password, "is unsafe"} in changeset.errors - true - """ - def errors_on(struct, data) do - struct.__struct__.changeset(struct, data) - |> Ecto.Changeset.traverse_errors(&Asciinema.ErrorHelpers.translate_error/1) - |> Enum.flat_map(fn {key, errors} -> for msg <- errors, do: {key, msg} end) - end -end diff --git a/test/views/error_view_test.exs b/test/views/error_view_test.exs index ebb260e..194af0d 100644 --- a/test/views/error_view_test.exs +++ b/test/views/error_view_test.exs @@ -1,21 +1,21 @@ defmodule Asciinema.ErrorViewTest do - use Asciinema.ConnCase, async: true + use AsciinemaWeb.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(Asciinema.ErrorView, "404.html", []) =~ + assert render_to_string(AsciinemaWeb.ErrorView, "404.html", []) =~ "not found" end test "render 500.html" do - assert render_to_string(Asciinema.ErrorView, "500.html", []) == + assert render_to_string(AsciinemaWeb.ErrorView, "500.html", []) == "Internal server error" end test "render any other" do - assert render_to_string(Asciinema.ErrorView, "505.html", []) == + assert render_to_string(AsciinemaWeb.ErrorView, "505.html", []) == "Internal server error" end end diff --git a/test/views/layout_view_test.exs b/test/views/layout_view_test.exs index 16029e4..5add0c7 100644 --- a/test/views/layout_view_test.exs +++ b/test/views/layout_view_test.exs @@ -1,3 +1,3 @@ defmodule Asciinema.LayoutViewTest do - use Asciinema.ConnCase, async: true + use AsciinemaWeb.ConnCase, async: true end diff --git a/test/views/page_view_test.exs b/test/views/page_view_test.exs index 719c818..e8fae40 100644 --- a/test/views/page_view_test.exs +++ b/test/views/page_view_test.exs @@ -1,3 +1,3 @@ defmodule Asciinema.PageViewTest do - use Asciinema.ConnCase, async: true + use AsciinemaWeb.ConnCase, async: true end diff --git a/web/templates/layout/docs.html.eex b/web/templates/layout/docs.html.eex deleted file mode 100644 index 1ffa491..0000000 --- a/web/templates/layout/docs.html.eex +++ /dev/null @@ -1 +0,0 @@ -<%= render @view_module, "wrapper.html", Map.merge(assigns, %{layout: {Asciinema.LayoutView, "app.html"}, topic_template: @view_template}) %> diff --git a/web/views/asciicast_animation_view.ex b/web/views/asciicast_animation_view.ex deleted file mode 100644 index c7a7cb3..0000000 --- a/web/views/asciicast_animation_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Asciinema.AsciicastAnimationView do - use Asciinema.Web, :view -end diff --git a/web/views/email_view.ex b/web/views/email_view.ex deleted file mode 100644 index 588cd84..0000000 --- a/web/views/email_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Asciinema.EmailView do - use Asciinema.Web, :view -end diff --git a/web/views/login_view.ex b/web/views/login_view.ex deleted file mode 100644 index 74c46e6..0000000 --- a/web/views/login_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Asciinema.LoginView do - use Asciinema.Web, :view -end diff --git a/web/views/session_view.ex b/web/views/session_view.ex deleted file mode 100644 index 5d39e54..0000000 --- a/web/views/session_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Asciinema.SessionView do - use Asciinema.Web, :view -end