awestructx 0.4.1.x1 → 0.4.1

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.
Files changed (34) hide show
  1. data/lib/awestruct/astruct_mixin.rb +3 -13
  2. data/lib/awestruct/cli/auto.rb +4 -18
  3. data/lib/awestruct/cli/invoker.rb +1 -12
  4. data/lib/awestruct/config.rb +0 -10
  5. data/lib/awestruct/engine.rb +13 -47
  6. data/lib/awestruct/extensions/atomizer.rb +3 -3
  7. data/lib/awestruct/extensions/minify.rb +23 -21
  8. data/lib/awestruct/extensions/posts.rb +4 -4
  9. data/lib/awestruct/extensions/sitemap.rb +0 -1
  10. data/lib/awestruct/handler_chains.rb +33 -15
  11. data/lib/awestruct/handlers/base_handler.rb +1 -16
  12. data/lib/awestruct/handlers/file_handler.rb +1 -3
  13. data/lib/awestruct/handlers/front_matter_handler.rb +0 -5
  14. data/lib/awestruct/handlers/haml_handler.rb +1 -12
  15. data/lib/awestruct/handlers/markdown_handler.rb +0 -14
  16. data/lib/awestruct/handlers/sass_handler.rb +0 -7
  17. data/lib/awestruct/handlers/scss_handler.rb +0 -7
  18. data/lib/awestruct/handlers/textile_handler.rb +0 -15
  19. data/lib/awestruct/page.rb +9 -13
  20. data/lib/awestruct/page_loader.rb +4 -8
  21. data/lib/awestruct/pipeline.rb +0 -7
  22. data/lib/awestruct/version.rb +1 -1
  23. data/lib/guard/awestruct.rb +1 -1
  24. metadata +267 -172
  25. data/lib/awestruct/cli/deploy.rb +0 -38
  26. data/lib/awestruct/dependencies.rb +0 -102
  27. data/lib/awestruct/deploy/github_pages_deploy.rb +0 -61
  28. data/lib/awestruct/deploy/rsync_deploy.rb +0 -51
  29. data/lib/awestruct/deployers.rb +0 -15
  30. data/lib/awestruct/handlers/asciidoc_handler.rb +0 -57
  31. data/lib/awestruct/handlers/coffeescript_handler.rb +0 -48
  32. data/lib/awestruct/handlers/erb_handler.rb +0 -44
  33. data/lib/awestruct/handlers/orgmode_handler.rb +0 -48
  34. data/lib/awestruct/handlers/restructuredtext_handler.rb +0 -67
@@ -1,6 +1,4 @@
1
1
 
2
- require 'awestruct/dependencies'
3
-
4
2
  module Awestruct
5
3
 
6
4
  module AStructMixin
@@ -23,7 +21,7 @@ module Awestruct
23
21
 
24
22
  def [](key)
25
23
  r = super( key ) || super( key.to_sym ) || super( key.to_s )
26
- transform_entry( key, r )
24
+ transform_entry( r )
27
25
  end
28
26
 
29
27
  def method_missing(sym, *args, &blk)
@@ -48,11 +46,8 @@ module Awestruct
48
46
  end
49
47
  end
50
48
 
51
- UNTRACKED_KEYS = [
52
- :url,
53
- ]
54
49
 
55
- def transform_entry(for_key, entry)
50
+ def transform_entry(entry)
56
51
  r = case(entry)
57
52
  when AStructMixin
58
53
  entry
@@ -60,15 +55,10 @@ module Awestruct
60
55
  #AStruct.new( entry )
61
56
  entry.extend( AStructMixin )
62
57
  when Array
63
- entry.map!{|i| transform_entry( for_key, i)}
58
+ entry.map!{|i| transform_entry(i)}
64
59
  else
65
60
  entry
66
61
  end
67
- if ( self.is_a? Awestruct::Page )
68
- unless UNTRACKED_KEYS.include? for_key.to_sym
69
- Awestruct::Dependencies.track_dependency( self )
70
- end
71
- end
72
62
  r
73
63
  end
74
64
 
@@ -4,31 +4,17 @@ module Awestruct
4
4
  module CLI
5
5
  class Auto
6
6
 
7
- def initialize(config)
8
- @config = config
7
+ def initialize(path)
8
+ @path = path
9
9
  end
10
10
 
11
11
  def run()
12
12
  Guard.setup
13
- Guard.start( :guardfile_contents=>guardfile_contents,
14
- :watchdir=>@config.dir,
13
+ Guard.start( :guardfile=>File.dirname(__FILE__) + '/Guardfile',
14
+ :watchdir=>@path,
15
15
  :watch_all_modifications=>true )
16
16
  end
17
17
 
18
- def guardfile_contents
19
- ignored = [
20
- "'.awestruct'",
21
- "'#{File.basename( @config.tmp_dir )}'",
22
- "'#{File.basename( @config.output_dir )}'",
23
- ]
24
- c = ''
25
- c += "guard :awestruct do\n"
26
- c += " watch %r(.*)\n"
27
- c += " ignore_paths #{ignored.join(', ')}"
28
- c += "end\n"
29
- c
30
- end
31
18
  end
32
-
33
19
  end
34
20
  end
@@ -3,7 +3,6 @@ require 'awestruct/cli/options'
3
3
  require 'awestruct/cli/generate'
4
4
  require 'awestruct/cli/auto'
5
5
  require 'awestruct/cli/server'
6
- require 'awestruct/cli/deploy'
7
6
 
8
7
  require 'pathname'
9
8
 
@@ -65,7 +64,6 @@ module Awestruct
65
64
 
66
65
  def setup_config()
67
66
  @config = Awestruct::Config.new( Dir.pwd )
68
- @config.track_dependencies = true if ( options.auto )
69
67
  end
70
68
 
71
69
  def invoke_init()
@@ -75,7 +73,6 @@ module Awestruct
75
73
  end
76
74
 
77
75
  def invoke_force()
78
- FileUtils.rm_rf( File.join( config.dir, '.awestruct', 'dependency-cache' ) )
79
76
  FileUtils.rm_rf( config.output_dir )
80
77
  end
81
78
 
@@ -84,18 +81,10 @@ module Awestruct
84
81
  end
85
82
 
86
83
  def invoke_deploy()
87
- deploy_config = profile[ 'deploy' ]
88
-
89
- if ( deploy_config.nil? )
90
- $stderr.puts "No configuration for 'deploy'"
91
- return
92
- end
93
-
94
- Awestruct::CLI::Deploy.new( config, deploy_config ).run
95
84
  end
96
85
 
97
86
  def invoke_auto()
98
- run_in_thread( Awestruct::CLI::Auto.new( config ) )
87
+ run_in_thread( Awestruct::CLI::Auto.new( config.dir ) )
99
88
  end
100
89
 
101
90
  def invoke_server()
@@ -12,10 +12,6 @@ module Awestruct
12
12
  attr_accessor :skin_dir
13
13
  attr_accessor :tmp_dir
14
14
  attr_accessor :ignore
15
- attr_accessor :track_dependencies
16
-
17
- attr_accessor :images_dir
18
- attr_accessor :stylesheets_dir
19
15
 
20
16
  def initialize(dir = Dir.pwd)
21
17
  @dir = Pathname.new( dir )
@@ -26,13 +22,7 @@ module Awestruct
26
22
  @extension_dir = Pathname.new( File.join(dir, '_ext') )
27
23
  @skin_dir = Pathname.new( File.join(dir, '_skin') )
28
24
  @tmp_dir = Pathname.new( File.join(dir, '_tmp') )
29
-
30
- @images_dir = Pathname.new( File.join(dir, 'images') )
31
- @stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )
32
-
33
25
  @ignore = File.exists?(ignore_file = File.join(dir, ".awestruct_ignore")) ? Dir[*IO.read(ignore_file).each_line.map(&:strip)] : []
34
-
35
- @track_dependencies = false
36
26
  end
37
27
 
38
28
  end
@@ -10,7 +10,6 @@ require 'awestruct/page_loader'
10
10
  require 'awestruct/extensions/pipeline'
11
11
 
12
12
  require 'fileutils'
13
- require 'set'
14
13
 
15
14
  class OpenStruct
16
15
  def inspect
@@ -55,24 +54,9 @@ module Awestruct
55
54
  execute_pipeline
56
55
  configure_compass
57
56
  set_urls( site.pages )
58
- build_page_index
59
57
  generate_output
60
58
  end
61
59
 
62
- def build_page_index
63
- site.pages_by_relative_source_path = {}
64
- site.pages.each do |p|
65
- if ( p.relative_source_path )
66
- site.pages_by_relative_source_path[ p.relative_source_path ] = p
67
- end
68
- end
69
- site.layouts.each do |p|
70
- if ( p.relative_source_path )
71
- site.pages_by_relative_source_path[ p.relative_source_path ] = p
72
- end
73
- end
74
- end
75
-
76
60
  def set_base_url(base_url, default_base_url)
77
61
  if ( base_url )
78
62
  site.base_url = base_url
@@ -208,46 +192,28 @@ module Awestruct
208
192
  if ( page.stale_output?( generated_path ) )
209
193
  generate_page( page, generated_path )
210
194
  else
211
- generate_page( page, generated_path, false )
195
+ puts "Up-to-date: #{generated_path}"
212
196
  end
213
197
  end
214
198
  end
215
199
 
216
- def generate_page(page, generated_path, produce_output=true)
217
- if ( produce_output )
218
- puts "Generating: #{generated_path}"
219
- FileUtils.mkdir_p( File.dirname( generated_path ) )
220
- File.open( generated_path, 'w' ) do |file|
221
- file << page.rendered_content
222
- end
223
- elsif ( site.config.track_dependencies )
224
- if page.dependencies.load!
225
- puts "Cached: #{generated_path}"
226
- else
227
- puts "Analyzing: #{generated_path}"
228
- page.rendered_content
229
- end
200
+ def generate_page(page, generated_path)
201
+ puts "Generating: #{generated_path}"
202
+ FileUtils.mkdir_p( File.dirname( generated_path ) )
203
+ File.open( generated_path, 'w' ) do |file|
204
+ file << page.rendered_content
230
205
  end
231
206
  end
232
207
 
233
208
  def generate_page_by_output_path(path)
234
209
  full_path = File.join( '', path )
235
- page = site.pages.find{|p| p.relative_source_path.to_s==full_path} || site.layouts.find{|p| p.relative_source_path.to_s==full_path}
236
- return if page.nil?
237
-
238
- #puts "regen page #{page.inspect}"
239
- #puts "page.dependents #{page.dependencies.dependents.inspect}"
240
-
241
- regen_pages = Set.new
242
- regen_pages << page unless ( page.output_path.nil? )
243
- regen_pages += page.dependencies.dependents
244
-
245
- #puts regen_pages.collect{|e|e.output_path}.inspect
246
- regen_pages.each do |p|
247
- unless ( p.output_path.nil? || p.__is_layout )
248
- generated_path = File.join( site.config.output_dir, p.output_path )
249
- generate_page( p, generated_path )
250
- end
210
+ #puts "regen path #{full_path}"
211
+ page = site.pages.find{|p| p.relative_source_path.to_s==full_path}
212
+ if ( page.nil? )
213
+ #puts "Unable to locate page for #{path}"
214
+ else
215
+ generated_path = File.join( site.config.output_dir, page.output_path )
216
+ generate_page(page, generated_path)
251
217
  end
252
218
  end
253
219
 
@@ -2,8 +2,8 @@ module Awestruct
2
2
  module Extensions
3
3
  class Atomizer
4
4
 
5
- def initialize(entries, output_path, opts={})
6
- @entries = entries
5
+ def initialize(entries_name, output_path, opts={})
6
+ @entries_name = entries_name
7
7
  @output_path = output_path
8
8
  @num_entries = opts[:num_entries] || 50
9
9
  @content_url = opts[:content_url]
@@ -11,7 +11,7 @@ module Awestruct
11
11
  end
12
12
 
13
13
  def execute(site)
14
- entries = @entries.is_a?(Array) ? @entries : site.send( @entries ) || []
14
+ entries = site.send( @entries_name ) || []
15
15
  unless ( @num_entries == :all )
16
16
  entries = entries[0, @num_entries]
17
17
  end
@@ -12,10 +12,10 @@ require 'fileutils'
12
12
  #
13
13
  # These commands must be available on your PATH in order to use them.
14
14
  #
15
- # This class is loaded as a transformer into the Awestruct pipeline. The
15
+ # This class is loaded as a transformer in the Awestruct pipeline. The
16
16
  # constructor accepts an array of symbols representing the file types to minimize.
17
17
  #
18
- # transformer Awestruct::Extensions::Minify.new
18
+ # extension Awestruct::Extensions::Minify.new
19
19
  #
20
20
  # This transform recognizes the following symbols:
21
21
  #
@@ -57,28 +57,30 @@ module Awestruct
57
57
 
58
58
  def transform(site, page, input)
59
59
  if site.minify
60
- ext = File.extname(page.output_path)
61
- if !ext.empty?
62
- ext_sym = ext[1..-1].to_sym
63
- if @types.include?(ext_sym)
64
- case ext_sym
65
- when :html
66
- print "minifying html #{page.output_path}"
67
- input = htmlcompressor(page, input, site.minify_html_opts)
68
- when :css
69
- print "minifying css #{page.output_path}"
70
- input = yuicompressor(page, input, :css)
71
- when :js
72
- print "minifying js #{page.output_path}"
73
- input = yuicompressor(page, input, :js)
74
- when :png
75
- print "minifying png #{page.output_path}"
76
- input = pngcrush(page, input)
77
- end
60
+ ext = File.extname(page.output_path)[1..-1].to_sym
61
+ if @types.include?(ext)
62
+ case ext
63
+ when :html
64
+ print "minifying html #{page.output_path}"
65
+ htmlcompressor(page, input, site.minify_html_opts)
66
+ when :css
67
+ print "minifying css #{page.output_path}"
68
+ yuicompressor(page, input, :css)
69
+ when :js
70
+ print "minifying js #{page.output_path}"
71
+ yuicompressor(page, input, :js)
72
+ when :png
73
+ print "minifying png #{page.output_path}"
74
+ pngcrush(page, input)
75
+ else
76
+ input
78
77
  end
78
+ else
79
+ input
79
80
  end
81
+ else
82
+ input
80
83
  end
81
- input
82
84
  end
83
85
 
84
86
  private
@@ -27,22 +27,22 @@ module Awestruct
27
27
  date = Time.parse page.date
28
28
  end
29
29
  year = date.year
30
- month = sprintf( "%02d", date.month )
31
- day = sprintf( "%02d", date.day )
30
+ month = date.month
31
+ day = date.day
32
32
  page.date = Time.utc(year, month, day)
33
33
  slug = $1
34
34
  end
35
35
 
36
36
  # if a date was found create a post
37
37
  if( year and month and day)
38
- page.slug ||= slug
38
+ page.slug = slug
39
39
  #context = OpenStruct.new({
40
40
  #:site=>site,
41
41
  #:page=>page,
42
42
  #})
43
43
  context = page.create_context
44
44
  #page.body = page.render( context )
45
- page.output_path = "#{@path_prefix}/#{year}/#{month}/#{day}/#{page.slug}.html"
45
+ page.output_path = "#{@path_prefix}/#{year}/#{month}/#{day}/#{slug}.html"
46
46
  #page.layout = 'post'
47
47
  posts << page
48
48
  end
@@ -33,7 +33,6 @@ module Awestruct
33
33
  page = site.engine.load_page( sitemap )
34
34
  page.output_path = 'sitemap.xml'
35
35
  page.sitemap_entries = sitemap_pages
36
- page.do_not_track_dependencies = true
37
36
 
38
37
  # Add the sitemap to our site
39
38
  site.pages << page
@@ -1,31 +1,49 @@
1
1
  require 'awestruct/handler_chain'
2
2
  require 'awestruct/handlers/file_handler'
3
+ require 'awestruct/handlers/front_matter_handler'
4
+ require 'awestruct/handlers/interpolation_handler'
3
5
  require 'awestruct/handlers/markdown_handler'
4
- require 'awestruct/handlers/orgmode_handler'
5
- require 'awestruct/handlers/asciidoc_handler'
6
- require 'awestruct/handlers/restructuredtext_handler'
7
6
  require 'awestruct/handlers/textile_handler'
8
- require 'awestruct/handlers/erb_handler'
9
7
  require 'awestruct/handlers/haml_handler'
10
8
  require 'awestruct/handlers/sass_handler'
11
9
  require 'awestruct/handlers/scss_handler'
12
- require 'awestruct/handlers/coffeescript_handler'
10
+ require 'awestruct/handlers/layout_handler'
11
+ require 'awestruct/handlers/page_delegating_handler'
13
12
 
14
13
  module Awestruct
15
14
 
16
15
  class HandlerChains
17
16
 
17
+
18
18
  DEFAULTS = [
19
- Awestruct::Handlers::MarkdownHandler::CHAIN,
20
- Awestruct::Handlers::TextileHandler::CHAIN,
21
- Awestruct::Handlers::ErbHandler::CHAIN,
22
- Awestruct::Handlers::OrgmodeHandler::CHAIN,
23
- Awestruct::Handlers::AsciidocHandler::CHAIN,
24
- Awestruct::Handlers::RestructuredtextHandler::CHAIN,
25
- Awestruct::Handlers::HamlHandler::CHAIN,
26
- Awestruct::Handlers::SassHandler::CHAIN,
27
- Awestruct::Handlers::ScssHandler::CHAIN,
28
- Awestruct::Handlers::CoffeescriptHandler::CHAIN,
19
+ HandlerChain.new( /\.md$/,
20
+ Awestruct::Handlers::FileHandler,
21
+ Awestruct::Handlers::FrontMatterHandler,
22
+ Awestruct::Handlers::InterpolationHandler,
23
+ Awestruct::Handlers::MarkdownHandler,
24
+ Awestruct::Handlers::LayoutHandler
25
+ ),
26
+ HandlerChain.new( /\.textile$/,
27
+ Awestruct::Handlers::FileHandler,
28
+ Awestruct::Handlers::FrontMatterHandler,
29
+ Awestruct::Handlers::InterpolationHandler,
30
+ Awestruct::Handlers::TextileHandler,
31
+ Awestruct::Handlers::LayoutHandler
32
+ ),
33
+ HandlerChain.new( /\.haml$/,
34
+ Awestruct::Handlers::FileHandler,
35
+ Awestruct::Handlers::FrontMatterHandler,
36
+ Awestruct::Handlers::HamlHandler,
37
+ Awestruct::Handlers::LayoutHandler
38
+ ),
39
+ HandlerChain.new( /\.sass$/,
40
+ Awestruct::Handlers::FileHandler,
41
+ Awestruct::Handlers::SassHandler
42
+ ),
43
+ HandlerChain.new( /\.scss$/,
44
+ Awestruct::Handlers::FileHandler,
45
+ Awestruct::Handlers::ScssHandler
46
+ ),
29
47
  HandlerChain.new( /.*/, Awestruct::Handlers::FileHandler )
30
48
  ]
31
49
 
@@ -1,6 +1,5 @@
1
1
 
2
2
  require 'hashery/open_cascade'
3
- require 'open3'
4
3
 
5
4
  module Awestruct
6
5
  module Handlers
@@ -83,12 +82,7 @@ module Awestruct
83
82
  end
84
83
 
85
84
  def inherit_front_matter(page)
86
- return @delegate.inherit_front_matter(page) if @delegate
87
- end
88
-
89
- def dependencies
90
- return @delegate.dependencies if @delegate
91
- []
85
+ @delegate.inherit_front_matter(page) if @delegate
92
86
  end
93
87
 
94
88
  def to_chain
@@ -97,15 +91,6 @@ module Awestruct
97
91
  chain.flatten
98
92
  end
99
93
 
100
- def execute_shell(command, input=nil)
101
- Open3.popen3(command) do |stdin, stdout, _|
102
- stdin.puts input unless input.nil?
103
- out = stdout.read
104
- end
105
- rescue Errno::EPIPE
106
- ""
107
- end
108
-
109
94
  end
110
95
  end
111
96
  end