From 8d2e119f5c551d548e4367a465089d507f13a8d9 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sun, 18 Apr 2021 20:28:00 -0300 Subject: [PATCH 01/95] wip: create blog app --- apps/blog/.formatter.exs | 4 ++++ apps/blog/.gitignore | 24 ++++++++++++++++++++++ apps/blog/README.md | 21 +++++++++++++++++++ apps/blog/lib/blog.ex | 18 ++++++++++++++++ apps/blog/lib/blog/application.ex | 11 ++++++++++ apps/blog/lib/blog/release.ex | 34 +++++++++++++++++++++++++++++++ apps/blog/lib/blog/repo.ex | 7 +++++++ apps/blog/mix.exs | 30 +++++++++++++++++++++++++++ apps/blog/test/blog_test.exs | 8 ++++++++ apps/blog/test/test_helper.exs | 1 + config/config.exs | 6 ++++++ config/dev.exs | 8 ++++++++ config/releases.exs | 12 +++++++++++ config/test.exs | 7 +++++++ docker-compose.yml | 12 +++++++++++ mix.lock | 6 ++++++ 16 files changed, 209 insertions(+) create mode 100644 apps/blog/.formatter.exs create mode 100644 apps/blog/.gitignore create mode 100644 apps/blog/README.md create mode 100644 apps/blog/lib/blog.ex create mode 100644 apps/blog/lib/blog/application.ex create mode 100644 apps/blog/lib/blog/release.ex create mode 100644 apps/blog/lib/blog/repo.ex create mode 100644 apps/blog/mix.exs create mode 100644 apps/blog/test/blog_test.exs create mode 100644 apps/blog/test/test_helper.exs diff --git a/apps/blog/.formatter.exs b/apps/blog/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/apps/blog/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/apps/blog/.gitignore b/apps/blog/.gitignore new file mode 100644 index 0000000..bf33fc9 --- /dev/null +++ b/apps/blog/.gitignore @@ -0,0 +1,24 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +blog-*.tar + diff --git a/apps/blog/README.md b/apps/blog/README.md new file mode 100644 index 0000000..4632a3c --- /dev/null +++ b/apps/blog/README.md @@ -0,0 +1,21 @@ +# Blog + +**TODO: Add description** + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `blog` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:blog, "~> 0.1.0"} + ] +end +``` + +Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) +and published on [HexDocs](https://hexdocs.pm). Once published, the docs can +be found at [https://hexdocs.pm/blog](https://hexdocs.pm/blog). + diff --git a/apps/blog/lib/blog.ex b/apps/blog/lib/blog.ex new file mode 100644 index 0000000..97e91ed --- /dev/null +++ b/apps/blog/lib/blog.ex @@ -0,0 +1,18 @@ +defmodule Blog do + @moduledoc """ + Documentation for `Blog`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> Blog.hello() + :world + + """ + def hello do + :world + end +end diff --git a/apps/blog/lib/blog/application.ex b/apps/blog/lib/blog/application.ex new file mode 100644 index 0000000..2d57845 --- /dev/null +++ b/apps/blog/lib/blog/application.ex @@ -0,0 +1,11 @@ +defmodule Blog.Application do + @moduledoc false + + use Application + + def start(_type, _args) do + children = [Blog.Repo] + + Supervisor.start_link(children, strategy: :one_for_one, name: Blog.Supervisor) + end +end diff --git a/apps/blog/lib/blog/release.ex b/apps/blog/lib/blog/release.ex new file mode 100644 index 0000000..571d61c --- /dev/null +++ b/apps/blog/lib/blog/release.ex @@ -0,0 +1,34 @@ +defmodule Blog.Release do + @moduledoc """ + Module for running migrations and rollback using + the release binary. + Example: bin/web eval "Blog.Release.migrate" + """ + + @app :blog + + def migrate do + load_app() + + for repo <- repos() do + {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true)) + end + end + + def rollback(repo, version) do + load_app() + {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version)) + end + + defp repos do + Application.fetch_env!(@app, :ecto_repos) + end + + defp load_app do + Application.load(@app) + end + + + + +end diff --git a/apps/blog/lib/blog/repo.ex b/apps/blog/lib/blog/repo.ex new file mode 100644 index 0000000..d7aeb69 --- /dev/null +++ b/apps/blog/lib/blog/repo.ex @@ -0,0 +1,7 @@ +defmodule Blog.Repo do + @moduledoc false + + use Ecto.Repo, + otp_app: :blog, + adapter: Ecto.Adapters.Postgres +end diff --git a/apps/blog/mix.exs b/apps/blog/mix.exs new file mode 100644 index 0000000..a73e438 --- /dev/null +++ b/apps/blog/mix.exs @@ -0,0 +1,30 @@ +defmodule Blog.MixProject do + use Mix.Project + + def project do + [ + app: :blog, + version: "0.1.0", + build_path: "../../_build", + config_path: "../../config/config.exs", + deps_path: "../../deps", + lockfile: "../../mix.lock", + elixir: "~> 1.10", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + def application do + [ + mod: {Blog.Application, []} + ] + end + + defp deps do + [ + {:ecto_sql, "~> 3.4"}, + {:postgrex, ">= 0.0.0"} + ] + end +end diff --git a/apps/blog/test/blog_test.exs b/apps/blog/test/blog_test.exs new file mode 100644 index 0000000..d4a8210 --- /dev/null +++ b/apps/blog/test/blog_test.exs @@ -0,0 +1,8 @@ +defmodule BlogTest do + use ExUnit.Case + doctest Blog + + test "greets the world" do + assert Blog.hello() == :world + end +end diff --git a/apps/blog/test/test_helper.exs b/apps/blog/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/apps/blog/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start() diff --git a/config/config.exs b/config/config.exs index 42df06f..c838d53 100644 --- a/config/config.exs +++ b/config/config.exs @@ -8,4 +8,10 @@ config :web, Web.Endpoint, pubsub_server: Web.PubSub, live_view: [signing_salt: "nNxuMZr4Bq73HLMihu1pYEdtKLAL/f+Z"] +config :blog, + ecto_repos: [Blog.Repo] + +config :blog, Blog.Repo, + migration_timestamps: [type: :utc_datetime] + import_config "#{Mix.env()}.exs" diff --git a/config/dev.exs b/config/dev.exs index d1ef2bf..b3f821c 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -21,3 +21,11 @@ config :web, Web.Endpoint, cd: Path.expand("../apps/web/assets", __DIR__) ] ] + +config :blog, Blog.Repo, + username: "postgres", + password: "postgres", + database: "branchpage_dev", + hostname: "db", + show_sensitive_data_on_connection_error: true, + pool_size: 10 diff --git a/config/releases.exs b/config/releases.exs index becde76..59c05a5 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -1 +1,13 @@ import Config + +config :web, Web.Endpoint, + secret_key_base: get_or_raise("SECRET_KEY_BASE") + +config :blog, Blog.Repo, + start_apps_before_migration: [:ssl], + ssl: true, + url: get_or_raise("DATABASE_URL"), + pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10") + +defp get_or_raise(env_var), + do: System.get_env(env_var) || raise "Missing environment variable #{env_var}" diff --git a/config/test.exs b/config/test.exs index 59769da..9024395 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,3 +1,10 @@ import Config config :web, Web.Endpoint, http: [port: 4000] + +config :blog, Blog.Repo, + username: "postgres", + password: "postgres", + database: "branchpage_test#{System.get_env("MIX_TEST_PARTITION")}", + hostname: "db", + pool: Ecto.Adapters.SQL.Sandbox diff --git a/docker-compose.yml b/docker-compose.yml index b5a99a7..cbcc635 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,3 +13,15 @@ services: - 4000:4000 volumes: - .:/branchpage + + db: + image: postgres:13 + container_name: branchpage_db + environment: + - POSTGRES_HOST_AUTH_METHOD=trust + - PGUSER=postgres + volumes: + - postgres_data:/var/lib/postgresql/data/ + +volumes: + postgres_data: diff --git a/mix.lock b/mix.lock index bf7a199..634db6d 100644 --- a/mix.lock +++ b/mix.lock @@ -2,10 +2,15 @@ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, "certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"}, "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"}, + "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "cowboy": {:hex, :cowboy, "2.8.0", "f3dc62e35797ecd9ac1b50db74611193c29815401e53bac9a5c0577bd7bc667d", [:rebar3], [{:cowlib, "~> 2.9.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "4643e4fba74ac96d4d152c75803de6fad0b3fa5df354c71afdd6cbeeb15fac8a"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.1", "ebd1a1d7aff97f27c66654e78ece187abdc646992714164380d8a041eda16754", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a6efd3366130eab84ca372cbd4a7d3c3a97bdfcfb4911233b035d117063f0af"}, "cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"}, "credo": {:hex, :credo, "1.5.5", "e8f422026f553bc3bebb81c8e8bf1932f498ca03339856c7fec63d3faac8424b", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "dd8623ab7091956a855dc9f3062486add9c52d310dfd62748779c4315d8247de"}, + "db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"}, + "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, + "ecto": {:hex, :ecto, "3.6.1", "7bb317e3fd0179ad725069fd0fe8a28ebe48fec6282e964ea502e4deccb0bd0f", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbb3294a990447b19f0725488a749f8cf806374e0d9d0dffc45d61e7aeaf6553"}, + "ecto_sql": {:hex, :ecto_sql, "3.6.1", "8774dc3fc0ff7b6be510858b99883640f990c0736b8ab54588f9a0c91807f909", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "66f35c3f2d5978b6bffebd1e6351ab8c9d6b68650d62abd1ab8d149de40e0779"}, "excoveralls": {:hex, :excoveralls, "0.13.3", "edc5f69218f84c2bf61b3609a22ddf1cec0fbf7d1ba79e59f4c16d42ea4347ed", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cc26f48d2f68666380b83d8aafda0fffc65dafcc8d8650358e0b61f6a99b1154"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "gettext": {:hex, :gettext, "0.18.2", "7df3ea191bb56c0309c00a783334b288d08a879f53a7014341284635850a6e55", [:mix], [], "hexpm", "f9f537b13d4fdd30f3039d33cb80144c3aa1f8d9698e47d7bcbcc8df93b1f5c5"}, @@ -24,6 +29,7 @@ "plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"}, "plug_cowboy": {:hex, :plug_cowboy, "2.4.1", "779ba386c0915027f22e14a48919a9545714f849505fa15af2631a0d298abf0f", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d72113b6dff7b37a7d9b2a5b68892808e3a9a752f2bf7e503240945385b70507"}, "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, + "postgrex": {:hex, :postgrex, "0.15.8", "f5e782bbe5e8fa178d5e3cd1999c857dc48eda95f0a4d7f7bd92a50e84a0d491", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "698fbfacea34c4cf22c8281abeb5cf68d99628d541874f085520ab3b53d356fe"}, "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"}, From 19d99cba663c223866738d2830a15bf93f9a754c Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 01:08:09 -0300 Subject: [PATCH 02/95] add blog configs --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index a6b275a..77c3ad0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ ENV MIX_ENV=$MIX_ENV # install mix dependencies COPY mix.exs mix.lock ./ COPY apps/web/mix.exs apps/web/mix.exs +COPY apps/blog/mix.exs apps/blog/mix.exs COPY config config RUN mix do deps.get, deps.compile --skip-umbrella-children From 0418b45ac7c483a80ead21c9e8eb06abcfcccf69 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 01:16:13 -0300 Subject: [PATCH 03/95] fix docker environment --- Dockerfile | 4 +--- docker-compose.yml | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 77c3ad0..d3688a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /branchpage RUN mix do local.hex --force, local.rebar --force -RUN apk add inotify-tools +RUN apk add npm inotify-tools # ----------------- @@ -37,8 +37,6 @@ RUN mix compile # ----------------- FROM build AS release -RUN apk add npm - # install node dependencies RUN npm ci --prefix ./apps/web/assets --no-audit diff --git a/docker-compose.yml b/docker-compose.yml index cbcc635..15fb2b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,8 @@ services: - 4000:4000 volumes: - .:/branchpage + depends_on: + - db db: image: postgres:13 @@ -21,7 +23,7 @@ services: - POSTGRES_HOST_AUTH_METHOD=trust - PGUSER=postgres volumes: - - postgres_data:/var/lib/postgresql/data/ + - db_data:/var/lib/postgresql/data/ volumes: - postgres_data: + db_data: From 989d28e72acfb50afe5debc05c7631e27d27caec Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 01:21:31 -0300 Subject: [PATCH 04/95] fix format --- apps/blog/lib/blog/release.ex | 4 ---- config/config.exs | 3 +-- config/releases.exs | 5 ++--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/blog/lib/blog/release.ex b/apps/blog/lib/blog/release.ex index 571d61c..df95fe2 100644 --- a/apps/blog/lib/blog/release.ex +++ b/apps/blog/lib/blog/release.ex @@ -27,8 +27,4 @@ defmodule Blog.Release do defp load_app do Application.load(@app) end - - - - end diff --git a/config/config.exs b/config/config.exs index c838d53..f98b060 100644 --- a/config/config.exs +++ b/config/config.exs @@ -11,7 +11,6 @@ config :web, Web.Endpoint, config :blog, ecto_repos: [Blog.Repo] -config :blog, Blog.Repo, - migration_timestamps: [type: :utc_datetime] +config :blog, Blog.Repo, migration_timestamps: [type: :utc_datetime] import_config "#{Mix.env()}.exs" diff --git a/config/releases.exs b/config/releases.exs index 59c05a5..d6689a9 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -1,7 +1,6 @@ import Config -config :web, Web.Endpoint, - secret_key_base: get_or_raise("SECRET_KEY_BASE") +config :web, Web.Endpoint, secret_key_base: get_or_raise("SECRET_KEY_BASE") config :blog, Blog.Repo, start_apps_before_migration: [:ssl], @@ -10,4 +9,4 @@ config :blog, Blog.Repo, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10") defp get_or_raise(env_var), - do: System.get_env(env_var) || raise "Missing environment variable #{env_var}" + do: System.get_env(env_var) || raise("Missing environment variable #{env_var}") From b7a9cbd4253070aef9af0e50f1a251ad53357c84 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 01:52:05 -0300 Subject: [PATCH 05/95] fix raises --- config/releases.exs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config/releases.exs b/config/releases.exs index d6689a9..de38724 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -1,12 +1,10 @@ import Config -config :web, Web.Endpoint, secret_key_base: get_or_raise("SECRET_KEY_BASE") +config :web, Web.Endpoint, + secret_key_base: System.get_env("SECRET_KEY_BASE") || raise("SECRET_KEY_BASE is missing.") config :blog, Blog.Repo, start_apps_before_migration: [:ssl], ssl: true, - url: get_or_raise("DATABASE_URL"), + url: System.get_env("DATABASE_URL") || raise("DATABASE_URL is missing."), pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10") - -defp get_or_raise(env_var), - do: System.get_env(env_var) || raise("Missing environment variable #{env_var}") From 32175c3b076a39c783c6b89136e55c96f5925e30 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 09:32:56 -0300 Subject: [PATCH 06/95] add blog migration --- apps/blog/mix.exs | 9 ++++++++- .../20210421121019_create_blog_table.exs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs diff --git a/apps/blog/mix.exs b/apps/blog/mix.exs index a73e438..1a7c58d 100644 --- a/apps/blog/mix.exs +++ b/apps/blog/mix.exs @@ -11,7 +11,8 @@ defmodule Blog.MixProject do lockfile: "../../mix.lock", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, - deps: deps() + deps: deps(), + aliases: aliases() ] end @@ -27,4 +28,10 @@ defmodule Blog.MixProject do {:postgrex, ">= 0.0.0"} ] end + + defp aliases do + [ + test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"] + ] + end end diff --git a/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs b/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs new file mode 100755 index 0000000..bc9429e --- /dev/null +++ b/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs @@ -0,0 +1,16 @@ +defmodule Blog.Repo.Migrations.CreateBlogTable do + use Ecto.Migration + + def change do + create table(:blog, primary_key: false) do + add :id, :uuid, primary_key: true, default: fragment("gen_random_uuid()") + add :fullname, :string + add :username, :string + add :bio, :string + add :donate_url, :string + + timestamps() + end + + end +end From c47cc0bc372604e2560512fcfc38ccb5778d00f7 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 09:37:14 -0300 Subject: [PATCH 07/95] add article migration --- .../20210421121019_create_blog_table.exs | 1 - .../20210421123442_create_article_table.exs | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs diff --git a/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs b/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs index bc9429e..b207bda 100755 --- a/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs +++ b/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs @@ -11,6 +11,5 @@ defmodule Blog.Repo.Migrations.CreateBlogTable do timestamps() end - end end diff --git a/apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs b/apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs new file mode 100644 index 0000000..225ff92 --- /dev/null +++ b/apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs @@ -0,0 +1,14 @@ +defmodule Blog.Repo.Migrations.CreateArticleTable do + use Ecto.Migration + + def change do + create table(:article, primary_key: false) do + add :id, :uuid, primary_key: true, default: fragment("gen_random_uuid()") + add :title, :string + add :edit_url, :string + add :blog_id, references(:blog, type: :uuid) + + timestamps() + end + end +end From 5d64be661812c085396a5075c68a658812e0e236 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 09:39:58 -0300 Subject: [PATCH 08/95] add release stage --- heroku.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/heroku.yml b/heroku.yml index 8eec25b..f1fad5f 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,3 +1,7 @@ build: docker: web: Dockerfile +release: + image: web + command: + - bin/web eval "Blog.Release.migrate" From a679c19cafcb3b4cbf0b433dfa914894f338c72f Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 09:43:36 -0300 Subject: [PATCH 09/95] add coverage configs --- apps/blog/mix.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/blog/mix.exs b/apps/blog/mix.exs index 1a7c58d..229c751 100644 --- a/apps/blog/mix.exs +++ b/apps/blog/mix.exs @@ -11,6 +11,7 @@ defmodule Blog.MixProject do lockfile: "../../mix.lock", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, + test_coverage: [tool: ExCoveralls], deps: deps(), aliases: aliases() ] From febbc1e5283186e2ffdd0e01d2cabd718108669c Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 09:49:43 -0300 Subject: [PATCH 10/95] add blog dependency --- apps/web/mix.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/web/mix.exs b/apps/web/mix.exs index c3af783..65b960c 100644 --- a/apps/web/mix.exs +++ b/apps/web/mix.exs @@ -26,6 +26,7 @@ defmodule Web.MixProject do defp deps do [ + {:blog, in_umbrella: true}, {:phoenix, "~> 1.5.8"}, {:phoenix_html, "~> 2.14"}, {:phoenix_live_view, "~> 0.15.4"}, From cf464f8a98b8efaed8a673f451d621a7b65451c4 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 10:09:33 -0300 Subject: [PATCH 11/95] add ssl to extra apps --- apps/blog/mix.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/blog/mix.exs b/apps/blog/mix.exs index 229c751..bc3b810 100644 --- a/apps/blog/mix.exs +++ b/apps/blog/mix.exs @@ -19,7 +19,8 @@ defmodule Blog.MixProject do def application do [ - mod: {Blog.Application, []} + mod: {Blog.Application, []}, + extra_applications: [:ssl] ] end From 87c04ed2defbc5b4d07223ce09a48b82a8b92cac Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 10:42:44 -0300 Subject: [PATCH 12/95] rename app to publishing --- Dockerfile | 2 +- apps/blog/test/blog_test.exs | 8 -------- apps/{blog => publishing}/.formatter.exs | 0 apps/{blog => publishing}/.gitignore | 0 apps/{blog => publishing}/README.md | 8 ++++---- apps/{blog/lib/blog.ex => publishing/lib/publishing.ex} | 6 +++--- .../lib/blog => publishing/lib/publishing}/application.ex | 6 +++--- .../lib/blog => publishing/lib/publishing}/release.ex | 6 +++--- apps/{blog/lib/blog => publishing/lib/publishing}/repo.ex | 4 ++-- apps/{blog => publishing}/mix.exs | 6 +++--- .../repo/migrations/20210421121019_create_blog_table.exs | 2 +- .../migrations/20210421123442_create_article_table.exs | 2 +- apps/publishing/test/publishing_test.exs | 8 ++++++++ apps/{blog => publishing}/test/test_helper.exs | 0 apps/web/mix.exs | 2 +- config/config.exs | 6 +++--- config/dev.exs | 2 +- config/releases.exs | 2 +- config/test.exs | 2 +- heroku.yml | 2 +- 20 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 apps/blog/test/blog_test.exs rename apps/{blog => publishing}/.formatter.exs (100%) rename apps/{blog => publishing}/.gitignore (100%) rename apps/{blog => publishing}/README.md (63%) rename apps/{blog/lib/blog.ex => publishing/lib/publishing.ex} (58%) rename apps/{blog/lib/blog => publishing/lib/publishing}/application.ex (60%) rename apps/{blog/lib/blog => publishing/lib/publishing}/release.ex (83%) rename apps/{blog/lib/blog => publishing/lib/publishing}/repo.ex (58%) rename apps/{blog => publishing}/mix.exs (86%) rename apps/{blog => publishing}/priv/repo/migrations/20210421121019_create_blog_table.exs (84%) rename apps/{blog => publishing}/priv/repo/migrations/20210421123442_create_article_table.exs (84%) create mode 100644 apps/publishing/test/publishing_test.exs rename apps/{blog => publishing}/test/test_helper.exs (100%) diff --git a/Dockerfile b/Dockerfile index d3688a0..9eb939d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ ENV MIX_ENV=$MIX_ENV # install mix dependencies COPY mix.exs mix.lock ./ COPY apps/web/mix.exs apps/web/mix.exs -COPY apps/blog/mix.exs apps/blog/mix.exs +COPY apps/publishing/mix.exs apps/publishing/mix.exs COPY config config RUN mix do deps.get, deps.compile --skip-umbrella-children diff --git a/apps/blog/test/blog_test.exs b/apps/blog/test/blog_test.exs deleted file mode 100644 index d4a8210..0000000 --- a/apps/blog/test/blog_test.exs +++ /dev/null @@ -1,8 +0,0 @@ -defmodule BlogTest do - use ExUnit.Case - doctest Blog - - test "greets the world" do - assert Blog.hello() == :world - end -end diff --git a/apps/blog/.formatter.exs b/apps/publishing/.formatter.exs similarity index 100% rename from apps/blog/.formatter.exs rename to apps/publishing/.formatter.exs diff --git a/apps/blog/.gitignore b/apps/publishing/.gitignore similarity index 100% rename from apps/blog/.gitignore rename to apps/publishing/.gitignore diff --git a/apps/blog/README.md b/apps/publishing/README.md similarity index 63% rename from apps/blog/README.md rename to apps/publishing/README.md index 4632a3c..3e3f96a 100644 --- a/apps/blog/README.md +++ b/apps/publishing/README.md @@ -1,21 +1,21 @@ -# Blog +# Publishing **TODO: Add description** ## Installation If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `blog` to your list of dependencies in `mix.exs`: +by adding `publishing` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:blog, "~> 0.1.0"} + {:publishing, "~> 0.1.0"} ] end ``` Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) and published on [HexDocs](https://hexdocs.pm). Once published, the docs can -be found at [https://hexdocs.pm/blog](https://hexdocs.pm/blog). +be found at [https://hexdocs.pm/publishing](https://hexdocs.pm/publishing). diff --git a/apps/blog/lib/blog.ex b/apps/publishing/lib/publishing.ex similarity index 58% rename from apps/blog/lib/blog.ex rename to apps/publishing/lib/publishing.ex index 97e91ed..ccb0d42 100644 --- a/apps/blog/lib/blog.ex +++ b/apps/publishing/lib/publishing.ex @@ -1,6 +1,6 @@ -defmodule Blog do +defmodule Publishing do @moduledoc """ - Documentation for `Blog`. + Documentation for `Publishing`. """ @doc """ @@ -8,7 +8,7 @@ defmodule Blog do ## Examples - iex> Blog.hello() + iex> Publishing.hello() :world """ diff --git a/apps/blog/lib/blog/application.ex b/apps/publishing/lib/publishing/application.ex similarity index 60% rename from apps/blog/lib/blog/application.ex rename to apps/publishing/lib/publishing/application.ex index 2d57845..a64fbff 100644 --- a/apps/blog/lib/blog/application.ex +++ b/apps/publishing/lib/publishing/application.ex @@ -1,11 +1,11 @@ -defmodule Blog.Application do +defmodule Publishing.Application do @moduledoc false use Application def start(_type, _args) do - children = [Blog.Repo] + children = [Publishing.Repo] - Supervisor.start_link(children, strategy: :one_for_one, name: Blog.Supervisor) + Supervisor.start_link(children, strategy: :one_for_one, name: Publishing.Supervisor) end end diff --git a/apps/blog/lib/blog/release.ex b/apps/publishing/lib/publishing/release.ex similarity index 83% rename from apps/blog/lib/blog/release.ex rename to apps/publishing/lib/publishing/release.ex index df95fe2..17434c1 100644 --- a/apps/blog/lib/blog/release.ex +++ b/apps/publishing/lib/publishing/release.ex @@ -1,11 +1,11 @@ -defmodule Blog.Release do +defmodule Publishing.Release do @moduledoc """ Module for running migrations and rollback using the release binary. - Example: bin/web eval "Blog.Release.migrate" + Example: bin/web eval "Publishing.Release.migrate" """ - @app :blog + @app :publishing def migrate do load_app() diff --git a/apps/blog/lib/blog/repo.ex b/apps/publishing/lib/publishing/repo.ex similarity index 58% rename from apps/blog/lib/blog/repo.ex rename to apps/publishing/lib/publishing/repo.ex index d7aeb69..206cd53 100644 --- a/apps/blog/lib/blog/repo.ex +++ b/apps/publishing/lib/publishing/repo.ex @@ -1,7 +1,7 @@ -defmodule Blog.Repo do +defmodule Publishing.Repo do @moduledoc false use Ecto.Repo, - otp_app: :blog, + otp_app: :publishing, adapter: Ecto.Adapters.Postgres end diff --git a/apps/blog/mix.exs b/apps/publishing/mix.exs similarity index 86% rename from apps/blog/mix.exs rename to apps/publishing/mix.exs index bc3b810..ed5f751 100644 --- a/apps/blog/mix.exs +++ b/apps/publishing/mix.exs @@ -1,9 +1,9 @@ -defmodule Blog.MixProject do +defmodule Publishing.MixProject do use Mix.Project def project do [ - app: :blog, + app: :publishing, version: "0.1.0", build_path: "../../_build", config_path: "../../config/config.exs", @@ -19,7 +19,7 @@ defmodule Blog.MixProject do def application do [ - mod: {Blog.Application, []}, + mod: {Publishing.Application, []}, extra_applications: [:ssl] ] end diff --git a/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs b/apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs similarity index 84% rename from apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs rename to apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs index b207bda..ad1aa2d 100755 --- a/apps/blog/priv/repo/migrations/20210421121019_create_blog_table.exs +++ b/apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs @@ -1,4 +1,4 @@ -defmodule Blog.Repo.Migrations.CreateBlogTable do +defmodule Publishing.Repo.Migrations.CreateBlogTable do use Ecto.Migration def change do diff --git a/apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs b/apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs similarity index 84% rename from apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs rename to apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs index 225ff92..a472470 100644 --- a/apps/blog/priv/repo/migrations/20210421123442_create_article_table.exs +++ b/apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs @@ -1,4 +1,4 @@ -defmodule Blog.Repo.Migrations.CreateArticleTable do +defmodule Publishing.Repo.Migrations.CreateArticleTable do use Ecto.Migration def change do diff --git a/apps/publishing/test/publishing_test.exs b/apps/publishing/test/publishing_test.exs new file mode 100644 index 0000000..33a1378 --- /dev/null +++ b/apps/publishing/test/publishing_test.exs @@ -0,0 +1,8 @@ +defmodule PublishingTest do + use ExUnit.Case + doctest Publishing + + test "greets the world" do + assert Publishing.hello() == :world + end +end diff --git a/apps/blog/test/test_helper.exs b/apps/publishing/test/test_helper.exs similarity index 100% rename from apps/blog/test/test_helper.exs rename to apps/publishing/test/test_helper.exs diff --git a/apps/web/mix.exs b/apps/web/mix.exs index 65b960c..08f51f2 100644 --- a/apps/web/mix.exs +++ b/apps/web/mix.exs @@ -26,7 +26,7 @@ defmodule Web.MixProject do defp deps do [ - {:blog, in_umbrella: true}, + {:publishing, in_umbrella: true}, {:phoenix, "~> 1.5.8"}, {:phoenix_html, "~> 2.14"}, {:phoenix_live_view, "~> 0.15.4"}, diff --git a/config/config.exs b/config/config.exs index f98b060..151cb75 100644 --- a/config/config.exs +++ b/config/config.exs @@ -8,9 +8,9 @@ config :web, Web.Endpoint, pubsub_server: Web.PubSub, live_view: [signing_salt: "nNxuMZr4Bq73HLMihu1pYEdtKLAL/f+Z"] -config :blog, - ecto_repos: [Blog.Repo] +config :publishing, + ecto_repos: [Publishing.Repo] -config :blog, Blog.Repo, migration_timestamps: [type: :utc_datetime] +config :publishing, Publishing.Repo, migration_timestamps: [type: :utc_datetime] import_config "#{Mix.env()}.exs" diff --git a/config/dev.exs b/config/dev.exs index b3f821c..4b4ae91 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -22,7 +22,7 @@ config :web, Web.Endpoint, ] ] -config :blog, Blog.Repo, +config :publishing, Publishing.Repo, username: "postgres", password: "postgres", database: "branchpage_dev", diff --git a/config/releases.exs b/config/releases.exs index de38724..3ac5d99 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -3,7 +3,7 @@ import Config config :web, Web.Endpoint, secret_key_base: System.get_env("SECRET_KEY_BASE") || raise("SECRET_KEY_BASE is missing.") -config :blog, Blog.Repo, +config :publishing, Publishing.Repo, start_apps_before_migration: [:ssl], ssl: true, url: System.get_env("DATABASE_URL") || raise("DATABASE_URL is missing."), diff --git a/config/test.exs b/config/test.exs index 9024395..7ea672f 100644 --- a/config/test.exs +++ b/config/test.exs @@ -2,7 +2,7 @@ import Config config :web, Web.Endpoint, http: [port: 4000] -config :blog, Blog.Repo, +config :publishing, Publishing.Repo, username: "postgres", password: "postgres", database: "branchpage_test#{System.get_env("MIX_TEST_PARTITION")}", diff --git a/heroku.yml b/heroku.yml index f1fad5f..768aba2 100644 --- a/heroku.yml +++ b/heroku.yml @@ -4,4 +4,4 @@ build: release: image: web command: - - bin/web eval "Blog.Release.migrate" + - bin/web eval "Publishing.Release.migrate" From 210ada59255ba1607fe6c639b0ee5c34aea6581a Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 11:01:09 -0300 Subject: [PATCH 13/95] create blog schema --- apps/publishing/lib/publishing/blog.ex | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 apps/publishing/lib/publishing/blog.ex diff --git a/apps/publishing/lib/publishing/blog.ex b/apps/publishing/lib/publishing/blog.ex new file mode 100644 index 0000000..a4eef33 --- /dev/null +++ b/apps/publishing/lib/publishing/blog.ex @@ -0,0 +1,27 @@ +defmodule Publishing.Blog do + @moduledoc false + + use Ecto.Schema + import Ecto.Changeset + + @primary_key {:id, :binary_id, autogenerate: true} + @optional_fields ~w(fullname username bio donate_url)a + @required_fields ~w()a + + schema "blog" do + field(:fullname, :string) + field(:username, :string) + field(:bio, :string) + field(:donate_url, :string) + + # has_many :articles, Publishing.Article + + timestamps() + end + + def changeset(%__MODULE__{} = struct, %{} = attrs) do + struct + |> cast(attrs, @optional_fields ++ @required_fields) + |> validate_required(@required_fields) + end +end From c74232da30c778500b40e1f227724207cf876481 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 11:15:08 -0300 Subject: [PATCH 14/95] create article schema --- apps/publishing/lib/publishing/article.ex | 26 +++++++++++++++++++++++ apps/publishing/lib/publishing/blog.ex | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 apps/publishing/lib/publishing/article.ex diff --git a/apps/publishing/lib/publishing/article.ex b/apps/publishing/lib/publishing/article.ex new file mode 100644 index 0000000..d70b629 --- /dev/null +++ b/apps/publishing/lib/publishing/article.ex @@ -0,0 +1,26 @@ +defmodule Publishing.Article do + @moduledoc false + + use Ecto.Schema + import Ecto.Changeset + + @primary_key {:id, :binary_id, autogenerate: true} + @optional_fields ~w(title edit_url blog_id)a + @required_fields ~w()a + + schema "article" do + field(:title, :string) + field(:edit_url, :string) + + belongs_to(:blog, Publishing.Blog, type: :binary_id) + + timestamps() + end + + def changeset(%__MODULE__{} = struct, %{} = attrs) do + struct + |> cast(attrs, @optional_fields ++ @required_fields) + |> validate_required(@required_fields) + |> assoc_constraint(:blog) + end +end diff --git a/apps/publishing/lib/publishing/blog.ex b/apps/publishing/lib/publishing/blog.ex index a4eef33..c7f6c10 100644 --- a/apps/publishing/lib/publishing/blog.ex +++ b/apps/publishing/lib/publishing/blog.ex @@ -14,7 +14,7 @@ defmodule Publishing.Blog do field(:bio, :string) field(:donate_url, :string) - # has_many :articles, Publishing.Article + has_many(:articles, Publishing.Article) timestamps() end From ec1e197a1a95b76c1ff87c1ce52fc1ff9f0da1c7 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 11:28:17 -0300 Subject: [PATCH 15/95] add blog changeset tests --- apps/publishing/test/publishing/blog_test.exs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 apps/publishing/test/publishing/blog_test.exs diff --git a/apps/publishing/test/publishing/blog_test.exs b/apps/publishing/test/publishing/blog_test.exs new file mode 100644 index 0000000..6038cf1 --- /dev/null +++ b/apps/publishing/test/publishing/blog_test.exs @@ -0,0 +1,27 @@ +defmodule Publishing.BlogTest do + use ExUnit.Case, async: true + + alias Publishing.Blog + + @valid_empty_attrs %{} + @valid_attrs %{ + fullname: "fullname", + username: "username", + bio: "bio", + donate_url: "donate_url" + } + @invalid_attrs %{fullname: 0, username: 0, bio: 0, donate_url: 0} + + test "channgeset/2 with valid params" do + changeset = Blog.changeset(%Blog{}, @valid_empty_attrs) + assert changeset.valid? + + changeset = Blog.changeset(%Blog{}, @valid_attrs) + assert changeset.valid? + end + + test "channgeset/2 with invalid params" do + changeset = Blog.changeset(%Blog{}, @invalid_attrs) + refute changeset.valid? + end +end From bf04d197f7d2647ba31db3cea874eb6b724ea44a Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 11:44:55 -0300 Subject: [PATCH 16/95] add article tests --- .iex.exs | 2 ++ apps/publishing/coveralls.json | 11 +++++++++ apps/publishing/mix.exs | 7 +++++- .../test/publishing/article_test.exs | 24 +++++++++++++++++++ apps/publishing/test/publishing/blog_test.exs | 4 +++- apps/publishing/test/support/factory.ex | 13 ++++++++++ mix.lock | 1 + 7 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .iex.exs create mode 100644 apps/publishing/coveralls.json create mode 100644 apps/publishing/test/publishing/article_test.exs create mode 100644 apps/publishing/test/support/factory.ex diff --git a/.iex.exs b/.iex.exs new file mode 100644 index 0000000..a287a3b --- /dev/null +++ b/.iex.exs @@ -0,0 +1,2 @@ +alias Publishing.Repo +alias Publishing.{Article, Blog} diff --git a/apps/publishing/coveralls.json b/apps/publishing/coveralls.json new file mode 100644 index 0000000..7d29f6b --- /dev/null +++ b/apps/publishing/coveralls.json @@ -0,0 +1,11 @@ +{ + "skip_files": [ + "lib/publishing/application.ex", + "lib/publishing/release.ex", + "lib/publishing/repo.ex", + "test/support" + ], + "coverage_options": { + "treat_no_relevant_lines_as_covered": true + } +} diff --git a/apps/publishing/mix.exs b/apps/publishing/mix.exs index ed5f751..f8df8ac 100644 --- a/apps/publishing/mix.exs +++ b/apps/publishing/mix.exs @@ -10,6 +10,7 @@ defmodule Publishing.MixProject do deps_path: "../../deps", lockfile: "../../mix.lock", elixir: "~> 1.10", + elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], deps: deps(), @@ -24,10 +25,14 @@ defmodule Publishing.MixProject do ] end + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] + defp deps do [ {:ecto_sql, "~> 3.4"}, - {:postgrex, ">= 0.0.0"} + {:postgrex, ">= 0.0.0"}, + {:ex_machina, "~> 2.7.0", only: :test} ] end diff --git a/apps/publishing/test/publishing/article_test.exs b/apps/publishing/test/publishing/article_test.exs new file mode 100644 index 0000000..aecbcae --- /dev/null +++ b/apps/publishing/test/publishing/article_test.exs @@ -0,0 +1,24 @@ +defmodule Publishing.ArticleTest do + use ExUnit.Case, async: true + + alias Publishing.Article + + @valid_empty_attrs %{} + @valid_attrs %{article: "article", edit_url: "edit_url", blog_id: "blog_id"} + @invalid_attrs %{article: 0, edit_url: 0} + + test "channgeset/2 with valid empty params" do + changeset = Article.changeset(%Article{}, @valid_empty_attrs) + assert changeset.valid? + end + + test "channgeset/2 with valid params" do + changeset = Article.changeset(%Article{}, @valid_attrs) + assert changeset.valid? + end + + test "channgeset/2 with invalid params" do + changeset = Article.changeset(%Article{}, @invalid_attrs) + refute changeset.valid? + end +end diff --git a/apps/publishing/test/publishing/blog_test.exs b/apps/publishing/test/publishing/blog_test.exs index 6038cf1..c1fc813 100644 --- a/apps/publishing/test/publishing/blog_test.exs +++ b/apps/publishing/test/publishing/blog_test.exs @@ -12,10 +12,12 @@ defmodule Publishing.BlogTest do } @invalid_attrs %{fullname: 0, username: 0, bio: 0, donate_url: 0} - test "channgeset/2 with valid params" do + test "channgeset/2 with valid empty params" do changeset = Blog.changeset(%Blog{}, @valid_empty_attrs) assert changeset.valid? + end + test "channgeset/2 with valid params" do changeset = Blog.changeset(%Blog{}, @valid_attrs) assert changeset.valid? end diff --git a/apps/publishing/test/support/factory.ex b/apps/publishing/test/support/factory.ex new file mode 100644 index 0000000..5369c1c --- /dev/null +++ b/apps/publishing/test/support/factory.ex @@ -0,0 +1,13 @@ +defmodule Publishing.Factory do + @moduledoc """ + Module for teste data fabrication + """ + + use ExMachina.Ecto, repo: Publishing.Repo + + alias Publishing.{Article, Blog} + + def article_factory, do: %Article{} + + def blog_factory, do: %Blog{} +end diff --git a/mix.lock b/mix.lock index 634db6d..5130e30 100644 --- a/mix.lock +++ b/mix.lock @@ -11,6 +11,7 @@ "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, "ecto": {:hex, :ecto, "3.6.1", "7bb317e3fd0179ad725069fd0fe8a28ebe48fec6282e964ea502e4deccb0bd0f", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbb3294a990447b19f0725488a749f8cf806374e0d9d0dffc45d61e7aeaf6553"}, "ecto_sql": {:hex, :ecto_sql, "3.6.1", "8774dc3fc0ff7b6be510858b99883640f990c0736b8ab54588f9a0c91807f909", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "66f35c3f2d5978b6bffebd1e6351ab8c9d6b68650d62abd1ab8d149de40e0779"}, + "ex_machina": {:hex, :ex_machina, "2.7.0", "b792cc3127fd0680fecdb6299235b4727a4944a09ff0fa904cc639272cd92dc7", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "419aa7a39bde11894c87a615c4ecaa52d8f107bbdd81d810465186f783245bf8"}, "excoveralls": {:hex, :excoveralls, "0.13.3", "edc5f69218f84c2bf61b3609a22ddf1cec0fbf7d1ba79e59f4c16d42ea4347ed", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cc26f48d2f68666380b83d8aafda0fffc65dafcc8d8650358e0b61f6a99b1154"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "gettext": {:hex, :gettext, "0.18.2", "7df3ea191bb56c0309c00a783334b288d08a879f53a7014341284635850a6e55", [:mix], [], "hexpm", "f9f537b13d4fdd30f3039d33cb80144c3aa1f8d9698e47d7bcbcc8df93b1f5c5"}, From 2f3406fa27e601e8fa5fad91ad8b2cecb26b3f6e Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 16:46:25 -0300 Subject: [PATCH 17/95] add length validation --- apps/publishing/.formatter.exs | 1 + apps/publishing/lib/publishing/article.ex | 1 + apps/publishing/lib/publishing/blog.ex | 3 ++ .../20210421121019_create_blog_table.exs | 2 +- .../20210421123442_create_article_table.exs | 2 +- .../test/publishing/article_test.exs | 25 ++++++++++++---- apps/publishing/test/publishing/blog_test.exs | 29 +++++++++++++++---- .../test/support/changeset_helpers.ex | 20 +++++++++++++ 8 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 apps/publishing/test/support/changeset_helpers.ex diff --git a/apps/publishing/.formatter.exs b/apps/publishing/.formatter.exs index d2cda26..d7ef50f 100644 --- a/apps/publishing/.formatter.exs +++ b/apps/publishing/.formatter.exs @@ -1,4 +1,5 @@ # Used by "mix format" [ + import_deps: [:ecto, :phoenix], inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] ] diff --git a/apps/publishing/lib/publishing/article.ex b/apps/publishing/lib/publishing/article.ex index d70b629..5c0812f 100644 --- a/apps/publishing/lib/publishing/article.ex +++ b/apps/publishing/lib/publishing/article.ex @@ -21,6 +21,7 @@ defmodule Publishing.Article do struct |> cast(attrs, @optional_fields ++ @required_fields) |> validate_required(@required_fields) + |> validate_length(:title, max: 255) |> assoc_constraint(:blog) end end diff --git a/apps/publishing/lib/publishing/blog.ex b/apps/publishing/lib/publishing/blog.ex index c7f6c10..5855083 100644 --- a/apps/publishing/lib/publishing/blog.ex +++ b/apps/publishing/lib/publishing/blog.ex @@ -23,5 +23,8 @@ defmodule Publishing.Blog do struct |> cast(attrs, @optional_fields ++ @required_fields) |> validate_required(@required_fields) + |> validate_length(:fullname, max: 255) + |> validate_length(:username, max: 255) + |> validate_length(:bio, max: 255) end end diff --git a/apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs b/apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs index ad1aa2d..ae72fc5 100755 --- a/apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs +++ b/apps/publishing/priv/repo/migrations/20210421121019_create_blog_table.exs @@ -7,7 +7,7 @@ defmodule Publishing.Repo.Migrations.CreateBlogTable do add :fullname, :string add :username, :string add :bio, :string - add :donate_url, :string + add :donate_url, :text timestamps() end diff --git a/apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs b/apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs index a472470..30011d6 100644 --- a/apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs +++ b/apps/publishing/priv/repo/migrations/20210421123442_create_article_table.exs @@ -5,7 +5,7 @@ defmodule Publishing.Repo.Migrations.CreateArticleTable do create table(:article, primary_key: false) do add :id, :uuid, primary_key: true, default: fragment("gen_random_uuid()") add :title, :string - add :edit_url, :string + add :edit_url, :text add :blog_id, references(:blog, type: :uuid) timestamps() diff --git a/apps/publishing/test/publishing/article_test.exs b/apps/publishing/test/publishing/article_test.exs index aecbcae..a0e96bc 100644 --- a/apps/publishing/test/publishing/article_test.exs +++ b/apps/publishing/test/publishing/article_test.exs @@ -1,24 +1,37 @@ defmodule Publishing.ArticleTest do use ExUnit.Case, async: true + import Publishing.ChangesetHelpers alias Publishing.Article @valid_empty_attrs %{} - @valid_attrs %{article: "article", edit_url: "edit_url", blog_id: "blog_id"} - @invalid_attrs %{article: 0, edit_url: 0} + @valid_attrs %{title: "title", edit_url: "edit_url", blog_id: "blog_id"} + @invalid_cast_attrs %{title: 0, edit_url: 0, blog_id: 0} + @invalid_length_attrs %{title: long_string()} - test "channgeset/2 with valid empty params" do + test "changeset/2 with valid empty params" do changeset = Article.changeset(%Article{}, @valid_empty_attrs) assert changeset.valid? end - test "channgeset/2 with valid params" do + test "changeset/2 with valid params" do changeset = Article.changeset(%Article{}, @valid_attrs) assert changeset.valid? end - test "channgeset/2 with invalid params" do - changeset = Article.changeset(%Article{}, @invalid_attrs) + test "changeset/2 with invalid cast params" do + changeset = Article.changeset(%Article{}, @invalid_cast_attrs) refute changeset.valid? + + assert %{title: [:cast]} = errors_on(changeset) + assert %{edit_url: [:cast]} = errors_on(changeset) + assert %{blog_id: [:cast]} = errors_on(changeset) + end + + test "changeset/2 with invalid length params" do + changeset = Article.changeset(%Article{}, @invalid_length_attrs) + refute changeset.valid? + + assert %{title: [:length]} = errors_on(changeset) end end diff --git a/apps/publishing/test/publishing/blog_test.exs b/apps/publishing/test/publishing/blog_test.exs index c1fc813..6713059 100644 --- a/apps/publishing/test/publishing/blog_test.exs +++ b/apps/publishing/test/publishing/blog_test.exs @@ -1,6 +1,7 @@ defmodule Publishing.BlogTest do use ExUnit.Case, async: true + import Publishing.ChangesetHelpers alias Publishing.Blog @valid_empty_attrs %{} @@ -10,20 +11,38 @@ defmodule Publishing.BlogTest do bio: "bio", donate_url: "donate_url" } - @invalid_attrs %{fullname: 0, username: 0, bio: 0, donate_url: 0} + @invalid_cast_attrs %{fullname: 0, username: 0, bio: 0, donate_url: 0} + @invalid_length_attrs %{ + fullname: long_string(), + username: long_string(), + bio: long_string() + } - test "channgeset/2 with valid empty params" do + test "changeset/2 with valid empty params" do changeset = Blog.changeset(%Blog{}, @valid_empty_attrs) assert changeset.valid? end - test "channgeset/2 with valid params" do + test "changeset/2 with valid params" do changeset = Blog.changeset(%Blog{}, @valid_attrs) assert changeset.valid? end - test "channgeset/2 with invalid params" do - changeset = Blog.changeset(%Blog{}, @invalid_attrs) + test "changeset/2 with invalid cast params" do + changeset = Blog.changeset(%Blog{}, @invalid_cast_attrs) + refute changeset.valid? + + assert %{fullname: [:cast]} = errors_on(changeset) + assert %{username: [:cast]} = errors_on(changeset) + assert %{bio: [:cast]} = errors_on(changeset) + end + + test "changeset/2 with invalid length params" do + changeset = Blog.changeset(%Blog{}, @invalid_length_attrs) refute changeset.valid? + + assert %{fullname: [:length]} = errors_on(changeset) + assert %{username: [:length]} = errors_on(changeset) + assert %{bio: [:length]} = errors_on(changeset) end end diff --git a/apps/publishing/test/support/changeset_helpers.ex b/apps/publishing/test/support/changeset_helpers.ex new file mode 100644 index 0000000..a236c63 --- /dev/null +++ b/apps/publishing/test/support/changeset_helpers.ex @@ -0,0 +1,20 @@ +defmodule Publishing.ChangesetHelpers do + @moduledoc """ + Helpers for testing ecto changesets. + """ + + @doc """ + Transforms changeset errors into a map of validation keys. + """ + def errors_on(changeset) do + Ecto.Changeset.traverse_errors( + changeset, + fn {_msg, opts} -> opts[:validation] end + ) + end + + @doc """ + Generate a 256 byte sized string. + """ + def long_string, do: String.duplicate("a", 256) +end From 34c420da11acf63a4a45ea8a527e545831bb2325 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 16:59:36 -0300 Subject: [PATCH 18/95] create body virtual field --- apps/publishing/lib/publishing/article.ex | 7 ++++--- apps/publishing/lib/publishing/blog.ex | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/publishing/lib/publishing/article.ex b/apps/publishing/lib/publishing/article.ex index 5c0812f..98badf1 100644 --- a/apps/publishing/lib/publishing/article.ex +++ b/apps/publishing/lib/publishing/article.ex @@ -9,10 +9,11 @@ defmodule Publishing.Article do @required_fields ~w()a schema "article" do - field(:title, :string) - field(:edit_url, :string) + field :title, :string + field :edit_url, :string + field :body, :string, virtual: true - belongs_to(:blog, Publishing.Blog, type: :binary_id) + belongs_to :blog, Publishing.Blog, type: :binary_id timestamps() end diff --git a/apps/publishing/lib/publishing/blog.ex b/apps/publishing/lib/publishing/blog.ex index 5855083..586d2d6 100644 --- a/apps/publishing/lib/publishing/blog.ex +++ b/apps/publishing/lib/publishing/blog.ex @@ -9,12 +9,12 @@ defmodule Publishing.Blog do @required_fields ~w()a schema "blog" do - field(:fullname, :string) - field(:username, :string) - field(:bio, :string) - field(:donate_url, :string) + field :fullname, :string + field :username, :string + field :bio, :string + field :donate_url, :string - has_many(:articles, Publishing.Article) + has_many :articles, Publishing.Article timestamps() end From bab561c98fb50433510f2b3facc33db7a14bd8bf Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 19:00:33 -0300 Subject: [PATCH 19/95] create github integration --- apps/publishing/lib/publishing.ex | 13 ----------- .../lib/publishing/integration/github.ex | 23 +++++++++++++++++++ apps/publishing/test/publishing_test.exs | 5 ---- 3 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 apps/publishing/lib/publishing/integration/github.ex diff --git a/apps/publishing/lib/publishing.ex b/apps/publishing/lib/publishing.ex index ccb0d42..47cd62f 100644 --- a/apps/publishing/lib/publishing.ex +++ b/apps/publishing/lib/publishing.ex @@ -2,17 +2,4 @@ defmodule Publishing do @moduledoc """ Documentation for `Publishing`. """ - - @doc """ - Hello world. - - ## Examples - - iex> Publishing.hello() - :world - - """ - def hello do - :world - end end diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex new file mode 100644 index 0000000..f2333f8 --- /dev/null +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -0,0 +1,23 @@ +defmodule Publishing.Integration.Github do + @moduledoc """ + implement a integration interface + """ + + def to_raw(url) do + [username, repository, "blob" | tail] = decompose(url) + resource = Enum.join(tail, "/") + + "https://raw.githubusercontent.com/#{username}/#{repository}/#{resource}" + end + + def get_username(url) do + [username | _] = decompose(url) + + username + end + + defp decompose(url) do + [_, path] = String.split(url, "github.com/") + String.split(path, "/") + end +end diff --git a/apps/publishing/test/publishing_test.exs b/apps/publishing/test/publishing_test.exs index 33a1378..f083d56 100644 --- a/apps/publishing/test/publishing_test.exs +++ b/apps/publishing/test/publishing_test.exs @@ -1,8 +1,3 @@ defmodule PublishingTest do use ExUnit.Case - doctest Publishing - - test "greets the world" do - assert Publishing.hello() == :world - end end From 138afd431ac623548bcc4a5074a4bd54d1133b9d Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 20:50:01 -0300 Subject: [PATCH 20/95] implement get_body/1 --- apps/publishing/lib/publishing/integration/github.ex | 12 +++++++++++- apps/publishing/mix.exs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index f2333f8..e119dc0 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -12,10 +12,20 @@ defmodule Publishing.Integration.Github do def get_username(url) do [username | _] = decompose(url) - username end + def get_title(body) do + body + end + + def get_body(raw_url) do + {:ok, 200, _, ref} = :hackney.get(raw_url) + {:ok, body} = :hackney.body(ref) + + body + end + defp decompose(url) do [_, path] = String.split(url, "github.com/") String.split(path, "/") diff --git a/apps/publishing/mix.exs b/apps/publishing/mix.exs index f8df8ac..f59e5f9 100644 --- a/apps/publishing/mix.exs +++ b/apps/publishing/mix.exs @@ -21,7 +21,7 @@ defmodule Publishing.MixProject do def application do [ mod: {Publishing.Application, []}, - extra_applications: [:ssl] + extra_applications: [:ssl, :hackney] ] end From 7ab0a1f9e931711b783a5da0f9c4df12e843b8bb Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 21:45:33 -0300 Subject: [PATCH 21/95] implement get_title/1 --- .../lib/publishing/integration/github.ex | 30 ++++++++++++------- apps/publishing/mix.exs | 3 +- mix.lock | 2 ++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index e119dc0..8fcecb6 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -3,29 +3,39 @@ defmodule Publishing.Integration.Github do implement a integration interface """ - def to_raw(url) do - [username, repository, "blob" | tail] = decompose(url) - resource = Enum.join(tail, "/") - - "https://raw.githubusercontent.com/#{username}/#{repository}/#{resource}" - end - def get_username(url) do [username | _] = decompose(url) username end def get_title(body) do - body + {:ok, ast, _} = EarmarkParser.as_ast(body) + + default = {"h1", [], "Untitled", %{}} + + {"h1", _, title, _} = Enum.find(ast, default, fn {tag, _, _, _} -> tag == "h1" end) + + title end - def get_body(raw_url) do - {:ok, 200, _, ref} = :hackney.get(raw_url) + def get_body(url) do + {:ok, 200, _, ref} = + url + |> to_raw() + |> :hackney.get() + {:ok, body} = :hackney.body(ref) body end + defp to_raw(url) do + [username, repository, "blob" | tail] = decompose(url) + resource = Enum.join(tail, "/") + + "https://raw.githubusercontent.com/#{username}/#{repository}/#{resource}" + end + defp decompose(url) do [_, path] = String.split(url, "github.com/") String.split(path, "/") diff --git a/apps/publishing/mix.exs b/apps/publishing/mix.exs index f59e5f9..44ef55c 100644 --- a/apps/publishing/mix.exs +++ b/apps/publishing/mix.exs @@ -32,7 +32,8 @@ defmodule Publishing.MixProject do [ {:ecto_sql, "~> 3.4"}, {:postgrex, ">= 0.0.0"}, - {:ex_machina, "~> 2.7.0", only: :test} + {:ex_machina, "~> 2.7.0", only: :test}, + {:earmark, "~> 1.4.5"} ] end diff --git a/mix.lock b/mix.lock index 5130e30..b2a988b 100644 --- a/mix.lock +++ b/mix.lock @@ -9,6 +9,8 @@ "credo": {:hex, :credo, "1.5.5", "e8f422026f553bc3bebb81c8e8bf1932f498ca03339856c7fec63d3faac8424b", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "dd8623ab7091956a855dc9f3062486add9c52d310dfd62748779c4315d8247de"}, "db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, + "earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, "ecto": {:hex, :ecto, "3.6.1", "7bb317e3fd0179ad725069fd0fe8a28ebe48fec6282e964ea502e4deccb0bd0f", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbb3294a990447b19f0725488a749f8cf806374e0d9d0dffc45d61e7aeaf6553"}, "ecto_sql": {:hex, :ecto_sql, "3.6.1", "8774dc3fc0ff7b6be510858b99883640f990c0736b8ab54588f9a0c91807f909", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "66f35c3f2d5978b6bffebd1e6351ab8c9d6b68650d62abd1ab8d149de40e0779"}, "ex_machina": {:hex, :ex_machina, "2.7.0", "b792cc3127fd0680fecdb6299235b4727a4944a09ff0fa904cc639272cd92dc7", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "419aa7a39bde11894c87a615c4ecaa52d8f107bbdd81d810465186f783245bf8"}, From 58fdccf5ffa8fa736d9b372c56b2d2851dc80bd9 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Wed, 21 Apr 2021 22:40:06 -0300 Subject: [PATCH 22/95] treat title corner cases --- .../lib/publishing/integration/github.ex | 34 ++++++++++++------- apps/publishing/mix.exs | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index 8fcecb6..de37244 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -1,24 +1,34 @@ defmodule Publishing.Integration.Github do @moduledoc """ - implement a integration interface + Integrates with github markdown resources. """ - def get_username(url) do - [username | _] = decompose(url) - username - end - - def get_title(body) do - {:ok, ast, _} = EarmarkParser.as_ast(body) + @doc """ + Returns the markdown's main title. It defaults to "Untitled". - default = {"h1", [], "Untitled", %{}} + Examples: + iex> title("# Hello World!\\nLorem ipsum...") + "Hello World!" - {"h1", _, title, _} = Enum.find(ast, default, fn {tag, _, _, _} -> tag == "h1" end) + iex> title("Lorem ipsum dolor sit amet...") + "Untitled" + """ + @spec title(String.t()) :: String.t() + def title(content) do + with {:ok, ast, _} <- EarmarkParser.as_ast(content), + [{"h1", _, [title], _} | _tail] <- ast do + title + else + _ -> "Untitled" + end + end - title + def author(url) do + [username | _] = decompose(url) + username end - def get_body(url) do + def get_content(url) do {:ok, 200, _, ref} = url |> to_raw() diff --git a/apps/publishing/mix.exs b/apps/publishing/mix.exs index 44ef55c..688d617 100644 --- a/apps/publishing/mix.exs +++ b/apps/publishing/mix.exs @@ -33,7 +33,7 @@ defmodule Publishing.MixProject do {:ecto_sql, "~> 3.4"}, {:postgrex, ">= 0.0.0"}, {:ex_machina, "~> 2.7.0", only: :test}, - {:earmark, "~> 1.4.5"} + {:earmark_parser, "~> 1.4.3"} ] end From 2f855210dd835c9551cb200f8c14f19f309bd145 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 09:34:25 -0300 Subject: [PATCH 23/95] improve validate/1 --- .../lib/publishing/integration/github.ex | 19 +++++++++++++++++-- apps/publishing/mix.exs | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index de37244..ba8d694 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -1,6 +1,6 @@ defmodule Publishing.Integration.Github do @moduledoc """ - Integrates with github markdown resources. + Integrates with github. """ @doc """ @@ -39,7 +39,22 @@ defmodule Publishing.Integration.Github do body end - defp to_raw(url) do + def validate(url) do + case URI.parse(url) do + %URI{scheme: scheme} when scheme not in ["http", "https"] -> + {:error, :scheme} + + %URI{host: host} when host != "github.com" -> + {:error, :host} + + %URI{path: path} -> + if MIME.from_path(path) == "text/markdown", + do: {:ok, url}, + else: {:error, :extension} + end + end + + def to_raw(url) do [username, repository, "blob" | tail] = decompose(url) resource = Enum.join(tail, "/") diff --git a/apps/publishing/mix.exs b/apps/publishing/mix.exs index 688d617..79b200b 100644 --- a/apps/publishing/mix.exs +++ b/apps/publishing/mix.exs @@ -21,7 +21,7 @@ defmodule Publishing.MixProject do def application do [ mod: {Publishing.Application, []}, - extra_applications: [:ssl, :hackney] + extra_applications: [:ssl, :hackney, :mime] ] end From a4924bbe6acf2ca86fee38ee8b3e2d960e0c9ad6 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 10:03:47 -0300 Subject: [PATCH 24/95] fix decompose/1 --- apps/publishing/lib/publishing/integration/github.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index ba8d694..ef7f77d 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -55,14 +55,14 @@ defmodule Publishing.Integration.Github do end def to_raw(url) do - [username, repository, "blob" | tail] = decompose(url) + [username, repository, _blob | tail] = decompose(url) resource = Enum.join(tail, "/") "https://raw.githubusercontent.com/#{username}/#{repository}/#{resource}" end - defp decompose(url) do - [_, path] = String.split(url, "github.com/") + def decompose(url) do + %URI{path: <<"/", path::binary>>} = URI.parse(url) String.split(path, "/") end end From 8b5ccb5fce5712637c92a6d01608340975ed0a0c Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 12:43:11 -0300 Subject: [PATCH 25/95] implement all public functions --- .../lib/publishing/integration/github.ex | 57 +++++++++++-------- .../publishing/integration/github_test.exs | 25 ++++++++ 2 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 apps/publishing/test/publishing/integration/github_test.exs diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index ef7f77d..f86c521 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -3,6 +3,10 @@ defmodule Publishing.Integration.Github do Integrates with github. """ + defstruct [:username, :repository, :resource] + + @type t :: %__MODULE__{username: binary, repository: binary, resource: binary} + @doc """ Returns the markdown's main title. It defaults to "Untitled". @@ -11,7 +15,7 @@ defmodule Publishing.Integration.Github do "Hello World!" iex> title("Lorem ipsum dolor sit amet...") - "Untitled" + nil """ @spec title(String.t()) :: String.t() def title(content) do @@ -19,26 +23,10 @@ defmodule Publishing.Integration.Github do [{"h1", _, [title], _} | _tail] <- ast do title else - _ -> "Untitled" + _ -> nil end end - def author(url) do - [username | _] = decompose(url) - username - end - - def get_content(url) do - {:ok, 200, _, ref} = - url - |> to_raw() - |> :hackney.get() - - {:ok, body} = :hackney.body(ref) - - body - end - def validate(url) do case URI.parse(url) do %URI{scheme: scheme} when scheme not in ["http", "https"] -> @@ -54,15 +42,34 @@ defmodule Publishing.Integration.Github do end end - def to_raw(url) do - [username, repository, _blob | tail] = decompose(url) - resource = Enum.join(tail, "/") + def get_username(url), do: decompose(url).username - "https://raw.githubusercontent.com/#{username}/#{repository}/#{resource}" + def get_content(url) do + raw = + url + |> decompose() + |> raw_url() + + case :hackney.get(raw) do + {:ok, 200, _, ref} -> + :hackney.body(ref) + + {:ok, status_code, _, _} -> + {:error, status_code} + end end - def decompose(url) do - %URI{path: <<"/", path::binary>>} = URI.parse(url) - String.split(path, "/") + defp raw_url(%__MODULE__{} = gh) do + "https://raw.githubusercontent.com/#{gh.username}/#{gh.repository}/#{gh.resource}" + end + + defp decompose(url) do + with %URI{path: <>} <- URI.parse(url), + ["", username, repository, "blob" | tail] <- String.split(path, "/"), + resource <- Enum.join(tail, "/") do + %__MODULE__{username: username, repository: repository, resource: resource} + else + _ -> %__MODULE__{} + end end end diff --git a/apps/publishing/test/publishing/integration/github_test.exs b/apps/publishing/test/publishing/integration/github_test.exs new file mode 100644 index 0000000..90ea823 --- /dev/null +++ b/apps/publishing/test/publishing/integration/github_test.exs @@ -0,0 +1,25 @@ +defmodule Publishing.Integration.GithubTest do + use ExUnit.Case, async: true + + alias Publishing.Integration.Github + + test "validate/1 on url with invalid scheme" do + assert {:error, :scheme} = Github.validate("") + assert {:error, :scheme} = Github.validate("test.com/") + end + + test "validate/1 on url with invalid host" do + assert {:error, :host} = Github.validate("https://test.com") + assert {:error, :host} = Github.validate("http://test.com") + end + + test "validate/1 on url with invalid resource extension" do + assert {:error, :extension} = Github.validate("https://github.com/test.txt") + assert {:error, :extension} = Github.validate("http://github.com/test.js") + end + + test "validate/1 on valid url" do + assert {:ok, _url} = Github.validate("https://github.com/test.md") + assert {:ok, _url} = Github.validate("http://github.com/test.md") + end +end From 49f99b80ce371d67bb24f99c1d77e63ebac75803 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 12:57:23 -0300 Subject: [PATCH 26/95] add docstests --- .../lib/publishing/integration/github.ex | 23 ++++++++++++++++--- .../publishing/integration/github_test.exs | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index f86c521..f6212dd 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -8,14 +8,14 @@ defmodule Publishing.Integration.Github do @type t :: %__MODULE__{username: binary, repository: binary, resource: binary} @doc """ - Returns the markdown's main title. It defaults to "Untitled". + Returns the markdown's main title if there is one. Examples: iex> title("# Hello World!\\nLorem ipsum...") "Hello World!" iex> title("Lorem ipsum dolor sit amet...") - nil + "" """ @spec title(String.t()) :: String.t() def title(content) do @@ -23,10 +23,27 @@ defmodule Publishing.Integration.Github do [{"h1", _, [title], _} | _tail] <- ast do title else - _ -> nil + _ -> "" end end + @doc """ + Validates the `url` as a github markdown. + + Examples: + iex> validate("https://github.com/felipelincoln/branchpage/blob/main/README.md") + {:ok, "https://github.com/felipelincoln/branchpage/blob/main/README.md"} + + iex> validate("github.com/felipelincoln/branchpage/blob/main/README.md") + {:error, :scheme} + + iex> validate("https://invalid.com/felipelincoln/branchpage/blob/main/README.md") + {:error, :host} + + iex> validate("https://github.com/felipelincoln/branchpage/blob/main/README.txt") + {:error, :extension} + """ + @spec validate(String.t()) :: {:ok, String.t()} | {:error, atom} def validate(url) do case URI.parse(url) do %URI{scheme: scheme} when scheme not in ["http", "https"] -> diff --git a/apps/publishing/test/publishing/integration/github_test.exs b/apps/publishing/test/publishing/integration/github_test.exs index 90ea823..e998b4c 100644 --- a/apps/publishing/test/publishing/integration/github_test.exs +++ b/apps/publishing/test/publishing/integration/github_test.exs @@ -1,5 +1,6 @@ defmodule Publishing.Integration.GithubTest do use ExUnit.Case, async: true + doctest Publishing.Integration.Github, import: true alias Publishing.Integration.Github From 781e239feaf9b7eaaa410390efeb2672e2dcaa35 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 13:05:33 -0300 Subject: [PATCH 27/95] add documentation --- .../lib/publishing/integration/github.ex | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index f6212dd..27ab7ec 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -11,19 +11,19 @@ defmodule Publishing.Integration.Github do Returns the markdown's main title if there is one. Examples: - iex> title("# Hello World!\\nLorem ipsum...") + iex> content_title("# Hello World!\\nLorem ipsum...") "Hello World!" - iex> title("Lorem ipsum dolor sit amet...") - "" + iex> content_title("Lorem ipsum dolor sit amet...") + nil """ - @spec title(String.t()) :: String.t() - def title(content) do + @spec content_title(String.t()) :: String.t() | nil + def content_title(content) do with {:ok, ast, _} <- EarmarkParser.as_ast(content), [{"h1", _, [title], _} | _tail] <- ast do title else - _ -> "" + _ -> nil end end @@ -59,8 +59,23 @@ defmodule Publishing.Integration.Github do end end + @doc """ + Returns the GitHub username from the `url`. + + Examples: + iex> get_username("https://github.com/felipelincoln/branchpage/blob/main/README.md") + "felipelincoln" + + iex> get_username("https://github.com/") + nil + """ + @spec get_username(String.t()) :: String.t() | nil def get_username(url), do: decompose(url).username + @doc """ + Retrieve the raw content of a resource's `url` from github. + """ + @spec get_content(String.t()) :: {:ok, Stream.t()} | {:error, integer} def get_content(url) do raw = url From 1bc8cb43af22fea85dc98926a9de652f67d2cb19 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 13:22:30 -0300 Subject: [PATCH 28/95] keep only doctests --- .gitignore | 1 + .../lib/publishing/integration/github.ex | 48 +++++++++---------- apps/publishing/mix.exs | 4 +- .../publishing/integration/github_test.exs | 22 --------- 4 files changed, 26 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index a00b25f..b168a32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /_build/ /deps/ +/cover/ diff --git a/apps/publishing/lib/publishing/integration/github.ex b/apps/publishing/lib/publishing/integration/github.ex index 27ab7ec..9a42f80 100644 --- a/apps/publishing/lib/publishing/integration/github.ex +++ b/apps/publishing/lib/publishing/integration/github.ex @@ -5,28 +5,6 @@ defmodule Publishing.Integration.Github do defstruct [:username, :repository, :resource] - @type t :: %__MODULE__{username: binary, repository: binary, resource: binary} - - @doc """ - Returns the markdown's main title if there is one. - - Examples: - iex> content_title("# Hello World!\\nLorem ipsum...") - "Hello World!" - - iex> content_title("Lorem ipsum dolor sit amet...") - nil - """ - @spec content_title(String.t()) :: String.t() | nil - def content_title(content) do - with {:ok, ast, _} <- EarmarkParser.as_ast(content), - [{"h1", _, [title], _} | _tail] <- ast do - title - else - _ -> nil - end - end - @doc """ Validates the `url` as a github markdown. @@ -44,7 +22,7 @@ defmodule Publishing.Integration.Github do {:error, :extension} """ @spec validate(String.t()) :: {:ok, String.t()} | {:error, atom} - def validate(url) do + def validate(url) when is_binary(url) do case URI.parse(url) do %URI{scheme: scheme} when scheme not in ["http", "https"] -> {:error, :scheme} @@ -59,6 +37,26 @@ defmodule Publishing.Integration.Github do end end + @doc """ + Returns the markdown's main title if there is one. + + Examples: + iex> content_title("# Hello World!\\nLorem ipsum...") + "Hello World!" + + iex> content_title("Lorem ipsum dolor sit amet...") + nil + """ + @spec content_title(String.t()) :: String.t() | nil + def content_title(content) when is_binary(content) do + with {:ok, ast, _} <- EarmarkParser.as_ast(content), + [{"h1", _, [title], _} | _tail] <- ast do + title + else + _ -> nil + end + end + @doc """ Returns the GitHub username from the `url`. @@ -70,13 +68,13 @@ defmodule Publishing.Integration.Github do nil """ @spec get_username(String.t()) :: String.t() | nil - def get_username(url), do: decompose(url).username + def get_username(url) when is_binary(url), do: decompose(url).username @doc """ Retrieve the raw content of a resource's `url` from github. """ @spec get_content(String.t()) :: {:ok, Stream.t()} | {:error, integer} - def get_content(url) do + def get_content(url) when is_binary(url) do raw = url |> decompose() diff --git a/apps/publishing/mix.exs b/apps/publishing/mix.exs index 79b200b..4ed8a34 100644 --- a/apps/publishing/mix.exs +++ b/apps/publishing/mix.exs @@ -32,8 +32,8 @@ defmodule Publishing.MixProject do [ {:ecto_sql, "~> 3.4"}, {:postgrex, ">= 0.0.0"}, - {:ex_machina, "~> 2.7.0", only: :test}, - {:earmark_parser, "~> 1.4.3"} + {:earmark_parser, "~> 1.4.3"}, + {:ex_machina, "~> 2.7.0", only: :test} ] end diff --git a/apps/publishing/test/publishing/integration/github_test.exs b/apps/publishing/test/publishing/integration/github_test.exs index e998b4c..f8e8e82 100644 --- a/apps/publishing/test/publishing/integration/github_test.exs +++ b/apps/publishing/test/publishing/integration/github_test.exs @@ -1,26 +1,4 @@ defmodule Publishing.Integration.GithubTest do use ExUnit.Case, async: true doctest Publishing.Integration.Github, import: true - - alias Publishing.Integration.Github - - test "validate/1 on url with invalid scheme" do - assert {:error, :scheme} = Github.validate("") - assert {:error, :scheme} = Github.validate("test.com/") - end - - test "validate/1 on url with invalid host" do - assert {:error, :host} = Github.validate("https://test.com") - assert {:error, :host} = Github.validate("http://test.com") - end - - test "validate/1 on url with invalid resource extension" do - assert {:error, :extension} = Github.validate("https://github.com/test.txt") - assert {:error, :extension} = Github.validate("http://github.com/test.js") - end - - test "validate/1 on valid url" do - assert {:ok, _url} = Github.validate("https://github.com/test.md") - assert {:ok, _url} = Github.validate("http://github.com/test.md") - end end From ca5b9f035af6987ccab5974222666c8ce8ad9281 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 13:29:21 -0300 Subject: [PATCH 29/95] remove earmark --- mix.lock | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mix.lock b/mix.lock index b2a988b..a3be885 100644 --- a/mix.lock +++ b/mix.lock @@ -9,7 +9,6 @@ "credo": {:hex, :credo, "1.5.5", "e8f422026f553bc3bebb81c8e8bf1932f498ca03339856c7fec63d3faac8424b", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "dd8623ab7091956a855dc9f3062486add9c52d310dfd62748779c4315d8247de"}, "db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, - "earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"}, "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, "ecto": {:hex, :ecto, "3.6.1", "7bb317e3fd0179ad725069fd0fe8a28ebe48fec6282e964ea502e4deccb0bd0f", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbb3294a990447b19f0725488a749f8cf806374e0d9d0dffc45d61e7aeaf6553"}, "ecto_sql": {:hex, :ecto_sql, "3.6.1", "8774dc3fc0ff7b6be510858b99883640f990c0736b8ab54588f9a0c91807f909", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "66f35c3f2d5978b6bffebd1e6351ab8c9d6b68650d62abd1ab8d149de40e0779"}, @@ -17,26 +16,26 @@ "excoveralls": {:hex, :excoveralls, "0.13.3", "edc5f69218f84c2bf61b3609a22ddf1cec0fbf7d1ba79e59f4c16d42ea4347ed", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cc26f48d2f68666380b83d8aafda0fffc65dafcc8d8650358e0b61f6a99b1154"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "gettext": {:hex, :gettext, "0.18.2", "7df3ea191bb56c0309c00a783334b288d08a879f53a7014341284635850a6e55", [:mix], [], "hexpm", "f9f537b13d4fdd30f3039d33cb80144c3aa1f8d9698e47d7bcbcc8df93b1f5c5"}, - "hackney": {:hex, :hackney, "1.17.0", "717ea195fd2f898d9fe9f1ce0afcc2621a41ecfe137fae57e7fe6e9484b9aa99", [:rebar3], [{:certifi, "~>2.5", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "64c22225f1ea8855f584720c0e5b3cd14095703af1c9fbc845ba042811dc671c"}, + "hackney": {:hex, :hackney, "1.17.4", "99da4674592504d3fb0cfef0db84c3ba02b4508bae2dff8c0108baa0d6e0977c", [:rebar3], [{:certifi, "~>2.6.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "de16ff4996556c8548d512f4dbe22dd58a587bf3332e7fd362430a7ef3986b16"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "1.5.0", "203ef35ef3389aae6d361918bf3f952fa17a09e8e43b5aa592b93eba05d0fb8d", [:mix], [], "hexpm", "55a94c0f552249fc1a3dd9cd2d3ab9de9d3c89b559c2bd01121f824834f24746"}, + "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "parse_trans": {:hex, :parse_trans, "3.4.0", "bb87ac362a03ca674ebb7d9d498f45c03256aded7214c9101f7035ef44b798c7", [:rebar3], [], "hexpm", "f99e368830bea44552224e37e04943a54874f08b8590485de8d13832b63a2dc3"}, + "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, "phoenix": {:hex, :phoenix, "1.5.8", "71cfa7a9bb9a37af4df98939790642f210e35f696b935ca6d9d9c55a884621a4", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "35ded0a32f4836168c7ab6c33b88822eccd201bcd9492125a9bea4c54332d955"}, "phoenix_html": {:hex, :phoenix_html, "2.14.3", "51f720d0d543e4e157ff06b65de38e13303d5778a7919bcc696599e5934271b8", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "efd697a7fff35a13eeeb6b43db884705cba353a1a41d127d118fda5f90c8e80f"}, - "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.0", "f35f61c3f959c9a01b36defaa1f0624edd55b87e236b606664a556d6f72fd2e7", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "02c1007ae393f2b76ec61c1a869b1e617179877984678babde131d716f95b582"}, - "phoenix_live_view": {:hex, :phoenix_live_view, "0.15.4", "86908dc9603cc81c07e84725ee42349b5325cb250c9c20d3533856ff18dbb7dc", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 0.5", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "35d78f3c35fe10a995dca5f4ab50165b7a90cbe02e23de245381558f821e9462"}, + "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.1", "9eba6ad16bd80c45f338b2059c7b255ce30784d76f4181304e7b78640e5a7513", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "f3ae26b5abb85a1cb2bc8bb199e29fbcefb34259e469b31fe0c6323f2175a5ef"}, + "phoenix_live_view": {:hex, :phoenix_live_view, "0.15.5", "153f15022ff03162201cfbd3de73115f3a6e868bc8a3c07b86a8e984de6a57e2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 0.5", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "00c80cf27365bdeb44c694b1dc8cf950b4b26141307df340d39a9be47d8dc1ef"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"}, "plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"}, - "plug_cowboy": {:hex, :plug_cowboy, "2.4.1", "779ba386c0915027f22e14a48919a9545714f849505fa15af2631a0d298abf0f", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d72113b6dff7b37a7d9b2a5b68892808e3a9a752f2bf7e503240945385b70507"}, + "plug_cowboy": {:hex, :plug_cowboy, "2.5.0", "51c998f788c4e68fc9f947a5eba8c215fbb1d63a520f7604134cab0270ea6513", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5b2c8925a5e2587446f33810a58c01e66b3c345652eeec809b76ba007acde71a"}, "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "postgrex": {:hex, :postgrex, "0.15.8", "f5e782bbe5e8fa178d5e3cd1999c857dc48eda95f0a4d7f7bd92a50e84a0d491", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "698fbfacea34c4cf22c8281abeb5cf68d99628d541874f085520ab3b53d356fe"}, "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, - "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"}, - "timex": {:hex, :timex, "3.6.4", "137a49450b8d1f80efff82de4b78ab9ad2e367f06346825704310599733f338b", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "f6fce3f07ab67f525043af5b1f68ed5fa12a41b9dab95a9a98bb6acfb30ecadc"}, + "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, + "timex": {:hex, :timex, "3.7.5", "3eca56e23bfa4e0848f0b0a29a92fa20af251a975116c6d504966e8a90516dfd", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "a15608dca680f2ef663d71c95842c67f0af08a0f3b1d00e17bbd22872e2874e4"}, "tzdata": {:hex, :tzdata, "1.1.0", "72f5babaa9390d0f131465c8702fa76da0919e37ba32baa90d93c583301a8359", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "18f453739b48d3dc5bcf0e8906d2dc112bb40baafe2c707596d89f3c8dd14034"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, } From 31294ee2d3a3e4117ac62ccf17cd3f02887018d9 Mon Sep 17 00:00:00 2001 From: Felipe LIncoln Date: Sat, 24 Apr 2021 16:32:19 -0300 Subject: [PATCH 30/95] reset new article layout --- apps/web/assets/css/base.css | 4 +++ apps/web/lib/web/live/new_live.ex | 27 +++++++------------ apps/web/lib/web/live/new_live.html.leex | 15 +++++------ .../lib/web/templates/layout/base.html.eex | 18 ++++++------- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/apps/web/assets/css/base.css b/apps/web/assets/css/base.css index ebf157f..314e297 100644 --- a/apps/web/assets/css/base.css +++ b/apps/web/assets/css/base.css @@ -34,4 +34,8 @@ .container { @apply max-w-screen-sm sm:mx-auto box-content px-mb sm:px-sc } + + .input { + @apply w-full border-b border-gray-300 focus:border-gray-800 focus:outline-none p-0 sm:p-1 + } } diff --git a/apps/web/lib/web/live/new_live.ex b/apps/web/lib/web/live/new_live.ex index f2c1f36..1902c9c 100644 --- a/apps/web/lib/web/live/new_live.ex +++ b/apps/web/lib/web/live/new_live.ex @@ -4,6 +4,8 @@ defmodule Web.NewLive do use Phoenix.LiveView import Phoenix.HTML, only: [raw: 1] + alias Publishing.Integration.Github + @meta %{ title: "branchpage title", description: "some description", @@ -12,26 +14,17 @@ defmodule Web.NewLive do @impl true def mount(_params, _session, socket) do - name = "Felipe Lincoln" - date = Timex.today() |> Timex.format!("%b %e", :strftime) - title = "Lorem ipsum dolor sit amet. Consectetur adipiscing elit." - - body_html = """ -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare eu mi eget lacinia. Maecenas tincidunt risus vel mi vehicula, sit amet varius ligula porta. Pellentesque id ex viverra, pellentesque neque eget, aliquet magna. Sed viverra egestas pulvinar. Mauris luctus egestas ante, et facilisis ligula vulputate sit amet. Nunc ut ipsum velit. Vivamus finibus scelerisque nibh, ac dapibus mauris finibus ut. Sed consequat nibh at pharetra ornare.

-

Vivamus nunc dui, pellentesque quis nulla vel, laoreet facilisis sem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis libero nibh, varius ac lacus nec, gravida facilisis mi. Mauris urna libero, laoreet sit amet gravida ac, pharetra eu magna. Morbi iaculis egestas interdum. Donec a mi sit amet ipsum consequat malesuada. Nam magna erat, tempus eget tortor nec, fringilla tincidunt odio. Mauris finibus eget mi vitae aliquet. Maecenas a est vitae urna vestibulum vulputate id at urna. Donec id feugiat orci, vel tincidunt nunc. Quisque dapibus libero porta fringilla consectetur.

-

Aenean nunc augue, bibendum vitae aliquet sed, rhoncus at mauris. Morbi eleifend ultrices commodo. Donec bibendum justo a ultricies vehicula. Sed iaculis enim et nisl auctor, nec ultricies tortor suscipit. Phasellus non convallis dui. Nullam scelerisque quis tortor nec sollicitudin. Pellentesque tristique pretium nunc a tincidunt. Fusce sodales nunc sapien, at scelerisque diam fermentum sit amet. Fusce eu arcu magna. Curabitur ullamcorper elementum nisi vitae efficitur. Curabitur in venenatis magna. Fusce suscipit ex lectus, at iaculis est efficitur nec. Cras vitae dolor placerat, placerat sapien sit amet, tempor magna. Fusce sagittis leo sit amet magna venenatis fringilla. Phasellus euismod purus ex, quis egestas odio elementum sed.

