jekyll-paginate-category 0.1.0

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: 6699dff7f7bb91b085125c183c0d0e0641239bc7
4
+ data.tar.gz: 3fcc27a0ce1b9f3bb9d409bbab56c8a32ebc1e81
5
+ SHA512:
6
+ metadata.gz: 1434ac1cb6dc5c9768f984fa1faaddea87800c157100c2efb4ccfc87aa115c13e609b4ee0e464ebc9e08c86cf65cdca612a62e89400085e34d8059c163f74370
7
+ data.tar.gz: 83f931b33b6084df4b5db793c612ccd52d716884f94fd0203c3781978af822d372685983fd80f9a718cd73dfaf8b87c785a94b15b1b92f6c4ea67a3b4e22d425
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-paginate-category.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 midnightSuyama
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,61 @@
1
+ # Jekyll::Paginate::Category
2
+
3
+ Pagination Generator for Jekyll Category
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jekyll-paginate-category'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jekyll-paginate-category
20
+
21
+ ## Usage
22
+
23
+ ### _config.yml
24
+
25
+ ```yaml
26
+ gems: [jekyll-paginate, jekyll-paginate-category]
27
+
28
+ paginate: 5
29
+ paginate_path: "page:num"
30
+
31
+ category_dir: "categories"
32
+ category_layout: "index.html"
33
+ ```
34
+
35
+ ### index.html (category_layout)
36
+
37
+ ```html
38
+ {% if page.paginator %}
39
+ {% assign paginator = page.paginator %}
40
+ {% endif %}
41
+
42
+ {% for post in paginator.posts %}
43
+ ...
44
+ {% endfor %}
45
+ ```
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-paginate-category. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
56
+
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
61
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-paginate-category/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-paginate-category"
8
+ spec.version = Jekyll::Paginate::Category::VERSION
9
+ spec.authors = ["midnightSuyama"]
10
+ spec.email = ["midnightSuyama@gmail.com"]
11
+ spec.summary = "Pagination Generator for Jekyll Category"
12
+ spec.description = "Pagination Generator for Jekyll Category"
13
+ spec.homepage = "https://github.com/midnightSuyama/jekyll-paginate-category"
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.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.10"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "jekyll", ">= 2.0"
23
+ spec.add_development_dependency "jekyll-paginate", "~> 1.1"
24
+ end
@@ -0,0 +1,48 @@
1
+ require "jekyll-paginate-category/version"
2
+
3
+ module Jekyll
4
+ module Paginate
5
+ module Category
6
+
7
+ class Pagination < Generator
8
+ safe true
9
+ priority :lowest
10
+
11
+ def generate(site)
12
+ if Paginate::Pager.pagination_enabled?(site)
13
+ site.categories.each do |category, posts|
14
+ total = Paginate::Pager.calculate_pages(posts, site.config['paginate'])
15
+ (1..total).each do |i|
16
+ site.pages << IndexPage.new(site, category, i)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ class IndexPage < Page
24
+ def initialize(site, category, num_page)
25
+ @site = site
26
+ @base = site.source
27
+
28
+ category_dir = site.config['category_dir'] || 'categories'
29
+ @dir = File.join(category_dir, category)
30
+
31
+ @name = Paginate::Pager.paginate_path(site, num_page)
32
+ @name.concat '/' unless @name.end_with? '/'
33
+
34
+ self.process(@name)
35
+
36
+ category_layout = site.config['category_layout'] || 'index.html'
37
+ self.read_yaml(@base, category_layout)
38
+
39
+ self.data.merge!(
40
+ 'title' => category,
41
+ 'paginator' => Paginate::Pager.new(site, num_page, site.categories[category])
42
+ )
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ module Jekyll
2
+ module Paginate
3
+ module Category
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-paginate-category
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - midnightSuyama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jekyll-paginate
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ description: Pagination Generator for Jekyll Category
70
+ email:
71
+ - midnightSuyama@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - jekyll-paginate-category.gemspec
82
+ - lib/jekyll-paginate-category.rb
83
+ - lib/jekyll-paginate-category/version.rb
84
+ homepage: https://github.com/midnightSuyama/jekyll-paginate-category
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.4.8
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Pagination Generator for Jekyll Category
108
+ test_files: []