ng_will_paginate 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85a5a495223ddd4e2bcff7330463cb674b31fad1
4
+ data.tar.gz: 15add4a62d3e3a970d7cb9e0e898eeb9a56193d1
5
+ SHA512:
6
+ metadata.gz: 27f4388e0dae4e4687c5fb937794cff8e4a5f016343b0df8fa324b9cf63ecced73b61833b6e8ee76c9951ed4cd6564fc6fb9af90d502b4fa3ea7506730d01620
7
+ data.tar.gz: 806dfec209c3b81795ea571c2851d839ed1a32050ad9b46e3a535f38543f79bb3df30ae410e9fe4ca59d78136800fef9e2369988d4b6b0b4997cff9b4729a661
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/dummy/tmp/*
11
+ *.cache
12
+ /spec/dummy/log/*
13
+ /spec/dummy/public/*
14
+ .log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ng_will_paginate.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Cheri Allen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,111 @@
1
+ # NgWillPaginate
2
+
3
+ ng_will_paginate makes it easy to use the will_paginate gem with Angular, everyone's favorte Javascript framework.
4
+
5
+ Normal use of will_paginate gem requires a page reload. Trying to paginate with AJAX on a single page requires quite a bit of extra work. This gem does that work for you.
6
+
7
+ This allows you to use the will_paginate gem via an Angular controller. User pushes button on page, triggering a method in Angular controller that calls a Rails controller for selected page of records.
8
+
9
+ Includes:
10
+ - service that talks to rails
11
+ - directive that puts links on page
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'will_paginate'
19
+ gem 'ng_will_paginate'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Add '//= require ng_will_paginate' to your application.js manifest
27
+
28
+ Add 'ng-will-paginate' as a dependency of your Angular app:
29
+ angular.module('myModule', ['ng-will-paginate'])
30
+
31
+ ## Usage
32
+ To use ng_will_paginate, first include the logic to retrieve your records from your database.
33
+
34
+ ###In your Rails controller:
35
+ ```ruby
36
+ def index
37
+ @records = MyClass.paginate(:page => params[:page], :per_page => 10).order(created_at: 'desc')
38
+
39
+ render json: { max: @records.total_pages,
40
+ records: @records.as_json() }
41
+ ```
42
+ The .as_json() method can accept all of it's normal options.
43
+ [See the .to_JSON documentation for examples](http://apidock.com/rails/Hash/to_json)
44
+
45
+ ###In your Angular controller:
46
+ 1. inject $scope and paginationService into your controller
47
+ ```coffeescript
48
+ myApp.controller 'myController', ['$scope', 'paginationService', ($scope, paginationService)->
49
+ //the controller code
50
+ ]
51
+ ```
52
+ 2. add the following code to your controller
53
+ ```coffescript
54
+ $scope.route = '/my_route' //this is the path for your method, if the index method above was for a class called 'Record', the path may look like '/records'
55
+
56
+ $scope.goToPage=(pageNumber)->
57
+ paginationService.getPage(pageNumber, $scope.route, $scope)
58
+
59
+ $scope.goToPage 1
60
+ ```
61
+
62
+ Now your records will be available as an array of JSON object in $scope.records
63
+
64
+ 3. in your view
65
+ ```html
66
+ <pagination></pagination>
67
+ ```
68
+
69
+
70
+ When triggering on page, pass model name like in WP. Setup includes which Rails endpoint each model name can go to.
71
+
72
+ ## Development
73
+
74
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
75
+
76
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
+
78
+ ### Testing
79
+ We love testing - so we want to test all the things.
80
+
81
+ To run jasmine tests:
82
+
83
+ 1. Navigate from the gem's repo to the dummy app
84
+ ```cd spec/dummy```
85
+ 2. Start a server
86
+ ```rails s```
87
+ 3. In your browser navigate to "localhost:3000/specs"
88
+
89
+ ## Contributing
90
+ Issues and tasks are in the Issues for this repo. We'd love your help!
91
+
92
+ Please comment on an Issue if you'd like to work on it, and submit a Pull Request when the work is done. All code should be tested.
93
+
94
+ 1. Fork it ( https://github.com/[my-github-username]/ng_will_paginate/fork )
95
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
96
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
97
+ 4. Push to the branch (`git push origin my-new-feature`)
98
+ 5. Create a new Pull Request
99
+
100
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) [code of conduct](http://contributor-covenant.org/version/1/3/0/).
101
+
102
+ ## About NIRD
103
+
104
+ ![alt text](https://s3-us-west-2.amazonaws.com/nirdmarketingassets/nird_logo_centered.png "Northwest Independent Ruby Development")
105
+
106
+ Grace_period is maintained and funded by NIRD LLC. The names and logos of NIRD are trademarks of NIRD LLC.
107
+ We are committed to giving back to the open source community. We are [available for hire.](http://www.nird.us/?utm_source=github)
108
+
109
+ ## License
110
+
111
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,46 @@
1
+ angular.module('ng-will-paginate', [])
2
+ .directive 'pagination', ->
3
+ {
4
+ restrict: 'E',
5
+ scope: false,
6
+ template: "<div class='pagination-container' ng-if='pages.length > 1'>
7
+ <a class='pagination' ng-click='goToPage(1)' ng-if='currentPage > 1'>
8
+ <<
9
+ </a>
10
+ <a class='pagination' ng-click='goToPage(currentPage - 1)' ng-if='currentPage > 1'>
11
+ < prev
12
+ </a>
13
+ <a class='pagination page-links' ng-repeat='page in pages' ng-click='goToPage(page)'
14
+ ng-class=\"{'current': page == currentPage}\">
15
+ {{page}}
16
+ </a>
17
+ <a class='pagination' ng-click='goToPage(currentPage + 1)' ng-if='currentPage != max'>
18
+ next >
19
+ </a>
20
+ <a class='pagination' ng-click='goToPage(max)' ng-if='currentPage != max'>
21
+ >>
22
+ </a>
23
+ </div>"
24
+ }
25
+ .factory 'paginationService', ['$http', ($http)->
26
+
27
+ getPage: (pageNumber, route, scope)->
28
+ return $http.get(route, params: {page: pageNumber})
29
+ .success ((data, status, headers, config) ->
30
+ scope.currentPage = pageNumber
31
+ scope.max = data.max
32
+
33
+ scope.pages = []
34
+ scope.pages.push(scope.currentPage - 2) if scope.currentPage - 2 > 0
35
+ scope.pages.push(scope.currentPage - 1) if scope.currentPage - 1 > 0
36
+ scope.pages.push(scope.currentPage)
37
+ scope.pages.push(scope.currentPage + 1) if scope.currentPage + 1 <= scope.max
38
+ scope.pages.push(scope.currentPage + 2) if scope.currentPage + 2 <= scope.max
39
+
40
+ scope.records = data.records
41
+ )
42
+ .error ((data, status, headers, config) ->
43
+ return data.errors
44
+ )
45
+
46
+ ]
@@ -0,0 +1,10 @@
1
+ module NgWillPaginate
2
+ class Objectifier
3
+ def self.JSONify(per_page, page, records, as_json_options=nil)
4
+ return { max: 0, records: [] } if records.length == 0
5
+ total = records.first.class.count
6
+ max_pages = (total / per_page).ceil
7
+ return {max: max_pages, records: records.as_json(as_json_options)}
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ng_will_paginate"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ require "ng_will_paginate/version"
2
+
3
+ module NgWillPaginate
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module NgWillPaginate
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ng_will_paginate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ng_will_paginate"
8
+ spec.version = NgWillPaginate::VERSION
9
+ spec.authors = ["Cheri Allen", "Utah Kate Newman", "Patrick Dent"]
10
+ spec.email = ["nirds@nird.us"]
11
+
12
+ spec.summary = %q{Allows you to incorporate will_paginate into an Angular on Ruby on Rails app.}
13
+ spec.description = %q{}
14
+ spec.homepage = "http://github.com/nirds/ng_will_paginate"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.8"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_runtime_dependency "will_paginate"
24
+ spec.add_development_dependency "jasmine-rails"
25
+ spec.add_development_dependency "rails"
26
+ spec.add_development_dependency "sqlite3"
27
+ spec.add_development_dependency "coffee-rails"
28
+ spec.add_development_dependency "angularjs-rails"
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ng_will_paginate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Cheri Allen
8
+ - Utah Kate Newman
9
+ - Patrick Dent
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-01-13 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.8'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: '1.8'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '10.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '10.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: will_paginate
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: jasmine-rails
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rails
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: sqlite3
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ - !ruby/object:Gem::Dependency
100
+ name: coffee-rails
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ - !ruby/object:Gem::Dependency
114
+ name: angularjs-rails
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ description: ''
128
+ email:
129
+ - nirds@nird.us
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .rspec
136
+ - .travis.yml
137
+ - CODE_OF_CONDUCT.md
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - app/assets/javascripts/ng_will_paginate.js.coffee
143
+ - app/models/ng_will_paginate/objectifier.rb
144
+ - bin/console
145
+ - bin/setup
146
+ - lib/ng_will_paginate.rb
147
+ - lib/ng_will_paginate/version.rb
148
+ - ng_will_paginate-0.1.0.gem
149
+ - ng_will_paginate-0.1.1.gem
150
+ - ng_will_paginate-0.2.0.gem
151
+ - ng_will_paginate-0.2.1.gem
152
+ - ng_will_paginate-0.2.2.gem
153
+ - ng_will_paginate-0.2.3.gem
154
+ - ng_will_paginate-0.2.4.gem
155
+ - ng_will_paginate-0.2.5.gem
156
+ - ng_will_paginate-0.2.6.gem
157
+ - ng_will_paginate-0.3.0.gem
158
+ - ng_will_paginate.gemspec
159
+ homepage: http://github.com/nirds/ng_will_paginate
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.4.6
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: Allows you to incorporate will_paginate into an Angular on Ruby on Rails
183
+ app.
184
+ test_files: []
185
+ has_rdoc: