nano-pure-mod 0.0.1
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/nano-pure-mod.gemspec +12 -0
- data/will_paginate-4.0.1/LICENSE +18 -0
- data/will_paginate-4.0.1/README.md +58 -0
- data/will_paginate-4.0.1/lib/will_paginate/active_record.rb +248 -0
- data/will_paginate-4.0.1/lib/will_paginate/array.rb +33 -0
- data/will_paginate-4.0.1/lib/will_paginate/collection.rb +136 -0
- data/will_paginate-4.0.1/lib/will_paginate/core_ext.rb +30 -0
- data/will_paginate-4.0.1/lib/will_paginate/deprecation.rb +55 -0
- data/will_paginate-4.0.1/lib/will_paginate/i18n.rb +22 -0
- data/will_paginate-4.0.1/lib/will_paginate/locale/en.yml +37 -0
- data/will_paginate-4.0.1/lib/will_paginate/mongoid.rb +48 -0
- data/will_paginate-4.0.1/lib/will_paginate/page_number.rb +53 -0
- data/will_paginate-4.0.1/lib/will_paginate/per_page.rb +27 -0
- data/will_paginate-4.0.1/lib/will_paginate/railtie.rb +74 -0
- data/will_paginate-4.0.1/lib/will_paginate/sequel.rb +39 -0
- data/will_paginate-4.0.1/lib/will_paginate/version.rb +9 -0
- data/will_paginate-4.0.1/lib/will_paginate/view_helpers/action_view.rb +155 -0
- data/will_paginate-4.0.1/lib/will_paginate/view_helpers/hanami.rb +41 -0
- data/will_paginate-4.0.1/lib/will_paginate/view_helpers/link_renderer.rb +136 -0
- data/will_paginate-4.0.1/lib/will_paginate/view_helpers/link_renderer_base.rb +77 -0
- data/will_paginate-4.0.1/lib/will_paginate/view_helpers/sinatra.rb +41 -0
- data/will_paginate-4.0.1/lib/will_paginate/view_helpers.rb +162 -0
- data/will_paginate-4.0.1/lib/will_paginate.rb +13 -0
- metadata +64 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'sinatra/base'
|
|
2
|
+
require 'will_paginate/view_helpers'
|
|
3
|
+
require 'will_paginate/view_helpers/link_renderer'
|
|
4
|
+
|
|
5
|
+
module WillPaginate
|
|
6
|
+
module Sinatra
|
|
7
|
+
module Helpers
|
|
8
|
+
include ViewHelpers
|
|
9
|
+
|
|
10
|
+
def will_paginate(collection, options = {}) #:nodoc:
|
|
11
|
+
options = options.merge(:renderer => LinkRenderer) unless options[:renderer]
|
|
12
|
+
super(collection, options)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class LinkRenderer < ViewHelpers::LinkRenderer
|
|
17
|
+
protected
|
|
18
|
+
|
|
19
|
+
def url(page)
|
|
20
|
+
str = File.join(request.script_name.to_s, request.path_info)
|
|
21
|
+
params = request.GET.merge(param_name.to_s => page.to_s)
|
|
22
|
+
params.update @options[:params] if @options[:params]
|
|
23
|
+
str << '?' << build_query(params)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def request
|
|
27
|
+
@template.request
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def build_query(params)
|
|
31
|
+
Rack::Utils.build_nested_query params
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.registered(app)
|
|
36
|
+
app.helpers Helpers
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
::Sinatra.register self
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'will_paginate/core_ext'
|
|
3
|
+
require 'will_paginate/i18n'
|
|
4
|
+
require 'will_paginate/deprecation'
|
|
5
|
+
|
|
6
|
+
module WillPaginate
|
|
7
|
+
# = Will Paginate view helpers
|
|
8
|
+
#
|
|
9
|
+
# The main view helper is +will_paginate+. It renders the pagination links
|
|
10
|
+
# for the given collection. The helper itself is lightweight and serves only
|
|
11
|
+
# as a wrapper around LinkRenderer instantiation; the renderer then does
|
|
12
|
+
# all the hard work of generating the HTML.
|
|
13
|
+
module ViewHelpers
|
|
14
|
+
class << self
|
|
15
|
+
# Write to this hash to override default options on the global level:
|
|
16
|
+
#
|
|
17
|
+
# WillPaginate::ViewHelpers.pagination_options[:page_links] = false
|
|
18
|
+
#
|
|
19
|
+
attr_accessor :pagination_options
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# default view options
|
|
23
|
+
self.pagination_options = Deprecation::Hash.new \
|
|
24
|
+
:class => 'pagination',
|
|
25
|
+
:previous_label => nil,
|
|
26
|
+
:next_label => nil,
|
|
27
|
+
:inner_window => 4, # links around the current page
|
|
28
|
+
:outer_window => 1, # links around beginning and end
|
|
29
|
+
:link_separator => ' ', # single space is friendly to spiders and non-graphic browsers
|
|
30
|
+
:param_name => :page,
|
|
31
|
+
:params => nil,
|
|
32
|
+
:page_links => true,
|
|
33
|
+
:container => true
|
|
34
|
+
|
|
35
|
+
label_deprecation = Proc.new { |key, value|
|
|
36
|
+
"set the 'will_paginate.#{key}' key in your i18n locale instead of editing pagination_options" if defined? Rails
|
|
37
|
+
}
|
|
38
|
+
pagination_options.deprecate_key(:previous_label, :next_label, &label_deprecation)
|
|
39
|
+
pagination_options.deprecate_key(:renderer) { |key, _| "pagination_options[#{key.inspect}] shouldn't be set globally" }
|
|
40
|
+
|
|
41
|
+
include WillPaginate::I18n
|
|
42
|
+
|
|
43
|
+
# Returns HTML representing page links for a WillPaginate::Collection-like object.
|
|
44
|
+
# In case there is no more than one page in total, nil is returned.
|
|
45
|
+
#
|
|
46
|
+
# ==== Options
|
|
47
|
+
# * <tt>:class</tt> -- CSS class name for the generated DIV (default: "pagination")
|
|
48
|
+
# * <tt>:previous_label</tt> -- default: "« Previous"
|
|
49
|
+
# * <tt>:next_label</tt> -- default: "Next »"
|
|
50
|
+
# * <tt>:inner_window</tt> -- how many links are shown around the current page (default: 4)
|
|
51
|
+
# * <tt>:outer_window</tt> -- how many links are around the first and the last page (default: 1)
|
|
52
|
+
# * <tt>:link_separator</tt> -- string separator for page HTML elements (default: single space)
|
|
53
|
+
# * <tt>:param_name</tt> -- parameter name for page number in URLs (default: <tt>:page</tt>)
|
|
54
|
+
# * <tt>:params</tt> -- additional parameters when generating pagination links
|
|
55
|
+
# (eg. <tt>:controller => "foo", :action => nil</tt>)
|
|
56
|
+
# * <tt>:renderer</tt> -- class name, class or instance of a link renderer (default in Rails:
|
|
57
|
+
# <tt>WillPaginate::ActionView::LinkRenderer</tt>)
|
|
58
|
+
# * <tt>:page_links</tt> -- when false, only previous/next links are rendered (default: true)
|
|
59
|
+
# * <tt>:container</tt> -- toggles rendering of the DIV container for pagination links, set to
|
|
60
|
+
# false only when you are rendering your own pagination markup (default: true)
|
|
61
|
+
#
|
|
62
|
+
# All options not recognized by will_paginate will become HTML attributes on the container
|
|
63
|
+
# element for pagination links (the DIV). For example:
|
|
64
|
+
#
|
|
65
|
+
# <%= will_paginate @posts, :style => 'color:blue' %>
|
|
66
|
+
#
|
|
67
|
+
# will result in:
|
|
68
|
+
#
|
|
69
|
+
# <div class="pagination" style="color:blue"> ... </div>
|
|
70
|
+
#
|
|
71
|
+
def will_paginate(collection, options = {})
|
|
72
|
+
# early exit if there is nothing to render
|
|
73
|
+
return nil unless collection.total_pages > 1
|
|
74
|
+
|
|
75
|
+
options = WillPaginate::ViewHelpers.pagination_options.merge(options)
|
|
76
|
+
|
|
77
|
+
options[:previous_label] ||= will_paginate_translate(:previous_label) { '← Previous' }
|
|
78
|
+
options[:next_label] ||= will_paginate_translate(:next_label) { 'Next →' }
|
|
79
|
+
|
|
80
|
+
# get the renderer instance
|
|
81
|
+
renderer = case options[:renderer]
|
|
82
|
+
when nil
|
|
83
|
+
raise ArgumentError, ":renderer not specified"
|
|
84
|
+
when String
|
|
85
|
+
klass = if options[:renderer].respond_to? :constantize then options[:renderer].constantize
|
|
86
|
+
else Object.const_get(options[:renderer]) # poor man's constantize
|
|
87
|
+
end
|
|
88
|
+
klass.new
|
|
89
|
+
when Class then options[:renderer].new
|
|
90
|
+
else options[:renderer]
|
|
91
|
+
end
|
|
92
|
+
# render HTML for pagination
|
|
93
|
+
renderer.prepare collection, options, self
|
|
94
|
+
output = renderer.to_html
|
|
95
|
+
output = output.html_safe if output.respond_to?(:html_safe)
|
|
96
|
+
output
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Renders a message containing number of displayed vs. total entries.
|
|
100
|
+
#
|
|
101
|
+
# <%= page_entries_info @posts %>
|
|
102
|
+
# #-> Displaying posts 6 - 12 of 26 in total
|
|
103
|
+
#
|
|
104
|
+
# The default output contains HTML. Use ":html => false" for plain text.
|
|
105
|
+
def page_entries_info(collection, options = {})
|
|
106
|
+
model = options[:model]
|
|
107
|
+
model = collection.first.class unless model or collection.empty?
|
|
108
|
+
model ||= 'entry'
|
|
109
|
+
model_key = if model.respond_to? :model_name
|
|
110
|
+
model.model_name.i18n_key # ActiveModel::Naming
|
|
111
|
+
else
|
|
112
|
+
model.to_s.underscore
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if options.fetch(:html, true)
|
|
116
|
+
b, eb = '<b>', '</b>'
|
|
117
|
+
sp = ' '
|
|
118
|
+
html_key = '_html'
|
|
119
|
+
else
|
|
120
|
+
b = eb = html_key = ''
|
|
121
|
+
sp = ' '
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
model_count = collection.total_pages > 1 ? 5 : collection.size
|
|
125
|
+
defaults = ["models.#{model_key}"]
|
|
126
|
+
defaults << Proc.new { |_, opts|
|
|
127
|
+
if model.respond_to? :model_name
|
|
128
|
+
model.model_name.human(:count => opts[:count])
|
|
129
|
+
else
|
|
130
|
+
name = model_key.to_s.tr('_', ' ')
|
|
131
|
+
raise "can't pluralize model name: #{model.inspect}" unless name.respond_to? :pluralize
|
|
132
|
+
opts[:count] == 1 ? name : name.pluralize
|
|
133
|
+
end
|
|
134
|
+
}
|
|
135
|
+
model_name = will_paginate_translate defaults, :count => model_count
|
|
136
|
+
|
|
137
|
+
if collection.total_pages < 2
|
|
138
|
+
i18n_key = :"page_entries_info.single_page#{html_key}"
|
|
139
|
+
keys = [:"#{model_key}.#{i18n_key}", i18n_key]
|
|
140
|
+
|
|
141
|
+
will_paginate_translate keys, :count => collection.total_entries, :model => model_name do |_, opts|
|
|
142
|
+
case opts[:count]
|
|
143
|
+
when 0; "No #{opts[:model]} found"
|
|
144
|
+
when 1; "Displaying #{b}1#{eb} #{opts[:model]}"
|
|
145
|
+
else "Displaying #{b}all#{sp}#{opts[:count]}#{eb} #{opts[:model]}"
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
else
|
|
149
|
+
i18n_key = :"page_entries_info.multi_page#{html_key}"
|
|
150
|
+
keys = [:"#{model_key}.#{i18n_key}", i18n_key]
|
|
151
|
+
params = {
|
|
152
|
+
:model => model_name, :count => collection.total_entries,
|
|
153
|
+
:from => collection.offset + 1, :to => collection.offset + collection.length
|
|
154
|
+
}
|
|
155
|
+
will_paginate_translate keys, params do |_, opts|
|
|
156
|
+
%{Displaying %s #{b}%d#{sp}-#{sp}%d#{eb} of #{b}%d#{eb} in total} %
|
|
157
|
+
[ opts[:model], opts[:from], opts[:to], opts[:count] ]
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# You will paginate!
|
|
2
|
+
module WillPaginate
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
if defined?(Rails::Railtie)
|
|
6
|
+
require 'will_paginate/railtie'
|
|
7
|
+
elsif defined?(Rails::Initializer)
|
|
8
|
+
raise "will_paginate 3.0 is not compatible with Rails 2.3 or older"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
if defined?(Sinatra) and Sinatra.respond_to? :register
|
|
12
|
+
require 'will_paginate/view_helpers/sinatra'
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nano-pure-mod
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on will_paginate
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- nano-pure-mod.gemspec
|
|
20
|
+
- will_paginate-4.0.1/LICENSE
|
|
21
|
+
- will_paginate-4.0.1/README.md
|
|
22
|
+
- will_paginate-4.0.1/lib/will_paginate.rb
|
|
23
|
+
- will_paginate-4.0.1/lib/will_paginate/active_record.rb
|
|
24
|
+
- will_paginate-4.0.1/lib/will_paginate/array.rb
|
|
25
|
+
- will_paginate-4.0.1/lib/will_paginate/collection.rb
|
|
26
|
+
- will_paginate-4.0.1/lib/will_paginate/core_ext.rb
|
|
27
|
+
- will_paginate-4.0.1/lib/will_paginate/deprecation.rb
|
|
28
|
+
- will_paginate-4.0.1/lib/will_paginate/i18n.rb
|
|
29
|
+
- will_paginate-4.0.1/lib/will_paginate/locale/en.yml
|
|
30
|
+
- will_paginate-4.0.1/lib/will_paginate/mongoid.rb
|
|
31
|
+
- will_paginate-4.0.1/lib/will_paginate/page_number.rb
|
|
32
|
+
- will_paginate-4.0.1/lib/will_paginate/per_page.rb
|
|
33
|
+
- will_paginate-4.0.1/lib/will_paginate/railtie.rb
|
|
34
|
+
- will_paginate-4.0.1/lib/will_paginate/sequel.rb
|
|
35
|
+
- will_paginate-4.0.1/lib/will_paginate/version.rb
|
|
36
|
+
- will_paginate-4.0.1/lib/will_paginate/view_helpers.rb
|
|
37
|
+
- will_paginate-4.0.1/lib/will_paginate/view_helpers/action_view.rb
|
|
38
|
+
- will_paginate-4.0.1/lib/will_paginate/view_helpers/hanami.rb
|
|
39
|
+
- will_paginate-4.0.1/lib/will_paginate/view_helpers/link_renderer.rb
|
|
40
|
+
- will_paginate-4.0.1/lib/will_paginate/view_helpers/link_renderer_base.rb
|
|
41
|
+
- will_paginate-4.0.1/lib/will_paginate/view_helpers/sinatra.rb
|
|
42
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
43
|
+
licenses:
|
|
44
|
+
- MIT
|
|
45
|
+
metadata:
|
|
46
|
+
source_code_uri: https://github.com/Andrey78/nano-pure-mod
|
|
47
|
+
rdoc_options: []
|
|
48
|
+
require_paths:
|
|
49
|
+
- lib
|
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
requirements: []
|
|
61
|
+
rubygems_version: 3.6.2
|
|
62
|
+
specification_version: 4
|
|
63
|
+
summary: Research test
|
|
64
|
+
test_files: []
|