middleman-pagegroups 1.0.4 → 1.0.9

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.
Files changed (30) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +4 -0
  3. data/CHANGELOG.md +53 -3
  4. data/README.md +9 -0
  5. data/README_doc.html +5172 -0
  6. data/Rakefile +5 -1
  7. data/documentation_project/Gemfile +2 -2
  8. data/documentation_project/config.rb +5 -1
  9. data/documentation_project/source/partials/_yard_config.erb +12 -12
  10. data/documentation_project/source/partials/_yard_helpers.erb +7 -7
  11. data/documentation_project/source/partials/_yard_helpers_css.erb +10 -10
  12. data/documentation_project/source/partials/_yard_helpers_extended.erb +1 -1
  13. data/documentation_project/source/partials/_yard_resources.erb +59 -13
  14. data/features/helpers_and_resources.feature +1 -1
  15. data/features/support/env.rb +0 -14
  16. data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/10_sibling_one.html.md.erb +7 -0
  17. data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/20_sibling_two.html.md.erb +7 -0
  18. data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/image.png +7 -0
  19. data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/index.html.md.erb +7 -0
  20. data/fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/index.html.md.erb +7 -0
  21. data/fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_one.html.md.erb +8 -0
  22. data/fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_two.html.md.erb +8 -0
  23. data/fixtures/middleman_pagegroups_app/source/30_nested_top/index.html.md.erb +7 -0
  24. data/fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_one.html.md.erb +8 -0
  25. data/fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_two.html.md.erb +8 -0
  26. data/fixtures/middleman_pagegroups_app/source/image.png +7 -0
  27. data/lib/middleman-pagegroups/extension.rb +63 -15
  28. data/lib/middleman-pagegroups/version.rb +1 -1
  29. data/middleman-pagegroups.gemspec +16 -1
  30. metadata +31 -20
@@ -72,7 +72,7 @@ Feature: Provide helpers and resource items to make multiple targets easy to man
72
72
  And the file "index.html" should contain 'current_resource.brethren_next:nil'
73
73
  And the file "index.html" should contain 'current_resource.brethren_previous:nil'
74
74
  And the file "index.html" should contain 'current_resource.group_count:1'
75
- And the file "index.html" should contain 'current_resource.legitimate_children:[#<Middleman::Sitemap::Resource path=sub_folder_01/index.html>, #<Middleman::Sitemap::Resource path=20_sub_folder_02/index.html>]'
75
+ And the file "index.html" should contain 'current_resource.legitimate_children:[#<Middleman::Sitemap::Resource path=sub_folder_01/index.html>, #<Middleman::Sitemap::Resource path=20_sub_folder_02/index.html>, #<Middleman::Sitemap::Resource path=30_nested_top/index.html>]'
76
76
  And the file "index.html" should contain 'current_resource.navigator_eligible:nil'
77
77
  And the file "index.html" should contain 'current_resource.page_group:source'
78
78
  And the file "index.html" should contain 'current_resource.page_name:index'
@@ -4,17 +4,3 @@ ENV['TEST'] = 'true'
4
4
  require 'middleman'
5
5
  require 'middleman-core/step_definitions'
6
6
  require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-pagegroups')
7
-
8
-
9
- require 'cucumber/formatter/pretty'
10
- class QuietFormatter < Cucumber::Formatter::Pretty
11
- def initialize(runtime, io, options)
12
- $stderr = File.new( '/dev/null', 'w' )
13
- super(runtime, io, options)
14
- end
15
-
16
- def after_features(features)
17
- $stderr = STDOUT
18
- super(features)
19
- end
20
- 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 %>
@@ -29,7 +29,7 @@ class MiddlemanPageGroups < ::Middleman::Extension
29
29
  option :nav_toc_index_class, nil, 'Default css class for the nav_toc_index helper/partial.'
30
30
 
31
31
  # @!group Extension Configuration
32
-
32
+
33
33
  # @!attribute [rw] options[:strip_file_prefixes]=
34
34
  # If `true` leading numbers used for sorting files will be removed for
35
35
  # presentation purposes. This makes it possible to neatly organize your
@@ -113,19 +113,39 @@ 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
@@ -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.legitimate? }
245
265
  .push(self)
246
266
  .sort_by { |p| p.sort_order }
247
267
  .find_index(self) + 1
