changed CHANGELOG.md
 
@@ -1,5 +1,9 @@
1
1
# Changelog
2
2
3
+ ## 0.3.1 (2022-06-06)
4
+
5
+ fixed warning about collecting into a non-empty list
6
+
3
7
## 0.3.0 (2021-11-13)
4
8
5
9
added preliminar support for Live View by calling `Phoenix.LiveView.Helpers.live_patch/2` instead of `Phoenix.HTML.Link.link/2` if *live* option is `true`
changed README.md
 
@@ -23,7 +23,7 @@ def deps do
23
23
[
24
24
# ...
25
25
{:scrivener_ecto, "~> 2.7"},
26
- {:scrivener_phoenix, "~> 0.3.0"},
26
+ {:scrivener_phoenix, "~> 0.3.1"},
27
27
]
28
28
end
29
29
```
 
@@ -34,7 +34,7 @@ The docs can be found at [https://hexdocs.pm/scrivener_phoenix](https://hexdocs.
34
34
35
35
Configure scrivener_phoenix in your_app/config/config.exs:
36
36
37
- ```
37
+ ```elixir
38
38
config :scrivener_phoenix,
39
39
left: 0,
40
40
right: 0,
 
@@ -202,6 +202,20 @@ def blog_page_path(conn_or_endpoint, action = :index, page, query_params \\ [])
202
202
203
203
TL;DR: for arity, add 3 to the length of the list you pass as parameters if page number is a parameter to your route else 2 (and the page number will be part of the query string)
204
204
205
+ Of course you can use your own functions as callback, eg: `<%= paginate @conn, @posts, fn conn, args -> MyBlogWeb.Router.Helpers.blog_path(conn, :index, args) end %>` or:
206
+
207
+ ```elixir
208
+ defmodule SomeModule do
209
+ def comment_index_url(conn, post, page, args) do
210
+ MyBlogWeb.Router.Helpers.blog_post_comment_page_url(conn, :index, post, page, args)
211
+ end
212
+ end
213
+ ```
214
+
215
+ With `<%= paginate @conn, @comments, &SomeModule.comment_index_url/3, [@post] %>` in the template.
216
+
217
+ Note that the conn (or endpoint module's name) remains the first argument and the Keyword-list for the query string parameters the very last.
218
+
205
219
## LiveView: dealing with live views
206
220
207
221
In order to avoid liveview reloading, we need to handle page changes with `handle_params/3` callback but without triggering a full (re)`mount/3`. To do so, pagination links have to be generated by calling `Phoenix.LiveView.Helpers.live_patch/2` instead of the "regular" `Phoenix.HTML.Link.link/2`. Since you may want to share a same template for dead and live views, a *live* option has been introduced to know which of these two has to be called.
changed hex_metadata.config
 
@@ -2,7 +2,7 @@
2
2
{<<"build_tools">>,[<<"mix">>]}.
3
3
{<<"description">>,
4
4
<<"Helper to render scrivener paginations in phoenix.\n\nFeatures:\n\n * reversed pagination (`3 2 1` instead of traditional `1 2 3`)\n * *page* parameter can be directly passed through URL's path (ie be part of your route, eg: /blog/page/3 instead of /blog/?page=3)">>}.
5
- {<<"elixir">>,<<"~> 1.7">>}.
5
+ {<<"elixir">>,<<"~> 1.9">>}.
6
6
{<<"files">>,
7
7
[<<"lib">>,<<"lib/scrivener_phoenix">>,<<"lib/scrivener_phoenix/page.ex">>,
8
8
<<"lib/scrivener_phoenix/gap.ex">>,<<"lib/gettext.ex">>,
 
@@ -34,4 +34,4 @@
34
34
{<<"optional">>,false},
35
35
{<<"repository">>,<<"hexpm">>},
36
36
{<<"requirement">>,<<">= 0.16.0">>}]]}.
37
- {<<"version">>,<<"0.3.0">>}.
37
+ {<<"version">>,<<"0.3.1">>}.
changed lib/scrivener_phoenix_web/views/scrivener_phoenix_view.ex
 
@@ -234,11 +234,15 @@ defmodule Scrivener.PhoenixView do
234
234
end
235
235
236
236
defp append_pages(links, pages, spage, options) do
237
- pages
238
- |> Enum.reverse()
239
- |> Enum.into(links, fn page ->
240
- options.template.page(page, spage, options)
241
- end)
237
+ result =
238
+ pages
239
+ |> Enum.reverse()
240
+ |> Enum.map(
241
+ fn page ->
242
+ options.template.page(page, spage, options)
243
+ end
244
+ )
245
+ Enum.concat(links, result)
242
246
end
243
247
244
248
@spec has_prev?(page :: Scrivener.Page.t) :: boolean
changed mix.exs
 
@@ -4,15 +4,12 @@ defmodule Scrivener.Phoenix.MixProject do
4
4
defp elixirc_paths(:test), do: ~W[lib test/support]
5
5
defp elixirc_paths(_), do: ~W[lib]
6
6
7
- defp compilers(:test), do: ~W[phoenix gettext]a ++ Mix.compilers()
8
- defp compilers(_), do: ~W[gettext]a ++ Mix.compilers()
9
-
10
7
def project do
11
8
[
12
9
app: :scrivener_phoenix,
13
- version: "0.3.0",
14
- elixir: "~> 1.7",
15
- compilers: compilers(Mix.env()),
10
+ version: "0.3.1",
11
+ elixir: "~> 1.9",
12
+ compilers: ~W[gettext]a ++ Mix.compilers(),
16
13
start_permanent: Mix.env() == :prod,
17
14
description: description(),
18
15
package: package(),
 
@@ -52,7 +49,7 @@ defmodule Scrivener.Phoenix.MixProject do
52
49
[
53
50
files: ~W[lib priv mix.exs CHANGELOG.md README.md],
54
51
licenses: ["BSD"],
55
- links: %{"GitHub" => "https://github.com/julp/scrivener_phoenix"}
52
+ links: %{"GitHub" => "https://github.com/julp/scrivener_phoenix"},
56
53
]
57
54
end