diff --git a/config/config.exs b/config/config.exs index 136603b..90e09d5 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 @@ -8,6 +8,8 @@ use Mix.Config # if you want to provide default values for your application for third- # party users, it should be done in your mix.exs file. +config :phoenix, json_library: Jason + # Sample configuration: # # config :logger, diff --git a/lib/scrivener/html.ex b/lib/scrivener/html.ex index 7cb0835..58fddd8 100644 --- a/lib/scrivener/html.ex +++ b/lib/scrivener/html.ex @@ -185,10 +185,8 @@ defmodule Scrivener.HTML do page_param: _page_param, params: _params ) - when not (style in @view_styles) do - raise "Scrivener.HTML: View style #{inspect(style)} is not a valid view style. Please use one of #{ - inspect(@view_styles) - }" + when style not in @view_styles do + raise "Scrivener.HTML: View style #{inspect(style)} is not a valid view style. Please use one of #{inspect(@view_styles)}" end # Bootstrap implementation diff --git a/mix.exs b/mix.exs index 4646472..93a0c3a 100644 --- a/mix.exs +++ b/mix.exs @@ -1,12 +1,12 @@ defmodule ScrivenerHtml.Mixfile do use Mix.Project - @version "1.8.1" + @version "1.2.0" def project do [ app: :scrivener_html, version: @version, - elixir: "~> 1.2", + elixir: "~> 1.17", name: "scrivener_html", source_url: "https://github.com/mgwidmann/scrivener_html", homepage_url: "https://github.com/mgwidmann/scrivener_html", @@ -29,7 +29,7 @@ defmodule ScrivenerHtml.Mixfile do # Type `mix help compile.app` for more information def application do [ - applications: [:logger] + extra_applications: [:phoenix, :phoenix_html, :scrivener] ] end @@ -47,12 +47,13 @@ defmodule ScrivenerHtml.Mixfile do # Type `mix help deps` for more examples and options defp deps do [ - {:scrivener, "~> 1.2 or ~> 2.0"}, - {:phoenix_html, "~> 2.2"}, - {:phoenix, "~> 1.0 and < 1.5.0", optional: true}, - {:plug, "~> 1.1"}, - {:ex_doc, "~> 0.19", only: :dev}, - {:earmark, "~> 1.1", only: :dev} + {:scrivener, "~> 2.7"}, + {:phoenix_html, "~> 3.1"}, + {:phoenix, "~> 1.7"}, + {:plug, "~> 1.16"}, + {:jason, "~> 1.4"}, + {:ex_doc, "~> 0.34.1", only: :dev}, + {:earmark, "~> 1.4", only: :dev} ] end diff --git a/mix.lock b/mix.lock index 60a41fe..0a3b49b 100644 --- a/mix.lock +++ b/mix.lock @@ -1,20 +1,30 @@ %{ + "castore": {:hex, :castore, "1.0.8", "dedcf20ea746694647f883590b82d9e96014057aff1d44d03ec90f36a5c0dc6e", [:mix], [], "hexpm", "0b2b66d2ee742cb1d9cb8c8be3b43c3a70ee8651f37b75a8b982e036752983f1"}, "decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], []}, - "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"}, + "earmark": {:hex, :earmark, "1.4.40", "ff1a0f8bf3b298113c2a257c4e7a8b29ba9db5d35f5ee6d29291cb8caa09a071", [:mix], [{:earmark_parser, "~> 1.4.35", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "5fb622d5e36046bc313a426211e8bf769ba50db7720744859a21932c6470d75c"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.40", "f3534689f6b58f48aa3a9ac850d4f05832654fe257bf0549c08cc290035f70d5", [:mix], [], "hexpm", "cdb34f35892a45325bad21735fadb88033bcb7c4c296a999bde769783f53e46a"}, "ecto": {:hex, :ecto, "1.1.8", "0f0348e678fa5a450c266d69816808f97fbd82ade32cf88d4b09bbe8f8c27545", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.5.0 or ~> 0.6.0", [hex: :mariaex, optional: true]}, {:poison, "~> 1.0 or ~> 2.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.4", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.11.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 0.7", [hex: :sbroker, optional: true]}]}, - "ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"}, + "jason": {:hex, :jason, "1.4.3", "d3f984eeb96fe53b85d20e0b049f03e57d075b5acda3ac8d465c969a2536c17b", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "9a90e868927f7c777689baa16d86f4d0e086d968db5c05d917ccff6d443e58a3"}, + "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, "meck": {:hex, :meck, "0.8.4", "59ca1cd971372aa223138efcf9b29475bde299e1953046a0c727184790ab1520", [:rebar, :make], []}, - "mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, + "mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "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"}, - "phoenix_html": {:hex, :phoenix_html, "2.9.3", "1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]}, - "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"}, - "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"}, - "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, + "phoenix": {:hex, :phoenix, "1.7.14", "a7d0b3f1bc95987044ddada111e77bd7f75646a08518942c72a8440278ae7825", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "c7859bc56cc5dfef19ecfc240775dae358cbaa530231118a9e014df392ace61a"}, + "phoenix_html": {:hex, :phoenix_html, "3.3.4", "42a09fc443bbc1da37e372a5c8e6755d046f22b9b11343bf885067357da21cb3", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "0249d3abec3714aff3415e7ee3d9786cb325be3151e6c4b3021502c585bf53fb"}, + "phoenix_html_helpers": {:hex, :phoenix_html_helpers, "1.0.1", "7eed85c52eff80a179391036931791ee5d2f713d76a81d0d2c6ebafe1e11e5ec", [:mix], [{:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "cffd2385d1fa4f78b04432df69ab8da63dc5cf63e07b713a4dcf36a3740e3090"}, + "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"}, + "phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"}, + "phoenix_view": {:hex, :phoenix_view, "2.0.2", "6bd4d2fd595ef80d33b439ede6a19326b78f0f1d8d62b9a318e3d9c1af351098", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}], "hexpm", "a929e7230ea5c7ee0e149ffcf44ce7cf7f4b6d2bfe1752dd7c084cdff152d36f"}, + "plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"}, + "plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"}, "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], []}, + "scrivener": {:hex, :scrivener, "2.7.2", "1d913c965ec352650a7f864ad7fd8d80462f76a32f33d57d1e48bc5e9d40aba2", [:mix], [], "hexpm", "7866a0ec4d40274efbee1db8bead13a995ea4926ecd8203345af8f90d2b620d9"}, + "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, + "websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"}, + "websock_adapter": {:hex, :websock_adapter, "0.5.6", "0437fe56e093fd4ac422de33bf8fc89f7bc1416a3f2d732d8b2c8fd54792fe60", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "e04378d26b0af627817ae84c92083b7e97aca3121196679b73c73b99d0d133ea"}, } 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..4c11e63 100644 --- a/test/scrivener/html_test.exs +++ b/test/scrivener/html_test.exs @@ -6,6 +6,8 @@ defmodule Scrivener.HTMLTest do import Scrivener.Support.HTML alias Scrivener.Page + import Phoenix.ConnTest + setup do Application.put_env(:scrivener_html, :view_style, :bootstrap) Application.put_env(:scrivener_html, :routes_helper, MyApp.Router.Helpers) @@ -162,7 +164,10 @@ defmodule Scrivener.HTMLTest do test "does not include ellipsis on first page" do assert pages(1..6) == - links_with_opts([total_pages: 8, page_number: 1], first: true, ellipsis: "…") + links_with_opts([total_pages: 8, page_number: 1], + first: true, + ellipsis: "…" + ) end test "uses ellipsis only beyond of first page" do @@ -318,7 +323,6 @@ defmodule Scrivener.HTMLTest do describe "Phoenix conn()" do test "handles no entries" do - use Phoenix.ConnTest Application.put_env(:scrivener_html, :view_style, :bootstrap) Application.put_env(:scrivener_html, :routes_helper, MyApp.Router.Helpers) @@ -331,15 +335,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", @@ -366,7 +370,6 @@ defmodule Scrivener.HTMLTest do end test "allows other url parameters" do - use Phoenix.ConnTest Application.put_env(:scrivener_html, :view_style, :bootstrap) Application.put_env(:scrivener_html, :routes_helper, MyApp.Router.Helpers) @@ -387,16 +390,14 @@ defmodule Scrivener.HTMLTest do end describe "View Styles" do - use Phoenix.ConnTest - test "renders Semantic UI styling" do assert {:safe, [ 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 +417,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 +521,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 +819,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 +877,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 +904,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 +925,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 +967,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 +1003,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 +1024,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",