Show-Pagination 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/show-pagination.rb +39 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9ee355d78de93576444ad0eaa6d48d76159a22fd72301a5c09200a3b126504e3
|
|
4
|
+
data.tar.gz: eba4dbb2568775a69395eeb350db5b4914df59ada3995739ee17bda2dd50268c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ed121f4b7891dd1c143375e1b63ed6893623f83515e2e48c90647f325f8b1165304e289a168793a7f89f922511f284f199e7d2726e5547ee800d4442a48a2677
|
|
7
|
+
data.tar.gz: 34019f8b5f63cfd2db471e4e919cc910ef9c4872eb4eeea0d5402e15c35bf83c023d43410062f7586576315a4cf24d13d324b298a29134706beebd878649afa3
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class ShowPagination
|
|
2
|
+
def previous_page_by_id
|
|
3
|
+
if @blog.id != Blog.first.id
|
|
4
|
+
blog = Blog.select(:id).where("id < ?", @blog.id)
|
|
5
|
+
blog.last.id
|
|
6
|
+
else
|
|
7
|
+
redirect_back(fallback_location: root_path)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def next_page_by_id
|
|
12
|
+
if @blog.id != Blog.last.id
|
|
13
|
+
blog = Blog.select(:id).where("id > ?", @blog.id)
|
|
14
|
+
blog.last.id
|
|
15
|
+
else
|
|
16
|
+
redirect_back(fallback_location: root_path)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def previous_page_by_slug
|
|
21
|
+
if @blog.id != Blog.first.id
|
|
22
|
+
blog = Blog.select(:id).where("id < ?", @blog.id)
|
|
23
|
+
page = Blog.find_by(id: blog.last.id)
|
|
24
|
+
page.slug
|
|
25
|
+
else
|
|
26
|
+
redirect_back(fallback_location: root_path)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def next_page_by_slug
|
|
31
|
+
if @blog.id != Blog.last.id
|
|
32
|
+
blog = Blog.select(:id).where("id > ?", @blog.id)
|
|
33
|
+
page = Blog.find_by(id: blog.first.id)
|
|
34
|
+
page.slug
|
|
35
|
+
else
|
|
36
|
+
redirect_back(fallback_location: root_path)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: Show-Pagination
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kade Illian
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-10-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple pagination gem for models like blogs or users.
|
|
14
|
+
email: kadeillianmt@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/show-pagination.rb
|
|
20
|
+
homepage: https://rubygems.org/gems/show-pagination
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubygems_version: 3.3.7
|
|
40
|
+
signing_key:
|
|
41
|
+
specification_version: 4
|
|
42
|
+
summary: The show-pagination allows for users to easily implement a 'next' and 'previous'
|
|
43
|
+
button that navigates to the next or previous non-nil id respectively!
|
|
44
|
+
test_files: []
|