middleman-pagegroups 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation_project/Gemfile +1 -1
- data/documentation_project/config.rb +1 -1
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/10_sibling_one.html.md.erb +7 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/20_sibling_two.html.md.erb +7 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/image.png +7 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/10_nested_sub_01/index.html.md.erb +7 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/index.html.md.erb +7 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_one.html.md.erb +8 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/20_nested_sub_02/sibling_two.html.md.erb +8 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/index.html.md.erb +7 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_one.html.md.erb +8 -0
- data/fixtures/middleman_pagegroups_app/source/30_nested_top/sibling_two.html.md.erb +8 -0
- data/fixtures/middleman_pagegroups_app/source/image.png +7 -0
- data/lib/middleman-pagegroups/extension.rb +45 -12
- data/lib/middleman-pagegroups/version.rb +1 -1
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8ef20a07f682d8227f594c24c1d1598b7c4f477
|
4
|
+
data.tar.gz: 3fbd69ebf368e3e2aa887ec2923b356d9dd8e4f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
12
|
+
gem 'middleman-pagegroups', '~> 1.0.5'
|
13
13
|
gem 'middleman', '~> 4.1.7'
|
14
14
|
gem 'middleman-syntax'
|
15
15
|
|
@@ -113,25 +113,45 @@ class MiddlemanPageGroups < ::Middleman::Extension
|
|
113
113
|
############################################################
|
114
114
|
|
115
115
|
#--------------------------------------------------------
|
116
|
-
# We
|
117
|
-
#
|
118
|
-
#
|
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
|
-
|
123
|
-
|
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
|
126
|
-
|
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
|
-
|
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
|
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 == '.'
|
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
|
+
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-
|
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.
|
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.
|