@@ -264,7 +284,7 @@ class MiddlemanPageGroups < ::Middleman::Extension
264
284
  #--------------------------------------------------------
265
285
  def resource.brethren
266
286
  self.siblings
267
- .find_all { |p| p.sort_order && p.sort_order != 0 && !p.ignored && p != self }
287
+ .find_all { |p| p.legitimate? && p != self }
268
288
  .sort_by { |p| p.sort_order }
269
289
  end
270
290
 
@@ -309,7 +329,7 @@ class MiddlemanPageGroups < ::Middleman::Extension
309
329
  # use of `:navigator => false` in its front matter.
310
330
  # * This page has a `sort_order`.
311
331
  #
312
- # @return (Boolean) Returns `true` if this pages is
332
+ # @return (Boolean) Returns `true` if this page is
313
333
  # eligible for a previous/next page control.
314
334
  #--------------------------------------------------------
315
335
  def resource.navigator_eligible?
@@ -320,6 +340,21 @@ class MiddlemanPageGroups < ::Middleman::Extension
320
340
  end
321
341
 
322
342
 
343
+ #--------------------------------------------------------
344
+ # Indicates whether or not a page is "legitimate" in
345
+ # terms of automatic navigation, based in:
346
+ #
347
+ # * The resource has a sort order and isn't zero.
348
+ # * The resource isn't ignored.
349
+ #
350
+ # @return (Boolean) Returns `true` if this pages
351
+ # participates in automatic navigation features.
352
+ #--------------------------------------------------------
353
+ def resource.legitimate?
354
+ self.sort_order && self.sort_order != 0 && !self.ignored
355
+ end
356
+
357
+
323
358
  #--------------------------------------------------------
324
359
  # Returns an array of all of the children of this
325
360
  # resource, taking into account their eligibility for
@@ -336,7 +371,7 @@ class MiddlemanPageGroups < ::Middleman::Extension
336
371
  #--------------------------------------------------------
337
372
  def resource.legitimate_children
338
373
  self.children
339
- .find_all { |p| p.sort_order && p.sort_order != 0 && !p.ignored }
374
+ .find_all { |p| p.legitimate? }
340
375
  .sort_by { |p| p.sort_order }
341
376
  end
342
377
 
@@ -369,10 +404,10 @@ class MiddlemanPageGroups < ::Middleman::Extension
369
404
  strip = @app.extensions[:MiddlemanPageGroups].options[:strip_file_prefixes]
370
405
  page_name = File.basename(resource.path, '.*')
371
406
  path_part = File.dirname(resource.destination_path)
407
+ file_renamed = false
372
408
 
373
409
  if resource.content_type && resource.content_type.start_with?('text/html', 'application/xhtml')
374
410
 
375
- file_renamed = false
376
411
  # Set the resource's sort order if provided via various means.
377
412
  if resource.data.key?('order')
378
413
  # Priority for ordering goes to the :order front matter key.
@@ -391,11 +426,24 @@ class MiddlemanPageGroups < ::Middleman::Extension
391
426
 
392
427
  # Remove the sort order indicator from the file or directory name.
393
428
  # 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
429
+ # order. Other files in a renamed directory that need to have their
395
430
  # paths changed will be changed below.
396
431
  if strip && sort_order
432
+
397
433
  path_parts = path_part.split('/')
434
+
435
+ # Handle preceding path parts, first, if there's a grandparent (all
436
+ # top level items have a parent and aren't part of this case). These
437
+ # will have already been set because we've done shallower paths first.
438
+ if resource.parent && resource.parent.parent
439
+ parent_path_parts = File.dirname(resource.parent.destination_path).split('/')
440
+ path_parts = parent_path_parts + path_parts[parent_path_parts.count..-1]
441
+ end
442
+
443
+ # Handle our immediate directory.
398
444
  path_parts.last.sub!(/^(\d*?)_/, '')
445
+
446
+ # Join up everything and write the correct path.
399
447
  path_part = path_parts.join('/')
400
448
  name_part = page_name.sub( "#{sort_order}_", '') + File.extname( resource.path )
401
449
  if path_part == '.'
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module MiddlemanPageGroups
3
- VERSION = '1.0.4'
3
+ VERSION = '1.0.9'
4
4
  end
5
5
  end
@@ -2,7 +2,22 @@
2
2
  $:.push File.expand_path('../lib', __FILE__)
3
3
  require 'middleman-pagegroups/version'