-

Suspendisse semper diam sit amet enim placerat, nec suscipit dolor efficitur. Suspendisse nec erat vitae felis dignissim rhoncus porta sit amet ipsum. Quisque consequat leo nec est hendrerit aliquet. Donec accumsan sem ut sapien placerat facilisis. Sed pharetra efficitur mi, quis condimentum ipsum egestas quis. Duis ultrices, nibh ut placerat tincidunt, elit dolor tincidunt orci, id ornare metus urna accumsan ex. Duis quis ullamcorper ex, blandit sagittis metus. Quisque urna mi, condimentum quis tortor non, maximus maximus felis. Suspendisse accumsan augue purus, ut pharetra nunc congue at.

-

Fusce sit amet euismod arcu. In hac habitasse platea dictumst. Morbi non ullamcorper turpis. Curabitur rutrum venenatis nisl, sit amet pharetra erat rhoncus non. Suspendisse et arcu vitae eros bibendum porta convallis vel dolor. Maecenas eget sodales ex. Vestibulum feugiat purus vitae risus ultrices, sed vehicula justo posuere. Nulla commodo, elit sed tincidunt facilisis, nunc nunc posuere ligula, bibendum auctor mi ante et augue. Pellentesque finibus facilisis ex, eget volutpat turpis aliquet ac. Nullam lectus erat, finibus sed purus eu, maximus commodo enim. Curabitur tincidunt justo nec justo laoreet sodales vitae a nibh.

- """ - socket = socket - |> assign(@meta) - |> assign(:name, name) - |> assign(:date, date) - |> assign(:title, title) - |> assign(:body_html, body_html) + |> assign(:meta, @meta) {:ok, socket} end + + @impl true + def handle_event("preview", %{"url" => url}, socket) do + IO.puts("In development") + + {:noreply, socket} + end end diff --git a/apps/web/lib/web/live/new_live.html.leex b/apps/web/lib/web/live/new_live.html.leex index 3a790eb..d116cee 100644 --- a/apps/web/lib/web/live/new_live.html.leex +++ b/apps/web/lib/web/live/new_live.html.leex @@ -1,13 +1,10 @@