middleman-pagegroups 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2ab967e85b659541d08e29ea91d9667788d2a12
4
- data.tar.gz: 199cb402abf8b3f2b96362258fc3b8722b49bd4a
3
+ metadata.gz: d8ef20a07f682d8227f594c24c1d1598b7c4f477
4
+ data.tar.gz: 3fbd69ebf368e3e2aa887ec2923b356d9dd8e4f7
5
5
  SHA512:
6
- metadata.gz: efb3153b5613167ab1c2a8a14184d7bbb987360faf9fa8f2e527e75ee35d6085a8007d08c5ca6e1558fcba90beb221720433db5fc6009c35bb3537c7b5e79b6a
7
- data.tar.gz: 0d409fe0292d57adc99226082aeb2b1fe06f02b817417d5b8e215345e428ed8d1eb8dfae9393ed8526e7b7c53ac200f575549e19da4e2d2afd3c201a7dfb4145
6
+ metadata.gz: b930592b8cb997613561d616b3de433557c4e4fc7299b5bbd51be1bb56e9b68ecf30d777e7cc4fdf21007ea94581952f1b9e49f2e82e78f6869712c278d178eb
7
+ data.tar.gz: aebd3e4e8202f815ca440b956cd3e096045b8dbd402755cf5da79198081b26c05b96d6bfaa16006998c0bece84c1a6b4d9bef12317cd03f3aefd39e61257144e
@@ -9,7 +9,7 @@ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw]
9
9
  gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
10
10
 
11
11
  # Middleman Gems
12
- gem 'middleman-pagegroups', '~> 1.0.4'
12
+ gem 'middleman-pagegroups', '~> 1.0.5'
13
13
  gem 'middleman', '~> 4.1.7'
14
14
  gem 'middleman-syntax'
15
15
 
@@ -86,7 +86,7 @@ helpers do
86
86
  end
87
87
 
88
88
  def product_version
89
- '1.0.4'
89
+ '1.0.5'
90
90
  end
91
91
 
92
92
  end
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: sibling_one
3
+ blurb: This is the sibling_one page.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: sibling_two
3
+ blurb: This is the sibling_two page.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: nested_sub_02 index page
3
+ blurb: This is the index page for the group nested_sub_02.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: nested_sub_01 index page
3
+ blurb: This is the index page for the group nested_sub_01.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: nested_sub_02 index page
3
+ blurb: This is the index page for the group nested_sub_02.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: sibling_one
3
+ blurb: This is the sibling_one page.
4
+ order: 10
5
+ ---
6
+
7
+ #<%= current_page.data.title %>
8
+ <%= current_page.data.blurb %>
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: sibling_two
3
+ blurb: This is the sibling_two page.
4
+ order: 20
5
+ ---
6
+
7
+ #<%= current_page.data.title %>
8
+ <%= current_page.data.blurb %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: nested_top index page
3
+ blurb: This is the index page for the group nested_top.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: sibling_one
3
+ blurb: This is the sibling_one page.
4
+ order: 30
5
+ ---
6
+
7
+ #<%= current_page.data.title %>
8
+ <%= current_page.data.blurb %>
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: sibling_two
3
+ blurb: This is the sibling_two page.
4
+ order: 40
5
+ ---
6
+
7
+ #<%= current_page.data.title %>
8
+ <%= current_page.data.blurb %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: nested_sub_02 index page
3
+ blurb: This is the index page for the group nested_sub_02.
4
+ ---
5
+
6
+ #<%= current_page.data.title %>
7
+ <%= current_page.data.blurb %>
@@ -113,25 +113,45 @@ class MiddlemanPageGroups < ::Middleman::Extension
113
113
  ############################################################
114
114
 
115
115
  #--------------------------------------------------------
116
- # We must ensure that for any directory the index_file
117
- # is first. This is so that we can check it for a page
118
- # order and rename the containing directory in output.
116
+ # We want to handle shallower paths first, and ensure
117
+ # that for any directory the index_file is first. This
118
+ # gives us the ability to rename our directories if the
119
+ # parent directory is to be renamed.
119
120
  # @!visibility private
120
121
  #--------------------------------------------------------
121
122
  def resource_sort_comparator( x, y )
122
- if File.basename(x.path) == app.config[:index_file]
123
- -1
123
+ x_length = Pathname(x.path).each_filename.to_a.count
124
+ x_basename = File.basename(x.path)
125
+ x_dirname = File.dirname(x.path)
126
+ y_length = Pathname(y.path).each_filename.to_a.count
127
+ y_basename = File.basename(y.path)
128
+ y_dirname = File.dirname(y.path)
129
+
130
+ if x_length != y_length
131
+ return x_length <=> y_length
124
132
  else