4
4
 
5
- mm_needed = ['~> 4.1', '>= 4.1.7']
5
+ # We should work with any 4.3.x version of Middleman, but due to #2319,
6
+ # automatic image alt attributes have been removed from Middleman, so
7
+ # I'm adjusting the minimum requirement to the first release incorporating
8
+ # that change.
9
+
10
+ mm_needed = ['~> 4.3.0', '>= 4.3.7']
11
+
12
+ # We should work with any 2.0 version of Ruby, but I'm no longer testing them
13
+ # for regressions. Version 2.6.0 goes back to December 2018, and is a suitable
14
+ # minimum version.
15
+ #
16
+ # Currently no released version of Middleman works with Ruby 3, so until that is
17
+ # resolved, We will only support 2.6 up to and not including Ruby 3.0.
18
+
19
+ rb_needed = ['~> 2.0', '>= 2.6']
20
+
6
21
 
7
22
  Gem::Specification.new do |s|
8
23
  s.name = 'middleman-pagegroups'
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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Derry
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-15 00:00:00.000000000 Z
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -16,60 +16,60 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: 4.3.0
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 4.1.7
22
+ version: 4.3.7
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '4.1'
29
+ version: 4.3.0
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 4.1.7
32
+ version: 4.3.7
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: middleman-cli
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '4.1'
39
+ version: 4.3.0
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 4.1.7
42
+ version: 4.3.7
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '4.1'
49
+ version: 4.3.0
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 4.1.7
52
+ version: 4.3.7
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: middleman
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '4.1'
59
+ version: 4.3.0
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 4.1.7
62
+ version: 4.3.7
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '4.1'
69
+ version: 4.3.0
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 4.1.7
72
+ version: 4.3.7
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: bundler
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -134,12 +134,14 @@ executables:
134
134
  extensions: []
135
135
  extra_rdoc_files: []
136
136
  files:
137
+ - ".gitattributes"
137
138
  - ".gitignore"
138
139
  - ".yardopts"
139
140
  - CHANGELOG.md
140
141
  - Gemfile
141
142
  - LICENSE.md
142
143
  - README.md
144
+ - README_doc.html
143
145
  - Rakefile
144
146
  - bin/middleman-pagegroups
145
147
  - documentation_project/.gitignore
@@ -201,7 +203,18 @@ files:
201
203
  - fixtures/middleman_pagegroups_app/source/20_sub_folder_02/not_legitimate.html.md.erb
202
204
  - fixtures/middleman_pagegroups_app/source/20_sub_folder_02/sibling_one.html.md.erb
203
205
  - fixtures/middleman_pagegroups_app/source/20_sub_folder_02/sibling_two.html.md.erb
206
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/10_sibling_one.html.md.erb
207
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/20_sibling_two.html.md.erb
208
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/image.png
209
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/index.html.md.erb
210
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/index.html.md.erb
211
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_one.html.md.erb
212
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_two.html.md.erb
213
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/index.html.md.erb
214
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_one.html.md.erb
215
+ - fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_two.html.md.erb
204
216
  - fixtures/middleman_pagegroups_app/source/_partial.md.erb
217
+ - fixtures/middleman_pagegroups_app/source/image.png
205
218
  - fixtures/middleman_pagegroups_app/source/index.html.md.erb
206
219
  - fixtures/middleman_pagegroups_app/source/layout.erb
207
220
  - fixtures/middleman_pagegroups_app/source/sub_folder_01/10_sibling_one.html.md.erb
@@ -226,7 +239,7 @@ homepage: https://github.com/middlemac/middleman-pagegroups
226
239
  licenses:
227
240
  - MIT
228
241
  metadata: {}
229
- post_install_message:
242
+ post_install_message:
230
243
  rdoc_options: []
231
244
  require_paths:
232
245
  - lib
@@ -241,12 +254,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
254
  - !ruby/object:Gem::Version
242
255
  version: '0'
243
256
  requirements: []
244
- rubyforge_project:
245
- rubygems_version: 2.5.1
246
- signing_key:
257
+ rubygems_version: 3.1.4
258
+ signing_key:
247
259
  specification_version: 4
248
260
  summary: Provides logical page groups and easy navigation for Middleman projects.
249
261
  test_files:
250
262
  - features/helpers_and_resources.feature
251
263
  - features/support/env.rb
252
- has_rdoc: