awestruct 0.2.3 → 0.2.4
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.
- data/bin/awestruct +29 -4
- data/lib/awestruct/engine.rb +47 -10
- data/lib/awestruct/extensions/data_dir.rb +3 -0
- data/lib/awestruct/extensions/pipeline.rb +7 -1
- data/lib/awestruct/extensions/posts.rb +36 -17
- data/lib/awestruct/extensions/tagger.rb +2 -2
- metadata +21 -7
data/bin/awestruct
CHANGED
@@ -9,6 +9,7 @@ require 'awestruct/commands/generate'
|
|
9
9
|
require 'awestruct/commands/server'
|
10
10
|
require 'awestruct/commands/deploy'
|
11
11
|
require 'yaml'
|
12
|
+
require 'fssm'
|
12
13
|
|
13
14
|
def parse(args)
|
14
15
|
options = OpenStruct.new( {
|
@@ -111,7 +112,7 @@ unless options.init
|
|
111
112
|
@profiles_data[options.profile]
|
112
113
|
else
|
113
114
|
# if no profile given, pick the first with deploy config
|
114
|
-
options.profile, profile_data = @profiles_data.select { |k,v| v['deploy'] }.first
|
115
|
+
options.profile, profile_data = @profiles_data.select { |k,v| v && v['deploy'] }.first
|
115
116
|
profile_data
|
116
117
|
end
|
117
118
|
end
|
@@ -200,10 +201,34 @@ threads = []
|
|
200
201
|
if ( options.auto )
|
201
202
|
threads << Thread.new {
|
202
203
|
generate_cmd = Awestruct::Commands::Generate.new( config, options.profile, options.base_url, default_base_url )
|
203
|
-
|
204
|
-
|
205
|
-
|
204
|
+
|
205
|
+
monitor = FSSM::Monitor.new
|
206
|
+
|
207
|
+
call_generate = lambda do |base, relative|
|
208
|
+
if !(relative =~ /.*~/)
|
209
|
+
puts "Triggered regeneration #{base} #{relative}"
|
210
|
+
generate_cmd.run
|
211
|
+
puts "Done"
|
212
|
+
end
|
206
213
|
end
|
214
|
+
|
215
|
+
Dir.entries(config.input_dir).each do |sub|
|
216
|
+
if !(sub =~ /^(_site|_tmp|\.git|\.gitignore|\.sass-cache|\.|\.\.).*/)
|
217
|
+
if File::directory? File.join(config.input_dir, sub)
|
218
|
+
monitor.path(sub) do
|
219
|
+
update &call_generate
|
220
|
+
create &call_generate
|
221
|
+
end
|
222
|
+
elsif
|
223
|
+
monitor.file(sub) do
|
224
|
+
update &call_generate
|
225
|
+
create &call_generate
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
monitor.run
|
207
232
|
}
|
208
233
|
end
|
209
234
|
|
data/lib/awestruct/engine.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
require 'ostruct'
|
2
3
|
require 'find'
|
3
4
|
require 'compass'
|
@@ -52,7 +53,7 @@ module Awestruct
|
|
52
53
|
@site.engine = self
|
53
54
|
|
54
55
|
@helpers = []
|
55
|
-
@
|
56
|
+
@max_site_mtime = nil
|
56
57
|
end
|
57
58
|
|
58
59
|
def skin_dir
|
@@ -62,7 +63,7 @@ module Awestruct
|
|
62
63
|
def generate(profile=nil, base_url=nil, default_base_url=nil, force=false)
|
63
64
|
@base_url = base_url
|
64
65
|
@default_base_url = default_base_url
|
65
|
-
@
|
66
|
+
@max_site_mtime = nil
|
66
67
|
load_site_yaml(profile)
|
67
68
|
load_yamls
|
68
69
|
set_base_url
|
@@ -132,7 +133,7 @@ module Awestruct
|
|
132
133
|
str = str || ''
|
133
134
|
str = str.gsub( /\\/, '\\\\\\\\' )
|
134
135
|
str = str.gsub( /\\\\#/, '\\#' )
|
135
|
-
str = str.gsub( '@', '\@' )
|
136
|
+
str = str.gsub( '@', '' ) #'\@' )
|
136
137
|
str = "%@#{str}@"
|
137
138
|
result = instance_eval( str )
|
138
139
|
result
|
@@ -212,7 +213,7 @@ module Awestruct
|
|
212
213
|
return true unless File.exist?( generated_path )
|
213
214
|
now = Time.now
|
214
215
|
generated_mtime = File.mtime( generated_path )
|
215
|
-
return true if ( ( @
|
216
|
+
return true if ( ( @max_site_mtime || Time.at(0) ) > generated_mtime )
|
216
217
|
source_mtime = File.mtime( page.source_path )
|
217
218
|
return true if ( source_mtime > generated_mtime ) && ( source_mtime + 1 < now )
|
218
219
|
ext = page.output_extension
|
@@ -276,8 +277,8 @@ module Awestruct
|
|
276
277
|
site_yaml = File.join( config.config_dir, 'site.yml' )
|
277
278
|
if ( File.exist?( site_yaml ) )
|
278
279
|
mtime = File.mtime( site_yaml )
|
279
|
-
if ( mtime > ( @
|
280
|
-
@
|
280
|
+
if ( mtime > ( @max_site_mtime || Time.at(0) ) )
|
281
|
+
@max_site_mtime = mtime
|
281
282
|
end
|
282
283
|
data = YAML.load( File.read( site_yaml ) )
|
283
284
|
site.interpolate = true
|
@@ -304,8 +305,8 @@ module Awestruct
|
|
304
305
|
|
305
306
|
def load_yaml(yaml_path)
|
306
307
|
mtime = File.mtime( yaml_path )
|
307
|
-
if ( mtime > ( @
|
308
|
-
@
|
308
|
+
if ( mtime > ( @max_site_mtime || Time.at(0) ) )
|
309
|
+
@max_site_mtime = mtime
|
309
310
|
end
|
310
311
|
data = YAML.load( File.read( yaml_path ) )
|
311
312
|
name = File.basename( yaml_path, '.yml' )
|
@@ -376,7 +377,7 @@ module Awestruct
|
|
376
377
|
end
|
377
378
|
|
378
379
|
def load_extensions
|
379
|
-
|
380
|
+
watched_dirs = []
|
380
381
|
pipeline = nil
|
381
382
|
skin_pipeline = nil
|
382
383
|
|
@@ -389,6 +390,7 @@ module Awestruct
|
|
389
390
|
pipeline = eval File.read( pipeline_file )
|
390
391
|
@helpers = pipeline.helpers || []
|
391
392
|
@transformers = pipeline.transformers || []
|
393
|
+
watched_dirs << ext_dir.to_s
|
392
394
|
end
|
393
395
|
|
394
396
|
if ( skin_dir )
|
@@ -401,12 +403,47 @@ module Awestruct
|
|
401
403
|
skin_pipeline = eval File.read( skin_pipeline_file )
|
402
404
|
@helpers = ( @helpers + skin_pipeline.helpers || [] ).flatten
|
403
405
|
@transformers = ( @transformers + skin_pipeline.transformers || [] ).flatten
|
406
|
+
watched_dirs << skin_dir.to_s
|
404
407
|
end
|
405
408
|
end
|
406
|
-
|
409
|
+
|
410
|
+
#if _partials directory (from Partial helper) is present, watch
|
411
|
+
partials = File.join( '_partials' )
|
412
|
+
if ( File.exists?( partials ) )
|
413
|
+
watched_dirs << partials
|
414
|
+
end
|
415
|
+
|
416
|
+
pipeline.watch(watched_dirs) if pipeline
|
417
|
+
skin_pipeline.watch(watched_dirs) if skin_pipeline
|
418
|
+
check_dir_for_change(watched_dirs)
|
419
|
+
|
407
420
|
pipeline.execute( site ) if pipeline
|
408
421
|
skin_pipeline.execute( site ) if skin_pipeline
|
409
422
|
end
|
423
|
+
|
424
|
+
def check_dir_for_change(watched_dirs)
|
425
|
+
watched_dirs.each do |dir|
|
426
|
+
Dir.chdir(dir){check_dir_for_change_recursively()}
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def check_dir_for_change_recursively()
|
431
|
+
directories=[]
|
432
|
+
Dir['*'].sort.each do |name|
|
433
|
+
if File.file?(name)
|
434
|
+
mtime = File.mtime(name)
|
435
|
+
if ( mtime > ( @max_site_mtime || Time.at(0) ) )
|
436
|
+
@max_site_mtime = mtime
|
437
|
+
end
|
438
|
+
elsif File.directory?(name)
|
439
|
+
directories << name
|
440
|
+
end
|
441
|
+
end
|
442
|
+
directories.each do |name|
|
443
|
+
#don't descend into . or .. on linux
|
444
|
+
Dir.chdir(name){check_dir_for_change_recursively()} if !Dir.pwd[File.expand_path(name)]
|
445
|
+
end
|
446
|
+
end
|
410
447
|
|
411
448
|
def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
|
412
449
|
if first_letter_in_uppercase
|
@@ -18,6 +18,7 @@ module Awestruct
|
|
18
18
|
|
19
19
|
def extension(ext)
|
20
20
|
@extensions << ext
|
21
|
+
ext.transform(@transformers) if ext.respond_to?('transform')
|
21
22
|
end
|
22
23
|
|
23
24
|
def helper(helper)
|
@@ -33,8 +34,13 @@ module Awestruct
|
|
33
34
|
ext.execute( site )
|
34
35
|
end
|
35
36
|
end
|
37
|
+
|
38
|
+
def watch(watched_dirs)
|
39
|
+
extensions.each do |ext|
|
40
|
+
ext.watch( watched_dirs ) if ext.respond_to?('watch')
|
41
|
+
end
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
end
|
39
46
|
end
|
40
|
-
|
@@ -12,26 +12,45 @@ module Awestruct
|
|
12
12
|
posts = []
|
13
13
|
|
14
14
|
site.pages.each do |page|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
year, month, day, slug = nil
|
16
|
+
|
17
|
+
if ( page.relative_source_path =~ /^#{@path_prefix}\// )
|
18
|
+
if ( page.relative_source_path =~ /^#{@path_prefix}\/(20[01][0-9])-([01][0-9])-([0123][0-9])-([^.]+)\..*$/ )
|
19
|
+
year = $1
|
20
|
+
month = $2
|
21
|
+
day = $3
|
22
|
+
slug = $4
|
23
|
+
page.date = Time.utc( year.to_i, month.to_i, day.to_i )
|
24
|
+
elsif (page.date)
|
25
|
+
page.relative_source_path =~ /^#{@path_prefix}\/(.*)\..*$/
|
26
|
+
date = page.date;
|
27
|
+
if date.kind_of? String
|
28
|
+
date = Time.parse page.date
|
29
|
+
end
|
30
|
+
year = date.year
|
31
|
+
month = date.month
|
32
|
+
day = date.day
|
33
|
+
page.date = Time.utc(year, month, day)
|
34
|
+
slug = $1
|
35
|
+
end
|
36
|
+
|
37
|
+
# if a date was found create a post
|
38
|
+
if( year and month and day)
|
39
|
+
page.slug = slug
|
40
|
+
context = OpenStruct.new({
|
41
|
+
:site=>site,
|
42
|
+
:page=>page,
|
43
|
+
})
|
44
|
+
#page.body = page.render( context )
|
45
|
+
page.output_path = "#{@path_prefix}/#{year}/#{month}/#{day}/#{slug}.html"
|
46
|
+
#page.layout = 'post'
|
47
|
+
posts << page
|
48
|
+
end
|
30
49
|
end
|
31
50
|
end
|
32
51
|
|
33
52
|
posts = posts.sort_by{|each| [each.date, each.sequence || 0, File.mtime( each.source_path ), each.slug ] }.reverse
|
34
|
-
|
53
|
+
|
35
54
|
last = nil
|
36
55
|
singular = @assign_to.to_s.singularize
|
37
56
|
posts.each do |e|
|
@@ -41,7 +60,7 @@ module Awestruct
|
|
41
60
|
end
|
42
61
|
last = e
|
43
62
|
end
|
44
|
-
|
63
|
+
|
45
64
|
site.send( "#{@assign_to}=", posts )
|
46
65
|
end
|
47
66
|
end
|
@@ -60,11 +60,11 @@ module Awestruct
|
|
60
60
|
span = max - min
|
61
61
|
|
62
62
|
if span > 0
|
63
|
-
slice = span / 6
|
63
|
+
slice = span / 6.0
|
64
64
|
ordered_tags.each do |tag|
|
65
65
|
adjusted_size = tag.pages.size - min
|
66
66
|
scaled_size = adjusted_size / slice
|
67
|
-
tag.group = ( tag.pages.size - min ) / slice
|
67
|
+
tag.group = (( tag.pages.size - min ) / slice).ceil
|
68
68
|
end
|
69
69
|
else
|
70
70
|
ordered_tags.each do |tag|
|
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
|
+
- 4
|
9
|
+
version: 0.2.4
|
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: 2011-
|
17
|
+
date: 2011-10-22 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -104,13 +104,13 @@ dependencies:
|
|
104
104
|
prerelease: false
|
105
105
|
requirement: &id007 !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
-
|
112
|
-
-
|
113
|
-
version: 0.
|
111
|
+
- 11
|
112
|
+
- 5
|
113
|
+
version: 0.11.5
|
114
114
|
type: :runtime
|
115
115
|
version_requirements: *id007
|
116
116
|
- !ruby/object:Gem::Dependency
|
@@ -141,6 +141,20 @@ dependencies:
|
|
141
141
|
version: 0.5.3
|
142
142
|
type: :runtime
|
143
143
|
version_requirements: *id009
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: fssm
|
146
|
+
prerelease: false
|
147
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
- 2
|
154
|
+
- 7
|
155
|
+
version: 0.2.7
|
156
|
+
type: :runtime
|
157
|
+
version_requirements: *id010
|
144
158
|
description:
|
145
159
|
email: bob@mcwhirter.org
|
146
160
|
executables:
|