awestruct 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/awestruct +35 -26
- data/lib/awestruct/config.rb +2 -1
- data/lib/awestruct/engine.rb +35 -29
- data/lib/awestruct/extensions/paginator.rb +6 -6
- data/lib/awestruct/site.rb +1 -1
- data/lib/awestruct/version.rb +1 -1
- metadata +3 -3
data/bin/awestruct
CHANGED
@@ -34,7 +34,7 @@ def parse(args)
|
|
34
34
|
options.init = init
|
35
35
|
options.generate = false
|
36
36
|
end
|
37
|
-
opts.on( '-f', '--framework FRAMEWORK', 'Specify a framework during initialization' ) do |framework|
|
37
|
+
opts.on( '-f', '--framework FRAMEWORK', 'Specify a compass framework during initialization (blueprint, 960)' ) do |framework|
|
38
38
|
options.framework = framework
|
39
39
|
end
|
40
40
|
opts.on( '--[no-]scaffold', 'Create scaffolding during initialization (default: true)' ) do |s|
|
@@ -91,6 +91,7 @@ def parse(args)
|
|
91
91
|
opts.on_tail("-v", "--version", "Display the version") do
|
92
92
|
puts "Awestruct: #{Awestruct::VERSION}"
|
93
93
|
puts "http://awestruct.org/"
|
94
|
+
exit
|
94
95
|
end
|
95
96
|
|
96
97
|
|
@@ -212,37 +213,45 @@ if ( options.auto )
|
|
212
213
|
monitor = FSSM::Monitor.new
|
213
214
|
|
214
215
|
call_generate = lambda do |base, relative|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
if relative == '.'
|
220
|
-
# It's necessary to restart the monitor on individual files
|
221
|
-
# after a change is handled
|
222
|
-
monitor.file(base) do
|
223
|
-
update &call_generate
|
224
|
-
create &call_generate
|
225
|
-
end
|
226
|
-
end
|
216
|
+
# Convert to absolute path and append file separator if necessary.
|
217
|
+
base = File::expand_path(base)
|
218
|
+
if base[base.length - 1] != File::SEPARATOR
|
219
|
+
base += File::SEPARATOR
|
227
220
|
end
|
228
|
-
end
|
229
221
|
|
230
|
-
|
231
|
-
if
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
222
|
+
# Filter out bad input just in case.
|
223
|
+
if base.length < config.input_dir.length or config.input_dir != base[0..config.input_dir.length]
|
224
|
+
return
|
225
|
+
end
|
226
|
+
|
227
|
+
path = base + relative
|
228
|
+
path = path[config.input_dir.length..path.length]
|
229
|
+
|
230
|
+
if path =~ /^(_site|_tmp|\.git|\.gitignore|\.sass-cache|\.|\.\.).*/
|
231
|
+
return
|
232
|
+
end
|
233
|
+
if path =~ /.*(~|\.(swp|bak|tmp))$/
|
234
|
+
return
|
235
|
+
end
|
236
|
+
|
237
|
+
puts "Triggered regeneration: #{path}"
|
238
|
+
generate_cmd.run
|
239
|
+
puts "Done"
|
240
|
+
if relative == '.'
|
241
|
+
# It's necessary to restart the monitor on individual files
|
242
|
+
# after a change is handled
|
243
|
+
monitor.file(base) do
|
244
|
+
update &call_generate
|
245
|
+
create &call_generate
|
242
246
|
end
|
243
247
|
end
|
244
248
|
end
|
245
249
|
|
250
|
+
monitor.path(config.input_dir) do
|
251
|
+
update &call_generate
|
252
|
+
create &call_generate
|
253
|
+
end
|
254
|
+
|
246
255
|
monitor.run
|
247
256
|
}
|
248
257
|
end
|
data/lib/awestruct/config.rb
CHANGED
@@ -20,7 +20,8 @@ module Awestruct
|
|
20
20
|
@extension_dir = File.join(dir, '_ext')
|
21
21
|
@skin_dir = File.join(dir, '_skin')
|
22
22
|
@tmp_dir = File.join(dir, '_tmp')
|
23
|
-
@ignore = [
|
23
|
+
@ignore = File.exists?(ignore_file = File.join(dir, ".awestruct_ignore")) ? IO.read(ignore_file).each_line.map(&:strip) : []
|
24
|
+
@ignore = Dir[*@ignore]
|
24
25
|
end
|
25
26
|
|
26
27
|
end
|
data/lib/awestruct/engine.rb
CHANGED
@@ -166,7 +166,7 @@ module Awestruct
|
|
166
166
|
private
|
167
167
|
|
168
168
|
def adjust_load_path
|
169
|
-
ext_dir = File.join( config.extension_dir )
|
169
|
+
ext_dir = File.join( config.extension_dir )
|
170
170
|
if ( $LOAD_PATH.index( ext_dir ).nil? )
|
171
171
|
$LOAD_PATH << ext_dir
|
172
172
|
end
|
@@ -325,7 +325,7 @@ module Awestruct
|
|
325
325
|
|
326
326
|
def load_yamls
|
327
327
|
Dir[ File.join( config.config_dir, '*.yml' ) ].each do |yaml_path|
|
328
|
-
load_yaml( yaml_path ) unless ( File.basename( yaml_path ) == 'site.yml' )
|
328
|
+
load_yaml( yaml_path ) unless ( File.basename( yaml_path ) == 'site.yml' )
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
@@ -350,25 +350,27 @@ module Awestruct
|
|
350
350
|
end
|
351
351
|
|
352
352
|
def load_pages()
|
353
|
-
|
353
|
+
visited_pages = {}
|
354
354
|
dir_pathname = Pathname.new( dir )
|
355
355
|
Find.find( dir ) do |path|
|
356
356
|
next if path == dir
|
357
357
|
basename = File.basename( path )
|
358
358
|
if ( basename == '.htaccess' )
|
359
359
|
#special case
|
360
|
-
elsif (
|
360
|
+
elsif ( basename =~ /^[_.]/ )
|
361
361
|
Find.prune
|
362
362
|
next
|
363
363
|
end
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
364
|
+
file_pathname = Pathname.new( path )
|
365
|
+
relative_path = file_pathname.relative_path_from( dir_pathname ).to_s
|
366
|
+
if config.ignore.include?(relative_path)
|
367
|
+
Find.prune
|
368
|
+
next
|
369
|
+
end
|
370
|
+
page = load_page( path, :relative_path => relative_path )
|
371
|
+
if ( page )
|
372
|
+
inherit_front_matter( page )
|
373
|
+
visited_pages[ path ] = page
|
372
374
|
end
|
373
375
|
end
|
374
376
|
|
@@ -379,21 +381,25 @@ module Awestruct
|
|
379
381
|
basename = File.basename( path )
|
380
382
|
if ( basename == '.htaccess' )
|
381
383
|
#special case
|
382
|
-
elsif (
|
384
|
+
elsif ( basename =~ /^[_.]/ )
|
383
385
|
Find.prune
|
384
386
|
next
|
385
387
|
end
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
388
|
+
file_pathname = Pathname.new( path )
|
389
|
+
relative_path = file_pathname.relative_path_from( skin_dir_pathname ).to_s
|
390
|
+
if config.ignore.include?(relative_path)
|
391
|
+
Find.prune
|
392
|
+
next
|
393
|
+
end
|
394
|
+
page = load_page( path, :relative_path => relative_path )
|
395
|
+
if ( page )
|
396
|
+
inherit_front_matter( page )
|
397
|
+
visited_pages[ path ] = page
|
394
398
|
end
|
395
399
|
end
|
396
400
|
end
|
401
|
+
|
402
|
+
site.pages = visited_pages.values
|
397
403
|
end
|
398
404
|
|
399
405
|
def massage_yaml(obj)
|
@@ -419,43 +425,43 @@ module Awestruct
|
|
419
425
|
pipeline = nil
|
420
426
|
skin_pipeline = nil
|
421
427
|
|
422
|
-
ext_dir = File.join( config.extension_dir )
|
428
|
+
ext_dir = File.join( config.extension_dir )
|
423
429
|
pipeline_file = File.join( ext_dir, 'pipeline.rb' )
|
424
430
|
if ( File.exists?( pipeline_file ) )
|
425
|
-
pipeline = eval
|
431
|
+
pipeline = eval(File.read( pipeline_file ), nil, pipeline_file, 1)
|
426
432
|
@helpers = pipeline.helpers || []
|
427
433
|
@transformers = pipeline.transformers || []
|
428
434
|
watched_dirs << ext_dir.to_s
|
429
435
|
end
|
430
436
|
|
431
437
|
if ( skin_dir )
|
432
|
-
skin_ext_dir = File.join( skin_dir, config.extension_dir )
|
438
|
+
skin_ext_dir = File.join( skin_dir, config.extension_dir.sub(/^#{Dir.pwd}/, "") )
|
433
439
|
if ( $LOAD_PATH.index( skin_ext_dir ).nil? )
|
434
440
|
$LOAD_PATH << skin_ext_dir
|
435
441
|
end
|
436
442
|
skin_pipeline_file = File.join( skin_ext_dir, 'pipeline.rb' )
|
437
443
|
if ( File.exists?( skin_pipeline_file ) )
|
438
|
-
skin_pipeline = eval
|
444
|
+
skin_pipeline = eval(File.read( skin_pipeline_file ), nil, skin_pipeline_file, 1)
|
439
445
|
@helpers = ( @helpers + skin_pipeline.helpers || [] ).flatten
|
440
446
|
@transformers = ( @transformers + skin_pipeline.transformers || [] ).flatten
|
441
447
|
watched_dirs << skin_dir.to_s
|
442
448
|
end
|
443
449
|
end
|
444
|
-
|
450
|
+
|
445
451
|
#if _partials directory (from Partial helper) is present, watch
|
446
452
|
partials = File.join( '_partials' )
|
447
453
|
if ( File.exists?( partials ) )
|
448
454
|
watched_dirs << partials
|
449
455
|
end
|
450
|
-
|
456
|
+
|
451
457
|
pipeline.watch(watched_dirs) if pipeline
|
452
458
|
skin_pipeline.watch(watched_dirs) if skin_pipeline
|
453
459
|
check_dir_for_change(watched_dirs)
|
454
|
-
|
460
|
+
|
455
461
|
pipeline.execute( site ) if pipeline
|
456
462
|
skin_pipeline.execute( site ) if skin_pipeline
|
457
463
|
end
|
458
|
-
|
464
|
+
|
459
465
|
def check_dir_for_change(watched_dirs)
|
460
466
|
watched_dirs.each do |dir|
|
461
467
|
Dir.chdir(dir){check_dir_for_change_recursively()}
|
@@ -52,7 +52,7 @@ module Awestruct
|
|
52
52
|
@window_size = opts[:window_size] || 2
|
53
53
|
@remove_input = opts.has_key?( :remove_input ) ? opts[:remove_input] : true
|
54
54
|
@output_prefix = opts[:output_prefix] || File.dirname( @input_path )
|
55
|
-
@collection = opts[:collection]
|
55
|
+
@collection = opts[:collection]
|
56
56
|
end
|
57
57
|
|
58
58
|
def execute(site)
|
@@ -74,7 +74,7 @@ module Awestruct
|
|
74
74
|
site.pages << page
|
75
75
|
paginated_pages << page
|
76
76
|
i = i + 1
|
77
|
-
end
|
77
|
+
end
|
78
78
|
|
79
79
|
if ( @remove_input )
|
80
80
|
site.pages.reject!{|page|
|
@@ -84,10 +84,10 @@ module Awestruct
|
|
84
84
|
|
85
85
|
prev_page = nil
|
86
86
|
paginated_pages.each_with_index do |page,i|
|
87
|
-
page.
|
88
|
-
page.
|
89
|
-
page.
|
90
|
-
page.
|
87
|
+
page.send( @prop_name ).current_page = page
|
88
|
+
page.send( @prop_name ).current_page_index = i
|
89
|
+
page.send( @prop_name ).pages = paginated_pages
|
90
|
+
page.send( @prop_name ).window = 1
|
91
91
|
|
92
92
|
if ( prev_page != nil )
|
93
93
|
prev_page.send( @prop_name ).next_page = page
|
data/lib/awestruct/site.rb
CHANGED
data/lib/awestruct/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 11
|
9
|
+
version: 0.2.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bob McWhirter
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2012-01-06 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|