views: factor out paginator component.

* Refactor the paginator into a ViewComponent.
* Fix inconsistent spacing between paginator items.
* Fix a bug where the sequential paginator generated the wrong next /
  previous page links in the <link rel="{next|prev}"> tags in the <head>.
* Always include the final page as a hidden html element, so that it can
  be unhidden with custom CSS.
* Make it easier to change the pagination window.
This commit is contained in:
evazion
2021-02-18 00:49:05 -06:00
parent 8b8a3f3836
commit c1805cc4e0
19 changed files with 181 additions and 195 deletions

View File

@@ -22,32 +22,32 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
get posts_path(page: "a0")
assert_response :success
assert_select ".post-preview", count: 3
assert_select "#paginator-prev", count: 0
assert_select "#paginator-next", count: 1
assert_select "a.paginator-prev", count: 0
assert_select "a.paginator-next", count: 1
end
should "work with page=b0" do
get posts_path(page: "b0")
assert_response :success
assert_select ".post-preview", count: 0
assert_select "#paginator-prev", count: 0
assert_select "#paginator-next", count: 0
assert_select "a.paginator-prev", count: 0
assert_select "a.paginator-next", count: 0
end
should "work with page=b100000" do
get posts_path(page: "b100000")
assert_response :success
assert_select ".post-preview", count: 3
assert_select "#paginator-prev", count: 1
assert_select "#paginator-next", count: 0
assert_select "a.paginator-prev", count: 1
assert_select "a.paginator-next", count: 0
end
should "work with page=a100000" do
get posts_path(page: "a100000")
assert_response :success
assert_select ".post-preview", count: 0
assert_select "#paginator-prev", count: 0
assert_select "#paginator-next", count: 0
assert_select "a.paginator-prev", count: 0
assert_select "a.paginator-next", count: 0
end
end