diff --git a/config/config.exs b/config/config.exs index 136603b..3178df9 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,6 +1,6 @@ # This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. -use Mix.Config +import Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this diff --git a/mix.exs b/mix.exs index b111563..d8c0167 100644 --- a/mix.exs +++ b/mix.exs @@ -48,7 +48,7 @@ defmodule ScrivenerHtml.Mixfile do defp deps do [ {:scrivener, "~> 1.2 or ~> 2.0"}, - {:phoenix_html, "~> 2.2"}, + {:phoenix_html, "~> 2.2 or ~> 3.0"}, {:phoenix, "~> 1.0", optional: true}, {:plug, "~> 1.1"}, {:ex_doc, "~> 0.19", only: :dev}, diff --git a/mix.lock b/mix.lock index 8d56849..3772d87 100644 --- a/mix.lock +++ b/mix.lock @@ -6,15 +6,16 @@ "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5fbc8e549aa9afeea2847c0769e3970537ed302f93a23ac612602e805d9d1e7f"}, "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "adf0218695e22caeda2820eaba703fa46c91820d53813a2223413da3ef4ba515"}, "meck": {:hex, :meck, "0.8.4", "59ca1cd971372aa223138efcf9b29475bde299e1953046a0c727184790ab1520", [:rebar, :make], []}, - "mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm", "5e839994289d60326aa86020c4fbd9c6938af188ecddab2579f07b66cd665328"}, + "mime": {:hex, :mime, "2.0.2", "0b9e1a4c840eafb68d820b0e2158ef5c49385d17fb36855ac6e7e087d4b1dcc5", [:mix], [], "hexpm", "e6a3f76b4c277739e36c2e21a2c640778ba4c3846189d5ab19f97f126df5f9b7"}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm", "5c040b8469c1ff1b10093d3186e2e10dbe483cd73d79ec017993fb3985b8a9b3"}, "pavlov": {:git, "https://github.com/sproutapp/pavlov.git", "7f3c0d7c75c8c2875e21b495511a291194bfc85a", []}, "phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "22da8f659cf13d3ba73b767f66b8c389113ddf0ef7b94225cc84e94b85eac90e"}, - "phoenix_html": {:hex, :phoenix_html, "2.9.3", "1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "f090e3a75de4efd72ae2b9b016909fe673512ef04e6b72d7bf039031a64d4a52"}, + "phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm", "a3d890aaa3156d51056179dcaaadaf32b844f71656bb27c58756f2b97875c36c"}, - "plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm", "daa5fee4209c12c3c48b05a96cf88c320b627c9575f987554dcdc1fdcdf2c15e"}, - "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"}, + "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.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.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"}, + "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], [], "hexpm"}, "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}, "scrivener": {:hex, :scrivener, "2.2.1", "5a84cdfc042e3c318a03f965d8197b8294676a8fff7c4a29e482a90c467ebf19", [:mix], [], "hexpm", "a9cc85e580925b13cdb5265cead4594ddb3cc7fb23eea8843c219827165f6c4f"}, + "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, } diff --git a/test/scrivener/html/seo_test.exs b/test/scrivener/html/seo_test.exs index b5cbad7..bc2e56f 100644 --- a/test/scrivener/html/seo_test.exs +++ b/test/scrivener/html/seo_test.exs @@ -33,7 +33,7 @@ defmodule Scrivener.HTML.SEOTest do [ 60, "link", - [[32, "href", 61, 34, "?page=2", 34], [32, "rel", 61, 34, "next", 34]], + [32, "href", 61, 34, "?page=2", 34, 32, "rel", 61, 34, "next", 34], 62, [], 60, @@ -49,7 +49,7 @@ defmodule Scrivener.HTML.SEOTest do [ 60, "link", - [[32, "href", 61, 34, "?page=9", 34], [32, "rel", 61, 34, "prev", 34]], + [32, "href", 61, 34, "?page=9", 34, 32, "rel", 61, 34, "prev", 34], 62, [], 60, @@ -66,7 +66,7 @@ defmodule Scrivener.HTML.SEOTest do [ 60, "link", - [[32, "href", 61, 34, "?page=4", 34], [32, "rel", 61, 34, "prev", 34]], + [32, "href", 61, 34, "?page=4", 34, 32, "rel", 61, 34, "prev", 34], 62, [], 60, @@ -78,7 +78,7 @@ defmodule Scrivener.HTML.SEOTest do [ 60, "link", - [[32, "href", 61, 34, "?page=6", 34], [32, "rel", 61, 34, "next", 34]], + [32, "href", 61, 34, "?page=6", 34, 32, "rel", 61, 34, "next", 34], 62, [], 60, diff --git a/test/scrivener/html_test.exs b/test/scrivener/html_test.exs index 480c910..0f367b5 100644 --- a/test/scrivener/html_test.exs +++ b/test/scrivener/html_test.exs @@ -331,15 +331,15 @@ defmodule Scrivener.HTMLTest do [ 60, "ul", - [[32, "class", 61, 34, "pagination", 34]], + [" class=\"", "pagination", 34], 62, [ [ 60, "li", - [[32, "class", 61, 34, "active", 34]], + [" class=\"", "active", 34], 62, - [60, "a", [[32, "class", 61, 34, "", 34]], 62, "1", 60, 47, "a", 62], + [60, "a", [" class=\"", [], 34], 62, "1", 60, 47, "a", 62], 60, 47, "li", @@ -394,9 +394,9 @@ defmodule Scrivener.HTMLTest do [ 60, "div", - [[32, "class", 61, 34, "ui pagination menu", 34]], + [" class=\"", "ui pagination menu", 34], 62, - [[60, "a", [[32, "class", 61, 34, "active item", 34]], 62, "1", 60, 47, "a", 62]], + [[60, "a", [" class=\"", "active item", 34], 62, "1", 60, 47, "a", 62]], 60, 47, "div", @@ -416,62 +416,96 @@ defmodule Scrivener.HTMLTest do end test "renders Foundation for Sites 6.x styling" do - assert {:safe, + expected_content = { + :safe, + [ + 60, + "ul", + [ + " class=\"", + "pagination", + 34, + 32, + "role", + 61, + 34, + "pagination", + 34 + ], + 62, + [ + [ + 60, + "li", + [" class=\"", "current", 34], + 62, [ 60, - "ul", - [[32, "class", 61, 34, "pagination", 34], [32, "role", 61, 34, "pagination", 34]], + "span", + [" class=\"", [], 34], 62, - [ - [ - 60, - "li", - [[32, "class", 61, 34, "current", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "1", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "2", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [ - 60, - "span", - [[32, "class", 61, 34, "", 34]], - 62, - ">>", - 60, - 47, - "span", - 62 - ], - 60, - 47, - "li", - 62 - ] - ], + "1", 60, 47, - "ul", + "span", 62 - ]} = + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "2", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + [[[] | ">"] | ">"], + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ] + ], + 60, + 47, + "ul", + 62 + ] + } + + assert expected_content == HTML.pagination_links( build_conn(), %Page{ @@ -486,171 +520,285 @@ defmodule Scrivener.HTMLTest do end test "renders Foundation for Sites 6.x styling with ellipsis" do - assert {:safe, + expected_result = { + :safe, + [ + 60, + "ul", + [ + " class=\"", + "pagination", + 34, + 32, + "role", + 61, + 34, + "pagination", + 34 + ], + 62, + [ + [ + 60, + "li", + [" class=\"", [], 34], + 62, [ 60, - "ul", - [[32, "class", 61, 34, "pagination", 34], [32, "role", 61, 34, "pagination", 34]], + "span", + [" class=\"", [], 34], 62, - [ - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [ - 60, - "span", - [[32, "class", 61, 34, "", 34]], - 62, - "<<", - 60, - 47, - "span", - 62 - ], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "1", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "2", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "current", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "3", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "4", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "5", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "6", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "7", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "8", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "ellipsis", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [60, "span", [[32, "class", 61, 34, "", 34]], 62, "10", 60, 47, "span", 62], - 60, - 47, - "li", - 62 - ], - [ - 60, - "li", - [[32, "class", 61, 34, "", 34]], - 62, - [ - 60, - "span", - [[32, "class", 61, 34, "", 34]], - 62, - ">>", - 60, - 47, - "span", - 62 - ], - 60, - 47, - "li", - 62 - ] - ], + [[[] | "<"] | "<"], 60, 47, - "ul", + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "1", + 60, + 47, + "span", 62 - ]} == + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "2", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", "current", 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "3", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "4", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "5", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "6", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "7", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "8", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", "ellipsis", 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + [], + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + "10", + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ], + [ + 60, + "li", + [" class=\"", [], 34], + 62, + [ + 60, + "span", + [" class=\"", [], 34], + 62, + [[[] | ">"] | ">"], + 60, + 47, + "span", + 62 + ], + 60, + 47, + "li", + 62 + ] + ], + 60, + 47, + "ul", + 62 + ] + } + + assert expected_result == HTML.pagination_links( build_conn(), %Page{ @@ -670,23 +818,23 @@ defmodule Scrivener.HTMLTest do [ 60, "nav", - [[32, "aria-label", 61, 34, "Page navigation", 34]], + [32, "aria-label", 61, 34, "Page navigation", 34], 62, [ 60, "ul", - [[32, "class", 61, 34, "pagination", 34]], + [" class=\"", "pagination", 34], 62, [ [ 60, "li", - [[32, "class", 61, 34, "active page-item", 34]], + [" class=\"", "active page-item", 34], 62, [ 60, "a", - [[32, "class", 61, 34, "page-link", 34]], + [" class=\"", "page-link", 34], 62, "1", 60, @@ -728,15 +876,25 @@ defmodule Scrivener.HTMLTest do [ 60, "ul", - [[32, "class", 61, 34, "pagination", 34]], + [" class=\"", "pagination", 34], 62, [ [ 60, "li", - [[32, "class", 61, 34, "active", 34]], + [" class=\"", "active", 34], 62, - [60, "a", [[32, "class", 61, 34, "", 34]], 62, "1", 60, 47, "a", 62], + [ + 60, + "a", + [" class=\"", [], 34], + 62, + "1", + 60, + 47, + "a", + 62 + ], 60, 47, "li", @@ -745,9 +903,19 @@ defmodule Scrivener.HTMLTest do [ 60, "li", - [[32, "class", 61, 34, "waves-effect", 34]], + [" class=\"", "waves-effect", 34], 62, - [60, "a", [[32, "class", 61, 34, "", 34]], 62, "2", 60, 47, "a", 62], + [ + 60, + "a", + [" class=\"", [], 34], + 62, + "2", + 60, + 47, + "a", + 62 + ], 60, 47, "li", @@ -756,9 +924,19 @@ defmodule Scrivener.HTMLTest do [ 60, "li", - [[32, "class", 61, 34, "waves-effect", 34]], + [" class=\"", "waves-effect", 34], 62, - [60, "a", [[32, "class", 61, 34, "", 34]], 62, ">>", 60, 47, "a", 62], + [ + 60, + "a", + [" class=\"", [], 34], + 62, + [[[] | ">"] | ">"], + 60, + 47, + "a", + 62 + ], 60, 47, "li", @@ -788,23 +966,27 @@ defmodule Scrivener.HTMLTest do [ 60, "nav", - [[32, "class", 61, 34, "pagination is-centered", 34]], + [" class=\"", "pagination is-centered", 34], 62, [ 60, "ul", - [[32, "class", 61, 34, "pagination-list", 34]], + [" class=\"", "pagination-list", 34], 62, [ [ 60, "li", - [[32, "class", 61, 34, "", 34]], + [" class=\"", [], 34], 62, [ 60, "a", - [[32, "class", 61, 34, "pagination-link is-current", 34]], + [ + " class=\"", + "pagination-link is-current", + 34 + ], 62, "1", 60, @@ -820,12 +1002,12 @@ defmodule Scrivener.HTMLTest do [ 60, "li", - [[32, "class", 61, 34, "", 34]], + [" class=\"", [], 34], 62, [ 60, "a", - [[32, "class", 61, 34, "pagination-link", 34]], + [" class=\"", "pagination-link", 34], 62, "2", 60, @@ -841,14 +1023,14 @@ defmodule Scrivener.HTMLTest do [ 60, "li", - [[32, "class", 61, 34, "", 34]], + [" class=\"", [], 34], 62, [ 60, "a", - [[32, "class", 61, 34, "pagination-link", 34]], + [" class=\"", "pagination-link", 34], 62, - ">>", + [[[] | ">"] | ">"], 60, 47, "a",