redmine_kaminari 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f79d8a2d050e707d71ec0a9bd59fbfde5efd9d33
4
+ data.tar.gz: 56b4aa29d35214b797f1a5b787d30638002f3a65
5
+ SHA512:
6
+ metadata.gz: bccdeec00261a5ff35a7b5fe4e6a71fceaabb35b984516d19953318b3645fc19637aaf59a3a4aa2958279e666fec89c72862ed45a8d0a9cd875c4ff7250768b2
7
+ data.tar.gz: 63ba6e3a588f08b10beca1fcdd9d8c0b97160f2121b485e8789cb13445ef3cb28d037fe01b573f64738a2aba11e86467c00425a7cbdbc9f8cd419d791ade6ff7
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redmine_kaminari.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 shipiev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # RedmineKaminari
2
+
3
+ Kaminari pagination is adapted for Redmine. Now "Paginator.new" is in the past!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'redmine_kaminari'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install redmine_kaminari
18
+
19
+ ## Usage
20
+
21
+ # controller
22
+ class FooController < ApplicationController
23
+
24
+ def index
25
+ # per_page_option -- redmine's method
26
+ @collection = Foo.page(params[:page]).per(per_page_option)
27
+ end
28
+ end
29
+
30
+ #view
31
+
32
+ %p.pagination
33
+ = paginate @collection
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( http://github.com/<my-github-username>/redmine_kaminari/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,8 @@
1
+ -# Non-link tag that stands for skipped pages...
2
+ -# available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ %span.page.gap
8
+ &hellip;
@@ -0,0 +1,9 @@
1
+ -# Link to the "Next" page
2
+ -# available local variables
3
+ -# url: url to the next page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.next
9
+ = link_to_unless current_page.last?, "#{l(:label_next)} &raquo;".html_safe, url, rel: 'next', remote: remote
@@ -0,0 +1,10 @@
1
+ -# Link showing page number
2
+ -# available local variables
3
+ -# page: a page object for "this" page
4
+ -# url: url to this page
5
+ -# current_page: a page object for the currently displayed page
6
+ -# total_pages: total number of pages
7
+ -# per_page: number of items to fetch per page
8
+ -# remote: data-remote
9
+ %span{class: "page#{' current' if page.current?}"}
10
+ = link_to_unless page.current?, page, url, {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil}
@@ -0,0 +1,16 @@
1
+ -# The container tag
2
+ -# available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ -# paginator: the paginator that renders the pagination tags inside
8
+ = paginator.render do
9
+ = prev_page_tag unless current_page.first?
10
+ - each_page do |page|
11
+ - if page.left_outer? || page.right_outer? || page.inside_window?
12
+ = page_tag page
13
+ - elsif !page.was_truncated?
14
+ = gap_tag
15
+ = next_page_tag unless current_page.last?
16
+
@@ -0,0 +1,9 @@
1
+ -# Link to the "Previous" page
2
+ -# available local variables
3
+ -# url: url to the previous page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.prev
9
+ = link_to_unless current_page.first?, "&laquo; #{l(:label_previous)}".html_safe, url, rel: 'prev', remote: remote
@@ -0,0 +1,13 @@
1
+ require 'redmine_kaminari/version'
2
+ require 'redmine_kaminari/engine'
3
+ require 'redmine_kaminari/kaminari'
4
+ require 'redmine_kaminari/kaminari/action_view_extension_patch'
5
+
6
+ module RedmineKaminari
7
+ # Your code goes here...
8
+ end
9
+
10
+ require_dependency 'kaminari'
11
+ unless Kaminari::ActionViewExtension.included_modules.include? RedmineKaminari::Kaminari::ActionViewExtensionPatch
12
+ Kaminari::ActionViewExtension.send(:include, RedmineKaminari::Kaminari::ActionViewExtensionPatch)
13
+ end
@@ -0,0 +1,4 @@
1
+ module RedmineKaminari
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RedmineKaminari::Kaminari
2
+ # Your code goes here...
3
+ end
@@ -0,0 +1,66 @@
1
+ module RedmineKaminari::Kaminari::ActionViewExtensionPatch
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ alias_method_chain :paginate, :redmine_patch
6
+ alias_method_chain :page_entries_info, :redmine_patch
7
+
8
+ def per_page_tag(scope, options)
9
+ values = per_page_opts(scope.limit_value, scope.total_count)
10
+
11
+ if values.any?
12
+ links =
13
+ values.collect do |n|
14
+ if n == scope.limit_value
15
+ content_tag('span', n.to_s)
16
+ else
17
+ link_to n.to_s,
18
+ content_tag('a', href: url_for(per_page: n, options[:param_name] => nil)) do
19
+ n.to_s
20
+ end
21
+ end
22
+ end
23
+
24
+ l(:label_display_per_page, links.join(', ')).html_safe
25
+ end
26
+ end
27
+
28
+ def per_page_opts(selected=nil, item_count=nil)
29
+ options = Setting.per_page_options_array
30
+
31
+ if item_count && options.any?
32
+ max =
33
+ if item_count > options.first
34
+ options.detect {|value| value >= item_count} || item_count
35
+ else
36
+ item_count
37
+ end
38
+
39
+ options.select! {|value| value <= max || value == selected}
40
+ end
41
+
42
+ if options.empty? || (options.size == 1 && options.first == selected)
43
+ []
44
+ else
45
+ options
46
+ end
47
+ end
48
+ end
49
+
50
+ def page_entries_info_with_redmine_patch(scope, options = {})
51
+ first = scope.offset_value + 1
52
+ last = scope.last_page? ? scope.total_count : scope.offset_value + scope.limit_value
53
+ "(#{first}-#{last}/#{scope.total_count})".html_safe
54
+ end
55
+
56
+ def paginate_with_redmine_patch(scope, options = {}, &block)
57
+ paginate_without_redmine_patch(scope, options, &block) +
58
+ content_tag('span', class: 'items') do
59
+ page_entries_info(scope, options)
60
+ end + ' '.html_safe +
61
+ content_tag('span', class: 'per-page') do
62
+ per_page_tag(scope, options)
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,3 @@
1
+ module RedmineKaminari
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'redmine_kaminari/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'redmine_kaminari'
8
+ spec.version = RedmineKaminari::VERSION
9
+ spec.authors = ['Roman Shipiev']
10
+ spec.email = ['roman@shipiev.pro']
11
+ spec.summary = %q{Kaminari for Redmine's plugin developers}
12
+ spec.description = %q{Kaminari pagination is adapted for Redmine. Now "Paginator.new" is in the past!}
13
+ spec.homepage = 'https://github.com/shipiev/redmine_kaminari'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'rails', '~> 3.2.13'
22
+ spec.add_dependency 'haml-rails', '~> 0.4'
23
+ spec.add_dependency 'kaminari', '~> 0.16.1'
24
+ spec.add_development_dependency 'bundler', '~> 1.5'
25
+ spec.add_development_dependency 'rake'
26
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redmine_kaminari
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Roman Shipiev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kaminari
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.16.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.16.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Kaminari pagination is adapted for Redmine. Now "Paginator.new" is in
84
+ the past!
85
+ email:
86
+ - roman@shipiev.pro
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - app/views/kaminari/_gap.html.haml
97
+ - app/views/kaminari/_next_page.html.haml
98
+ - app/views/kaminari/_page.html.haml
99
+ - app/views/kaminari/_paginator.html.haml
100
+ - app/views/kaminari/_prev_page.html.haml
101
+ - lib/redmine_kaminari.rb
102
+ - lib/redmine_kaminari/engine.rb
103
+ - lib/redmine_kaminari/kaminari.rb
104
+ - lib/redmine_kaminari/kaminari/action_view_extension_patch.rb
105
+ - lib/redmine_kaminari/version.rb
106
+ - redmine_kaminari.gemspec
107
+ homepage: https://github.com/shipiev/redmine_kaminari
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.0.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Kaminari for Redmine's plugin developers
131
+ test_files: []
132
+ has_rdoc: