awestruct 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ module Awestruct
7
7
  attr_accessor :config_dir
8
8
  attr_accessor :extension_dir
9
9
  attr_accessor :output_dir
10
+ attr_accessor :skin_dir
10
11
  attr_accessor :ignore
11
12
 
12
13
  def initialize()
@@ -14,6 +15,7 @@ module Awestruct
14
15
  @config_dir = '_config'
15
16
  @output_dir = '_site'
16
17
  @extension_dir = '_ext'
18
+ @skin_dir = '_skin'
17
19
  @ignore = [ ]
18
20
  end
19
21
 
@@ -27,6 +27,7 @@ require 'awestruct/extensions/tagger'
27
27
  require 'awestruct/extensions/tag_cloud'
28
28
  require 'awestruct/extensions/intense_debate'
29
29
  require 'awestruct/extensions/google_analytics'
30
+ require 'awestruct/extensions/partial'
30
31
 
31
32
  require 'awestruct/util/inflector'
32
33
  require 'awestruct/util/default_inflections'
@@ -51,6 +52,10 @@ module Awestruct
51
52
  @max_yaml_mtime = nil
52
53
  end
53
54
 
55
+ def skin_dir
56
+ @site.skin_dir
57
+ end
58
+
54
59
  def generate(profile=nil, base_url=nil, default_base_url=nil, force=false)
55
60
  @base_url = base_url
56
61
  @default_base_url = default_base_url
@@ -235,9 +240,19 @@ module Awestruct
235
240
  layout_pathname = Pathname.new( layout_path )
236
241
  relative_path = layout_pathname.relative_path_from( dir_pathname ).to_s
237
242
  name = File.basename( layout_path, '.haml' )
238
- #site.layouts[ name ] = HamlFile.new( site, layout_path, relative_path )
239
243
  site.layouts[ name ] = load_page( layout_path, relative_path )
240
244
  end
245
+ if ( skin_dir )
246
+ skin_dir_pathname = Pathname.new( skin_dir )
247
+ Dir[ File.join( skin_dir, config.layouts_dir, '*.haml' ) ].each do |layout_path|
248
+ layout_pathname = Pathname.new( layout_path )
249
+ relative_path = layout_pathname.relative_path_from( skin_dir_pathname ).to_s
250
+ name = File.basename( layout_path, '.haml' )
251
+ unless ( site.layouts.key?( name ) )
252
+ site.layouts[ name ] = load_page( layout_path, relative_path )
253
+ end
254
+ end
255
+ end
241
256
  end
242
257
 
243
258
  def load_site_yaml(profile)
@@ -280,8 +295,8 @@ module Awestruct
280
295
  end
281
296
 
282
297
  def load_pages()
283
- dir_pathname = Pathname.new( dir )
284
298
  site.pages.clear
299
+ dir_pathname = Pathname.new( dir )
285
300
  Find.find( dir ) do |path|
286
301
  next if path == dir
287
302
  basename = File.basename( path )
@@ -300,6 +315,28 @@ module Awestruct
300
315
  end
301
316
  end
302
317
  end
318
+
319
+ if ( skin_dir )
320
+ skin_dir_pathname = Pathname( skin_dir )
321
+ Find.find( skin_dir ) do |path|
322
+ next if path == skin_dir
323
+ basename = File.basename( path )
324
+ if ( basename == '.htaccess' )
325
+ #special case
326
+ elsif ( config.ignore.include?( basename ) || ( basename =~ /^[_.]/ ) )
327
+ Find.prune
328
+ next
329
+ end
330
+ unless ( site.has_page?( path ) )
331
+ file_pathname = Pathname.new( path )
332
+ relative_path = file_pathname.relative_path_from( skin_dir_pathname ).to_s
333
+ page = load_page( path, relative_path )
334
+ if ( page )
335
+ site.pages << page
336
+ end
337
+ end
338
+ end
339
+ end
303
340
  end
304
341
 
305
342
  def massage_yaml(obj)
@@ -321,14 +358,34 @@ module Awestruct
321
358
  end
322
359
 
323
360
  def load_extensions
361
+
362
+ pipeline = nil
363
+ skin_pipeline = nil
364
+
324
365
  ext_dir = File.join( dir, config.extension_dir )
325
- pipeline_file = File.join( ext_dir, 'pipeline.rb' )
326
366
  if ( $LOAD_PATH.index( ext_dir ).nil? )
327
367
  $LOAD_PATH << ext_dir
328
368
  end
329
- pipeline = eval File.read( pipeline_file )
330
- pipeline.execute( site )
331
- @helpers = pipeline.helpers || []
369
+ pipeline_file = File.join( ext_dir, 'pipeline.rb' )
370
+ if ( File.exists?( pipeline_file ) )
371
+ pipeline = eval File.read( pipeline_file )
372
+ @helpers = pipeline.helpers || []
373
+ end
374
+
375
+ if ( skin_dir )
376
+ skin_ext_dir = File.join( skin_dir, config.extension_dir )
377
+ if ( $LOAD_PATH.index( skin_ext_dir ).nil? )
378
+ $LOAD_PATH << skin_ext_dir
379
+ end
380
+ skin_pipeline_file = File.join( skin_ext_dir, 'pipeline.rb' )
381
+ if ( File.exists?( skin_pipeline_file ) )
382
+ skin_pipeline = eval File.read( skin_pipeline_file )
383
+ @helpers = skin_pipeline.helpers || []
384
+ end
385
+ end
386
+
387
+ pipeline.execute( site ) if pipeline
388
+ skin_pipeline.execute( site ) if skin_pipeline
332
389
  end
333
390
 
334
391
  def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
@@ -0,0 +1,14 @@
1
+
2
+ module Awestruct
3
+ module Extensions
4
+ module Partial
5
+
6
+ def partial(path)
7
+ page = site.engine.load_site_page( File.join( '_partials', path ) )
8
+ page.content if ( page )
9
+ end
10
+
11
+ end
12
+ end
13
+
14
+ end
@@ -3,7 +3,9 @@ module Awestruct
3
3
 
4
4
  class Pipeline
5
5
 
6
+ attr_reader :before_extensions
6
7
  attr_reader :extensions
8
+ attr_reader :after_extensions
7
9
  attr_reader :helpers
8
10
 
9
11
  def initialize(&block)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awestruct
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bob McWhirter
@@ -143,6 +143,7 @@ files:
143
143
  - lib/awestruct/extensions/indexifier.rb
144
144
  - lib/awestruct/extensions/intense_debate.rb
145
145
  - lib/awestruct/extensions/paginator.rb
146
+ - lib/awestruct/extensions/partial.rb
146
147
  - lib/awestruct/extensions/pipeline.rb
147
148
  - lib/awestruct/extensions/posts.rb
148
149
  - lib/awestruct/extensions/tag_cloud.rb