middleman-pagegroups 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +18 -0
- data/LICENSE.md +22 -0
- data/README.md +87 -0
- data/Rakefile +10 -0
- data/bin/middleman-pagegroups +108 -0
- data/documentation_project/.gitignore +25 -0
- data/documentation_project/Gemfile +18 -0
- data/documentation_project/README.md +13 -0
- data/documentation_project/config.rb +109 -0
- data/documentation_project/source/documentation/10_concepts.html.md.erb +111 -0
- data/documentation_project/source/documentation/20_directory_organization.html.md.erb +85 -0
- data/documentation_project/source/documentation/30_frontmatter.html.md.erb +70 -0
- data/documentation_project/source/documentation/40_resources.html.md.erb +79 -0
- data/documentation_project/source/documentation/50_helpers.html.md.erb +252 -0
- data/documentation_project/source/documentation/60_sample_partials.html.md.erb +55 -0
- data/documentation_project/source/documentation/70_sample_layouts.html.md.erb +92 -0
- data/documentation_project/source/documentation/80_config.html.md.erb +98 -0
- data/documentation_project/source/documentation/index.html.md.erb +32 -0
- data/documentation_project/source/documentation/ovum.html.md.erb +27 -0
- data/documentation_project/source/fonts/font-awesome/FontAwesome.otf +0 -0
- data/documentation_project/source/fonts/font-awesome/fontawesome-webfont.eot +0 -0
- data/documentation_project/source/fonts/font-awesome/fontawesome-webfont.svg +655 -0
- data/documentation_project/source/fonts/font-awesome/fontawesome-webfont.ttf +0 -0
- data/documentation_project/source/fonts/font-awesome/fontawesome-webfont.woff +0 -0
- data/documentation_project/source/fonts/font-awesome/fontawesome-webfont.woff2 +0 -0
- data/documentation_project/source/images/middleman-pagegroups-small.png +0 -0
- data/documentation_project/source/images/middleman-pagegroups.png +0 -0
- data/documentation_project/source/index.html.md.erb +39 -0
- data/documentation_project/source/javascripts/all.js +1 -0
- data/documentation_project/source/layouts/layout.haml +11 -0
- data/documentation_project/source/layouts/template-logo-large.haml +25 -0
- data/documentation_project/source/layouts/template-logo-medium.haml +26 -0
- data/documentation_project/source/layouts/template-logo-small.haml +26 -0
- data/documentation_project/source/license.html.md.erb +29 -0
- data/documentation_project/source/partials/_nav_breadcrumbs.haml +11 -0
- data/documentation_project/source/partials/_nav_breadcrumbs_alt.haml +15 -0
- data/documentation_project/source/partials/_nav_brethren.haml +18 -0
- data/documentation_project/source/partials/_nav_brethren_index.haml +14 -0
- data/documentation_project/source/partials/_nav_legitimate_children.haml +16 -0
- data/documentation_project/source/partials/_nav_prev_next.haml +21 -0
- data/documentation_project/source/partials/_nav_toc_index.haml +21 -0
- data/documentation_project/source/stylesheets/_github.scss +61 -0
- data/documentation_project/source/stylesheets/_middlemac_minimal.scss +668 -0
- data/documentation_project/source/stylesheets/_normalize.scss +374 -0
- data/documentation_project/source/stylesheets/breadcrumb-separator-light.png +0 -0
- data/documentation_project/source/stylesheets/style.css.scss +3 -0
- data/documentation_project/source/toc.html.md.erb +26 -0
- data/lib/middleman-pagegroups/extension.rb +431 -0
- data/lib/middleman-pagegroups/partials.rb +173 -0
- data/lib/middleman-pagegroups/version.rb +5 -0
- data/lib/middleman-pagegroups.rb +6 -0
- data/middleman-pagegroups.gemspec +26 -0
- metadata +140 -0
@@ -0,0 +1,431 @@
|
|
1
|
+
################################################################################
|
2
|
+
# extension.rb
|
3
|
+
# This file constitutes the framework for the bulk of this extension.
|
4
|
+
################################################################################
|
5
|
+
require 'middleman-core'
|
6
|
+
require 'middleman-pagegroups/partials'
|
7
|
+
|
8
|
+
class MiddlemanPageGroups < ::Middleman::Extension
|
9
|
+
|
10
|
+
|
11
|
+
############################################################
|
12
|
+
# Define the options that are to be set within `config.rb`
|
13
|
+
# as extension options.
|
14
|
+
############################################################
|
15
|
+
option :strip_file_prefixes, true, 'If true leading numbers used for sorting files will be removed for presentation purposes.'
|
16
|
+
option :extend_page_class, true, 'If true then the page_class helper will be extended to include simple group and page_names.'
|
17
|
+
|
18
|
+
option :nav_breadcrumbs_class, nil, 'Default css class for the nav_breadcrumbs helper/partial.'
|
19
|
+
option :nav_breadcrumbs_alt_class, nil, 'Default css class for the nav_breadcrumbs_alt helper/partial.'
|
20
|
+
option :nav_breadcrumbs_alt_label, 'Current page', 'Default "current page" label for the nav_breadcrumbs_alt helper/partial.'
|
21
|
+
option :nav_brethren_class, nil, 'Default css class for the nav_brethren helper/partial.'
|
22
|
+
option :nav_brethren_index_class, nil, 'Default css class for the nav_brethren_index helper/partial.'
|
23
|
+
option :nav_legitimate_children_class, nil, 'Default css class for the nav_legitimate_children helper/partial.'
|
24
|
+
option :nav_prev_next_class, nil, 'Default css class for the nav_prev_next helper/partial.'
|
25
|
+
option :nav_prev_next_label_prev, 'Previous', 'Default "previous" label text for the nav_prev_next helper/partial.'
|
26
|
+
option :nav_prev_next_label_next, 'Next', 'Default "next" label text for the nav_prev_next helper/partial.'
|
27
|
+
option :nav_toc_index_class, nil, 'Default css class for the nav_toc_index helper/partial.'
|
28
|
+
|
29
|
+
|
30
|
+
############################################################
|
31
|
+
# Sitemap manipulators.
|
32
|
+
# Add new methods to each resource.
|
33
|
+
############################################################
|
34
|
+
def manipulate_resource_list(resources)
|
35
|
+
|
36
|
+
resources.each do |resource|
|
37
|
+
|
38
|
+
#--------------------------------------------------------
|
39
|
+
# page_name
|
40
|
+
# Make page_name available for each page. This is the
|
41
|
+
# file base name after any renaming has occurred.
|
42
|
+
# Useful for assigning classes, etc.
|
43
|
+
#--------------------------------------------------------
|
44
|
+
def resource.page_name
|
45
|
+
File.basename( self.destination_path, '.*' )
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
#--------------------------------------------------------
|
50
|
+
# page_group
|
51
|
+
# Make page_group available for each page. This is
|
52
|
+
# the source parent directory (not the request path).
|
53
|
+
# Useful for for assigning classes, and/or group
|
54
|
+
# conditionals.
|
55
|
+
#--------------------------------------------------------
|
56
|
+
def resource.page_group
|
57
|
+
File.basename( File.split( self.source_file )[0] )
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
#--------------------------------------------------------
|
62
|
+
# group_count
|
63
|
+
# Returns the quantity of pages in the current
|
64
|
+
# page’s group. This is NOT the count of the number
|
65
|
+
# of an index page's legitimate children.
|
66
|
+
#--------------------------------------------------------
|
67
|
+
def resource.group_count
|
68
|
+
self.brethren.count + 1
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
#--------------------------------------------------------
|
73
|
+
# sort_order
|
74
|
+
# Returns the page sort order or 0. This is set
|
75
|
+
# initial population of the resource map, and made
|
76
|
+
# available here.
|
77
|
+
#--------------------------------------------------------
|
78
|
+
def resource.sort_order
|
79
|
+
options[:sort_order]
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
#--------------------------------------------------------
|
84
|
+
# page_sequence
|
85
|
+
# Returns the page sequence amongst all of the
|
86
|
+
# brethren. Can be uses as a page number surrogate.
|
87
|
+
# Base 1.
|
88
|
+
#--------------------------------------------------------
|
89
|
+
def resource.page_sequence
|
90
|
+
if self.sort_order == 0
|
91
|
+
return nil
|
92
|
+
else
|
93
|
+
self.siblings
|
94
|
+
.find_all { |p| p.sort_order != 0 && !p.ignored }
|
95
|
+
.push(self)
|
96
|
+
.sort_by { |p| p.sort_order }
|
97
|
+
.find_index(self) + 1
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
#--------------------------------------------------------
|
103
|
+
# brethren
|
104
|
+
# Returns an array of all of the siblings of the
|
105
|
+
# specified page, taking into account their
|
106
|
+
# eligibility for display.
|
107
|
+
# - is not already the current page.
|
108
|
+
# - has a sort_order.
|
109
|
+
# - is not ignored.
|
110
|
+
# Returned array will be:
|
111
|
+
# - sorted by sort_order.
|
112
|
+
#--------------------------------------------------------
|
113
|
+
def resource.brethren
|
114
|
+
self.siblings
|
115
|
+
.find_all { |p| p.sort_order != 0 && !p.ignored && p != self }
|
116
|
+
.sort_by { |p| p.sort_order }
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
#--------------------------------------------------------
|
121
|
+
# brethren_next
|
122
|
+
# Returns the next sibling based on order or nil.
|
123
|
+
#--------------------------------------------------------
|
124
|
+
def resource.brethren_next
|
125
|
+
if self.sort_order == 0
|
126
|
+
return nil
|
127
|
+
else
|
128
|
+
return self.brethren.find { |p| p.sort_order > self.sort_order }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
#--------------------------------------------------------
|
134
|
+
# brethren_previous
|
135
|
+
# Returns the previous sibling based on order or nil.
|
136
|
+
#--------------------------------------------------------
|
137
|
+
def resource.brethren_previous
|
138
|
+
if self.sort_order == 0
|
139
|
+
return nil
|
140
|
+
else
|
141
|
+
return self.brethren.reverse.find { |p| p.sort_order < self.sort_order }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
#--------------------------------------------------------
|
147
|
+
# navigator_eligible?
|
148
|
+
# Determine whether a page is eligible to include a
|
149
|
+
# previous/next page control based on:
|
150
|
+
# - the group is set to allow navigation (:navigate)
|
151
|
+
# - this page is not excluded from navigation. (:navigator => false)
|
152
|
+
# - this page has a sort_order.
|
153
|
+
#--------------------------------------------------------
|
154
|
+
def resource.navigator_eligible?
|
155
|
+
group_navigates = self.parent && self.parent.data['navigate'] == true
|
156
|
+
self_navigates = !( self.data.key?('navigator') && self.data['navigator'] == false )
|
157
|
+
|
158
|
+
group_navigates && self_navigates && self.sort_order != 0
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
#--------------------------------------------------------
|
163
|
+
# legitimate_children
|
164
|
+
# Returns an array of all of the children of the
|
165
|
+
# specified page, taking into account their
|
166
|
+
# eligibility for display.
|
167
|
+
# - has a sort_order.
|
168
|
+
# - is not ignored.
|
169
|
+
# Returned array will be:
|
170
|
+
# - sorted by sort_order.
|
171
|
+
#--------------------------------------------------------
|
172
|
+
def resource.legitimate_children
|
173
|
+
self.children
|
174
|
+
.find_all { |p| p.sort_order !=0 && !p.ignored }
|
175
|
+
.sort_by { |p| p.sort_order }
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
#--------------------------------------------------------
|
180
|
+
# breadcrumbs
|
181
|
+
# Returns an array of pages leading to the current
|
182
|
+
# page.
|
183
|
+
#--------------------------------------------------------
|
184
|
+
def resource.breadcrumbs
|
185
|
+
hierarchy = [] << self
|
186
|
+
hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent
|
187
|
+
hierarchy
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
#========================================================
|
192
|
+
# sort_order and destination_path
|
193
|
+
# Take this opportunity to gather page sort orders
|
194
|
+
# and rename pages so that they don't include sort
|
195
|
+
# order as part of their names.
|
196
|
+
#
|
197
|
+
# Only X/HTML files with an `order` data key, or
|
198
|
+
# with an integer prefix + underscore will be
|
199
|
+
# considered for sort orders.
|
200
|
+
#
|
201
|
+
# If :strip_file_prefixes, then additionally we will
|
202
|
+
# prettify the output page name.
|
203
|
+
#========================================================
|
204
|
+
if resource.content_type && resource.content_type.start_with?('text/html', 'application/xhtml')
|
205
|
+
page_name = File.basename( resource.path, '.*' )
|
206
|
+
if resource.data.key?('order')
|
207
|
+
sort_order = resource.data['order']
|
208
|
+
elsif ( match = /^(\d*?)_/.match(page_name) )
|
209
|
+
sort_order = match[1]
|
210
|
+
if @app.extensions[:MiddlemanPageGroups].options[:strip_file_prefixes]
|
211
|
+
path_part = File.dirname( resource.destination_path )
|
212
|
+
name_part = page_name.sub( "#{sort_order}_", '') + File.extname( resource.path )
|
213
|
+
resource.destination_path = File.join( path_part, name_part )
|
214
|
+
end
|
215
|
+
else
|
216
|
+
sort_order = nil
|
217
|
+
end
|
218
|
+
|
219
|
+
resource.options[:sort_order] = sort_order.to_i
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
end # resources.each
|
224
|
+
|
225
|
+
resources
|
226
|
+
|
227
|
+
end # manipulate_resource_list
|
228
|
+
|
229
|
+
|
230
|
+
############################################################
|
231
|
+
# Helpers
|
232
|
+
# Methods defined in this helpers block are available in
|
233
|
+
# templates.
|
234
|
+
############################################################
|
235
|
+
|
236
|
+
helpers do
|
237
|
+
|
238
|
+
|
239
|
+
#--------------------------------------------------------
|
240
|
+
# page_classes
|
241
|
+
# Extend the built-in page_classes to include the
|
242
|
+
# naked group and page name.
|
243
|
+
#--------------------------------------------------------
|
244
|
+
def page_classes
|
245
|
+
if extensions[:MiddlemanPageGroups].options[:extend_page_class]
|
246
|
+
"#{current_page.page_name} #{current_page.page_group} #{super}"
|
247
|
+
else
|
248
|
+
super
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
#########################################################
|
254
|
+
# partial-like helpers
|
255
|
+
# Let's build these in so the user can choose to use
|
256
|
+
# them instead of installing partials.
|
257
|
+
#########################################################
|
258
|
+
|
259
|
+
#--------------------------------------------------------
|
260
|
+
# nav_breadcrumbs( locals )
|
261
|
+
# Generate the breadcrumbs partial.
|
262
|
+
# locals:
|
263
|
+
# [:klass] == class name for the list's <div>
|
264
|
+
#--------------------------------------------------------
|
265
|
+
def nav_breadcrumbs( locals = {} )
|
266
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
267
|
+
Haml::Engine.new(MMPartials::MM_BREADCRUMBS).render(self, locals)
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
#--------------------------------------------------------
|
272
|
+
# nav_breadcrumbs_alt( locals )
|
273
|
+
# Generate the breadcrumbs partial, alternate form.
|
274
|
+
# locals:
|
275
|
+
# [:klass] == class name for the list's <div>
|
276
|
+
# [:label] == label for "Current page"
|
277
|
+
#--------------------------------------------------------
|
278
|
+
def nav_breadcrumbs_alt( locals = {} )
|
279
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
280
|
+
Haml::Engine.new(MMPartials::MM_BREADCRUMBS_ALT).render(self, locals)
|
281
|
+
end
|
282
|
+
|
283
|
+
#--------------------------------------------------------
|
284
|
+
# nav_brethren( locals )
|
285
|
+
# Generate a fuller list of related topics, including
|
286
|
+
# blurbs if present.
|
287
|
+
# locals:
|
288
|
+
# [:klass] == class name for the list's <div>
|
289
|
+
# [:start] == resource from which to start the list.
|
290
|
+
#--------------------------------------------------------
|
291
|
+
def nav_brethren( locals = {} )
|
292
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
293
|
+
Haml::Engine.new(MMPartials::MM_BRETHREN).render(self, locals)
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
#--------------------------------------------------------
|
298
|
+
# nav_brethren_index( locals )
|
299
|
+
# Generates a condensed list of brethren, omitting
|
300
|
+
# blurbs.
|
301
|
+
# locals:
|
302
|
+
# [:klass] == class name for the list's <div>
|
303
|
+
# [:start] == resource from which to start the list.
|
304
|
+
#--------------------------------------------------------
|
305
|
+
def nav_brethren_index(locals = {})
|
306
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
307
|
+
Haml::Engine.new(MMPartials::MM_BRETHREN_INDEX).render(self, locals)
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
#--------------------------------------------------------
|
312
|
+
# nav_legitimate_children( locals )
|
313
|
+
# Generate a list of legitimate children.
|
314
|
+
# locals:
|
315
|
+
# [:klass] == class name for the list's <div>
|
316
|
+
# [:start] == resource from which to start the list.
|
317
|
+
#--------------------------------------------------------
|
318
|
+
def nav_legitimate_children(locals = {})
|
319
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
320
|
+
Haml::Engine.new(MMPartials::MM_LEGITIMATE_CHILDREN).render(self, locals)
|
321
|
+
end
|
322
|
+
|
323
|
+
|
324
|
+
#--------------------------------------------------------
|
325
|
+
# nav_prev_next( locals )
|
326
|
+
# Generate a previous and next button.
|
327
|
+
# locals:
|
328
|
+
# [:klass] == class name for the list's <div>
|
329
|
+
# [:label_previous] == label for previous button
|
330
|
+
# [:label_next] == label for next button
|
331
|
+
#--------------------------------------------------------
|
332
|
+
def nav_prev_next(locals = {})
|
333
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
334
|
+
Haml::Engine.new(MMPartials::MM_PREV_NEXT).render(self, locals)
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
#--------------------------------------------------------
|
339
|
+
# nav_toc_index( locals )
|
340
|
+
# Generate a nested table of contents.
|
341
|
+
# locals:
|
342
|
+
# [:start] == top-level starting resource.
|
343
|
+
# [:klass] == class name for the list's <div>
|
344
|
+
# Note in this case we're going to not use the haml
|
345
|
+
# template because render won't support the recursion
|
346
|
+
# we need.
|
347
|
+
#--------------------------------------------------------
|
348
|
+
def nav_toc_index( locals = {} )
|
349
|
+
recurse = locals.key?(:recurse) && locals[:recurse]
|
350
|
+
return if recurse && locals[:start].nil?
|
351
|
+
|
352
|
+
commence = locals[:start] || current_page
|
353
|
+
pages = commence.legitimate_children
|
354
|
+
|
355
|
+
if recurse
|
356
|
+
unless pages.to_a.empty?
|
357
|
+
haml_tag :ul do
|
358
|
+
pages.each do |p|
|
359
|
+
haml_tag :li do
|
360
|
+
haml_concat link_to p.data.title, p
|
361
|
+
nav_toc_index :start => p, :recurse => true
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
else
|
367
|
+
capture_haml do
|
368
|
+
locals[:klass] = locals.delete(:class) if locals.key?(:class)
|
369
|
+
haml_tag :ul, :class => (locals.key?(:klass) && locals[:klass]) || nav_toc_index_class do
|
370
|
+
haml_tag :li do
|
371
|
+
haml_concat link_to commence.data.title, commence
|
372
|
+
nav_toc_index :start => commence, :recurse => true
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end # capture_haml
|
376
|
+
end
|
377
|
+
|
378
|
+
end
|
379
|
+
|
380
|
+
|
381
|
+
#########################################################
|
382
|
+
# expose selected defaults
|
383
|
+
# We want our templates to be able to access the
|
384
|
+
# extension options for default settings in partials.
|
385
|
+
#########################################################
|
386
|
+
|
387
|
+
def nav_breadcrumbs_class
|
388
|
+
extensions[:MiddlemanPageGroups].options[:nav_breadcrumbs_class]
|
389
|
+
end
|
390
|
+
|
391
|
+
def nav_breadcrumbs_alt_class
|
392
|
+
extensions[:MiddlemanPageGroups].options[:nav_breadcrumbs_alt_class]
|
393
|
+
end
|
394
|
+
|
395
|
+
def nav_breadcrumbs_alt_label
|
396
|
+
extensions[:MiddlemanPageGroups].options[:nav_breadcrumbs_alt_label]
|
397
|
+
end
|
398
|
+
|
399
|
+
def nav_brethren_class
|
400
|
+
extensions[:MiddlemanPageGroups].options[:nav_brethren_class]
|
401
|
+
end
|
402
|
+
|
403
|
+
def nav_brethren_index_class
|
404
|
+
extensions[:MiddlemanPageGroups].options[:nav_brethren_index_class]
|
405
|
+
end
|
406
|
+
|
407
|
+
def nav_legitimate_children_class
|
408
|
+
extensions[:MiddlemanPageGroups].options[:nav_legitimate_children_class]
|
409
|
+
end
|
410
|
+
|
411
|
+
def nav_prev_next_class
|
412
|
+
extensions[:MiddlemanPageGroups].options[:nav_prev_next_class]
|
413
|
+
end
|
414
|
+
|
415
|
+
def nav_prev_next_label_prev
|
416
|
+
extensions[:MiddlemanPageGroups].options[:nav_prev_next_label_prev]
|
417
|
+
end
|
418
|
+
|
419
|
+
def nav_prev_next_label_next
|
420
|
+
extensions[:MiddlemanPageGroups].options[:nav_prev_next_label_next]
|
421
|
+
end
|
422
|
+
|
423
|
+
def nav_toc_index_class
|
424
|
+
extensions[:MiddlemanPageGroups].options[:nav_breadcrumbs_alt_class]
|
425
|
+
end
|
426
|
+
|
427
|
+
|
428
|
+
end #helpers
|
429
|
+
|
430
|
+
|
431
|
+
end # class MiddlemanPageGroups
|
@@ -0,0 +1,173 @@
|
|
1
|
+
################################################################################
|
2
|
+
# partials
|
3
|
+
# Here's the deal: this is an extension and not an extension+template, so in
|
4
|
+
# order to provide some modicum of usefulness to users, we're providing some
|
5
|
+
# template-like helpers in the extension. This file constitutes the source
|
6
|
+
# for them, with the added benefit that we can recycle the values in the
|
7
|
+
# console application and generate real partial templates for users that
|
8
|
+
# prefer pure MVC.
|
9
|
+
################################################################################
|
10
|
+
|
11
|
+
|
12
|
+
module MMPartials
|
13
|
+
|
14
|
+
MM_BREADCRUMBS = <<HEREDOC
|
15
|
+
- pages = current_page.breadcrumbs
|
16
|
+
- unless pages.to_a.empty?
|
17
|
+
%div{:class => (defined?(klass) && klass) || nav_breadcrumbs_class}
|
18
|
+
%ul
|
19
|
+
- pages.each do |p|
|
20
|
+
%li= link_to p.data.title, p
|
21
|
+
|
22
|
+
-#
|
23
|
+
- This partial renders links into an <ul>.
|
24
|
+
- You probably need a class in order to render this properly.
|
25
|
+
- :klass - pass in this local to specify a class for the containing div.
|
26
|
+
HEREDOC
|
27
|
+
|
28
|
+
|
29
|
+
MM_BREADCRUMBS_ALT = <<HEREDOC
|
30
|
+
- pages = current_page.breadcrumbs
|
31
|
+
- unless pages.to_a.empty?
|
32
|
+
%div{:class => (defined?(klass) && klass) || nav_breadcrumbs_alt_class}
|
33
|
+
%ul
|
34
|
+
- pages[0...pages.count-1].each do |p|
|
35
|
+
%li= link_to p.data.title, p
|
36
|
+
%li= (defined?(label) && label) || nav_breadcrumbs_alt_label
|
37
|
+
|
38
|
+
-#
|
39
|
+
- This partial renders links into an <ul>.
|
40
|
+
- You probably need a class in order to render this properly.
|
41
|
+
- This alternate version replaces the last link with the extension's
|
42
|
+
`nav_breadcrumbs_alt_label` value.
|
43
|
+
- :label - pass in this local instead of using the default.
|
44
|
+
- :klass - pass in this local to specify a class for the containing div.
|
45
|
+
HEREDOC
|
46
|
+
|
47
|
+
|
48
|
+
MM_BRETHREN = <<HEREDOC
|
49
|
+
- commence = (defined?(start) && start) || current_page
|
50
|
+
- pages = commence.brethren
|
51
|
+
- unless pages.to_a.empty?
|
52
|
+
%div{:class => (defined?(klass) && klass) || nav_brethren_class}
|
53
|
+
%dl
|
54
|
+
- pages.each do |p|
|
55
|
+
%dt<
|
56
|
+
= link_to p.data.title, p
|
57
|
+
- if p.data.blurb
|
58
|
+
%dd= p.data.blurb
|
59
|
+
|
60
|
+
-#
|
61
|
+
- This partial renders links with blurbs into a <dl> to serve as
|
62
|
+
a related links table of contents.
|
63
|
+
- You probably need a class in order to render this properly.
|
64
|
+
- For a compact form without blurbs, see also `_nav_brethren_index.haml.
|
65
|
+
- :klass - pass in this local to specify a class for the containing div.
|
66
|
+
- :start - pass in this local to specify a different starting point.
|
67
|
+
HEREDOC
|
68
|
+
|
69
|
+
|
70
|
+
MM_BRETHREN_INDEX =<<HEREDOC
|
71
|
+
- commence = (defined?(start) && start) || current_page
|
72
|
+
- pages = commence.brethren
|
73
|
+
- unless pages.to_a.empty?
|
74
|
+
%div{:class => (defined?(klass) && klass) || nav_brethren_index_class}
|
75
|
+
%ul
|
76
|
+
- pages.each do |p|
|
77
|
+
%li= link_to p.data.title, p
|
78
|
+
|
79
|
+
-#
|
80
|
+
This partial renders brethren into an <ul> to serve as a related-pages type
|
81
|
+
of table of contents.
|
82
|
+
- You probably need a class in order to render this properly.
|
83
|
+
- :klass - pass in this local to specify a class for the containing div.
|
84
|
+
- :start - pass in this local to specify a different starting point.
|
85
|
+
HEREDOC
|
86
|
+
|
87
|
+
|
88
|
+
MM_LEGITIMATE_CHILDREN =<<HEREDOC
|
89
|
+
- commence = (defined?(start) && start) || current_page
|
90
|
+
- pages = commence.legitimate_children
|
91
|
+
- unless pages.to_a.empty?
|
92
|
+
%div{:class => (defined?(klass) && klass) || nav_legitimate_children_class}
|
93
|
+
%dl
|
94
|
+
- pages.each do |p|
|
95
|
+
%dt= link_to p.data.title, p
|
96
|
+
- if p.data.blurb
|
97
|
+
%dd= p.data.blurb
|
98
|
+
|
99
|
+
-#
|
100
|
+
This partial renders links with blurbs into a <dl> to serve as a high-level
|
101
|
+
table of contents.
|
102
|
+
- You probably need a class in order to render this properly.
|
103
|
+
- :klass - pass in this local to specify a class for the containing div.
|
104
|
+
- :start - pass in this local to specify a different starting point.
|
105
|
+
HEREDOC
|
106
|
+
|
107
|
+
|
108
|
+
MM_PREV_NEXT =<<HEREDOC
|
109
|
+
- p_prev = current_page.brethren_previous
|
110
|
+
- p_next = current_page.brethren_next
|
111
|
+
- b_prev = (defined?(label_previous) && label_previous) || nav_prev_next_label_prev
|
112
|
+
- b_next = (defined?(label_next) && label_next) || nav_prev_next_label_next
|
113
|
+
%div{:class => (defined?(klass) && klass) || nav_prev_next_class}
|
114
|
+
- if p_prev.nil?
|
115
|
+
%span= b_prev
|
116
|
+
- else
|
117
|
+
= link_to b_prev, p_prev
|
118
|
+
- if p_next.nil?
|
119
|
+
%span= b_next
|
120
|
+
- else
|
121
|
+
= link_to b_next, p_next
|
122
|
+
|
123
|
+
-#
|
124
|
+
This partial renders a div with two spans that are suitable for use as
|
125
|
+
previous and next buttons when properly styled.
|
126
|
+
- You probably need a class in order to render this properly.
|
127
|
+
- :klass - pass in this local to specify a class for the containing div.
|
128
|
+
- :label_previous - the label for the Previous button. Default is "Previous".
|
129
|
+
- :label_next - the label for the Next button. Default is "Next".
|
130
|
+
HEREDOC
|
131
|
+
|
132
|
+
|
133
|
+
MM_TOC_INDEX = <<HEREDOC
|
134
|
+
- commence = (defined?(start) && start) || current_page
|
135
|
+
- pages = commence.legitimate_children
|
136
|
+
- if defined?(recurse) && recurse
|
137
|
+
- unless pages.to_a.empty?
|
138
|
+
%ul
|
139
|
+
- pages.each do |p|
|
140
|
+
%li<
|
141
|
+
= link_to p.data.title, p
|
142
|
+
= partial 'partials/toc_index', :locals => { :start => p, :recurse => true }
|
143
|
+
- else
|
144
|
+
%ul{:class => (defined?(klass) && klass) || nav_toc_index_class}
|
145
|
+
%li<
|
146
|
+
= link_to commence.data.title, commence
|
147
|
+
= partial 'partials/toc_index', :locals => { :start => commence, :recurse => true }
|
148
|
+
|
149
|
+
-#
|
150
|
+
- This partial renders nested links into an <ul>. The top level item is the
|
151
|
+
start page followed by the entire directory structure below it.
|
152
|
+
- You probably need a class in order to render this properly.
|
153
|
+
- :start - pass in this local to specify the starting page.
|
154
|
+
- :klass - pass in this local to specify a class for the containing div.
|
155
|
+
HEREDOC
|
156
|
+
|
157
|
+
|
158
|
+
#########################################################
|
159
|
+
# MM_PARTIALS
|
160
|
+
# Used by the CLI application to build partial files.
|
161
|
+
#########################################################
|
162
|
+
MM_PARTIALS = [
|
163
|
+
{ :filename => '_nav_breadcrumbs.haml', :content => MM_BREADCRUMBS },
|
164
|
+
{ :filename => '_nav_breadcrumbs_alt.haml', :content => MM_BREADCRUMBS_ALT },
|
165
|
+
{ :filename => '_nav_brethren.haml', :content => MM_BRETHREN },
|
166
|
+
{ :filename => '_nav_brethren_index.haml', :content => MM_BRETHREN_INDEX },
|
167
|
+
{ :filename => '_nav_legitimate_children.haml', :content => MM_LEGITIMATE_CHILDREN },
|
168
|
+
{ :filename => '_nav_prev_next.haml', :content => MM_PREV_NEXT },
|
169
|
+
{ :filename => '_nav_toc_index.haml', :content => MM_TOC_INDEX },
|
170
|
+
]
|
171
|
+
|
172
|
+
|
173
|
+
end # module
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'middleman-pagegroups/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'middleman-pagegroups'
|
7
|
+
s.version = Middleman::MiddlemanPageGroups::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Jim Derry']
|
10
|
+
s.email = ['balthisar@gmail.com']
|
11
|
+
s.homepage = 'https://github.com/middlemac/middleman-pagegroups'
|
12
|
+
s.summary = 'Provides logical page groups and easy navigation for Middleman projects.'
|
13
|
+
s.description = 'Provides logical page groups and easy navigation for Middleman projects.'
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
# The version of middleman-core your extension depends on
|
22
|
+
s.add_runtime_dependency('middleman-core', ['~> 4.1', '>= 4.1.6'])
|
23
|
+
|
24
|
+
# Additional dependencies
|
25
|
+
s.add_runtime_dependency('middleman-cli', ['~> 4.1', '>= 4.1.6'])
|
26
|
+
end
|