125
- if File.dirname(x.path) == File.dirname(y.path)
126
- return File.basename(x.path) <=> File.basename(y.path)
133
+ if [x_basename, y_basename].include?(app.config[:index_file])
134
+ # If either is an index file, favor the index file.
135
+ # If both are index files, favor the path.
136
+ if x_basename == y_basename
137
+ return x_basename <=> y_basename
138
+ else
139
+ return x_basename == app.config[:index_file] ? -1 : 1
140
+ end
127
141
  else
128
- return File.dirname(x.path) <=> File.dirname(y.path)
142
+ # If the dir names are the same, favor the basename,
143
+ # otherwise favor the entire path name.
144
+ if x_dirname == y_dirname
145
+ return x_basename <=> y_basename
146
+ else
147
+ return x_dirname <=> y_dirname
148
+ end
129
149
  end
130
150
  end
131
151
  end
132
152
 
133
153
 
134
- #--------------------------------------------------------
154
+ #--------------------------------------------------------
135
155
  # Add our own resource methods to each resource in the
136
156
  # site map.
137
157
  # @!visibility private
@@ -241,7 +261,7 @@ class MiddlemanPageGroups < ::Middleman::Extension
241
261
  return nil
242
262
  else
243
263
  self.siblings
244
- .find_all { |p| p.sort_order != 0 && !p.ignored }
264
+ .find_all { |p| p.sort_order && p.sort_order != 0 && !p.ignored }
245
265
  .push(self)
246
266
  .sort_by { |p| p.sort_order }
247
267
  .find_index(self) + 1
@@ -369,10 +389,10 @@ class MiddlemanPageGroups < ::Middleman::Extension
369
389
  strip = @app.extensions[:MiddlemanPageGroups].options[:strip_file_prefixes]
370
390
  page_name = File.basename(resource.path, '.*')
371
391
  path_part = File.dirname(resource.destination_path)
392
+ file_renamed = false
372
393
 
373
394
  if resource.content_type && resource.content_type.start_with?('text/html', 'application/xhtml')
374
395
 
375
- file_renamed = false
376
396
  # Set the resource's sort order if provided via various means.
377
397
  if resource.data.key?('order')
378
398
  # Priority for ordering goes to the :order front matter key.
@@ -391,11 +411,24 @@ class MiddlemanPageGroups < ::Middleman::Extension
391
411
 
392
412
  # Remove the sort order indicator from the file or directory name.
393
413
  # This will only change the output path for files that have a sort
394
- # order. Other files in a renamed directory that needs to have their
414
+ # order. Other files in a renamed directory that need to have their
395
415
  # paths changed will be changed below.
396
416
  if strip && sort_order
417
+
397
418
  path_parts = path_part.split('/')
419
+
420
+ # Handle preceding path parts, first, if there's a grandparent (all
421
+ # top level items have a parent and aren't part of this case). These
422
+ # will have already been set because we've done shallower paths first.
423
+ if resource.parent.parent
424
+ parent_path_parts = File.dirname(resource.parent.destination_path).split('/')
425
+ path_parts = parent_path_parts + path_parts[parent_path_parts.count..-1]
426
+ end
427
+
428
+ # Handle our immediate directory.
398
429
  path_parts.last.sub!(/^(\d*?)_/, '')
430
+
431
+ # Join up everything and write the correct path.
399
432
  path_part = path_parts.join('/')
400
433
  name_part = page_name.sub( "#{sort_order}_", '') + File.extname( resource.path )
401
434
  if path_part == '.'
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module MiddlemanPageGroups
3
- VERSION = '1.0.4'
3
+ VERSION = '1.0.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-pagegroups
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Derry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-15 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -201,7 +201,18 @@ files:
201
201
  - fixtures/middleman_pagegroups_app/source/20_sub_folder_02/not_legitimate.html.md.erb
202
202
  - fixtures/middleman_pagegroups_app/source/20_sub_folder_02/sibling_one.html.md.erb
203
203
  - fixtures/middleman_pagegroups_app/source/20_sub_folder_02/sibling_two.html.md.erb
204
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/10_sibling_one.html.md.erb
205
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/20_sibling_two.html.md.erb
206
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/image.png
207
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/index.html.md.erb
208
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/index.html.md.erb
209
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_one.html.md.erb
210
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_two.html.md.erb
211
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/index.html.md.erb
212
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_one.html.md.erb
213
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_two.html.md.erb
204
214
  - fixtures/middleman_pagegroups_app/source/_partial.md.erb
215
+ - fixtures/middleman_pagegroups_app/source/image.png
205
216
  - fixtures/middleman_pagegroups_app/source/index.html.md.erb
206
217
  - fixtures/middleman_pagegroups_app/source/layout.erb
207
218
  - fixtures/middleman_pagegroups_app/source/sub_folder_01/10_sibling_one.html.md.erb
@@ -242,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
253
  version: '0'
243
254
  requirements: []
244
255
  rubyforge_project:
245
- rubygems_version: 2.5.1
256
+ rubygems_version: 2.4.8
246
257
  signing_key:
247
258
  specification_version: 4
248
259
  summary: Provides logical page groups and easy navigation for Middleman projects.