middleman-paginate 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbd7fc48c530af4d135112ba45e0c4cc8ec8ac82
4
- data.tar.gz: 38c07ed4b13d45e3d64a14903135c1a95959070b
3
+ metadata.gz: a4f42ba72811499edf5dcc6dcf40c3dc1001841a
4
+ data.tar.gz: 8961f41b248d0010d2e90edcbf518af32a36868d
5
5
  SHA512:
6
- metadata.gz: a32e1ccc5e149ef826a71b5e452b708e29c90c0c925547b6a56afed8e533ac3c51a755c398c213f511999db208fe594dcd2120ffad6b14a7d8ed10607d19383a
7
- data.tar.gz: 27fc100643959c0d43c3053c3a6abb581cc6f6ae6c211d33f62a6608a3c8482ea41a192512eaa492af535e9396ed46647e7d3d0eeb1a2e701f98ced384d1c84c
6
+ metadata.gz: 8fff4c9e592e54843eac4534874e9a88bfb7135d0abdab31efafae3853b3209938079467d56faea916382e226662548ce942c378fe61d2a9beeac4b7c198364a
7
+ data.tar.gz: 6b36f5690d13600e4eb3616f99db241ebd78ee9ba0e4f84bb561bbb3bcf96575445da422c81c26123120936fcae7574ef3907cc6410f4e5854a486ce9322069b
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Middleman::Paginate
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/middleman/paginate`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -25,7 +21,7 @@ Or install it yourself as:
25
21
  Consider that middleman-paginate creates a page for each set of data sliced from your collection. This page is created by a template. In your config.rb
26
22
 
27
23
  ```ruby
28
- paginate data.your_collection, "/episodes", "/templates/episodes.html"
24
+ paginate data.your_collection, "/episodes", "/templates/episodes.html", suffix: "/page/:num/index", per_page: 20
29
25
  ```
30
26
 
31
27
  in your pagination template you'll find a collection named `items` with the objects for the specific page:
@@ -47,7 +43,7 @@ You also have an object `pager` that offers some helpers to build the pagination
47
43
  The final URLs will be:
48
44
 
49
45
  ```
50
- http://127.0.0.1:4567/episodes.html
46
+ http://127.0.0.1:4567/episodes/index.html
51
47
  http://127.0.0.1:4567/episodes/page/2.html
52
48
  http://127.0.0.1:4567/episodes/page/3.html
53
49
  ```
@@ -34,12 +34,21 @@ module Middleman
34
34
  current_page > 1 && current_page - 1
35
35
  end
36
36
 
37
- def page_path(page = current_page)
37
+ def full_page_path(page = current_page)
38
38
  "#{@base_path}#{page == 1 ? '/index' : @suffix.gsub(/:num/, page.to_s)}.html"
39
39
  end
40
+
41
+ def page_path(page = current_page)
42
+ full_path = full_page_path(page)
43
+ if full_path.end_with?("/index.html")
44
+ full_path.gsub(/index\.html$/, '')
45
+ else
46
+ full_path
47
+ end
48
+ end
40
49
  end
41
50
 
42
- def paginate(collection, base_path, template, per_page: 20, suffix: "/page/:num", locals: {}, data: {})
51
+ def paginate(collection, base_path, template, per_page: 20, suffix: "/page/:num/index", locals: {}, data: {})
43
52
  pages = collection.each_slice(per_page).to_a
44
53
  descriptors = []
45
54
 
@@ -52,7 +61,7 @@ module Middleman
52
61
  }
53
62
 
54
63
  descriptors << Middleman::Sitemap::Extensions::ProxyDescriptor.new(
55
- Middleman::Util.normalize_path(pager.page_path),
64
+ Middleman::Util.normalize_path(pager.full_page_path),
56
65
  Middleman::Util.normalize_path(template),
57
66
  opts.dup
58
67
  )
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Paginate
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-01 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,4 +113,3 @@ signing_key:
113
113
  specification_version: 4
114
114
  summary: A simple helper to generate custom paginated content with Middleman
115
115
  test_files: []
116
- has_rdoc: