awestruct 0.2.18 → 0.4.2.x1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/bin/awestruct +2 -274
  2. data/lib/awestruct/astruct.rb +22 -0
  3. data/lib/awestruct/astruct_mixin.rb +81 -0
  4. data/lib/awestruct/cli/auto.rb +34 -0
  5. data/lib/awestruct/cli/deploy.rb +38 -0
  6. data/lib/awestruct/{commands → cli}/generate.rb +3 -3
  7. data/lib/awestruct/cli/invoker.rb +120 -0
  8. data/lib/awestruct/cli/options.rb +116 -0
  9. data/lib/awestruct/{commands → cli}/server.rb +1 -1
  10. data/lib/awestruct/config.rb +20 -8
  11. data/lib/awestruct/context.rb +22 -0
  12. data/lib/awestruct/dependencies.rb +102 -0
  13. data/lib/awestruct/deploy/github_pages_deploy.rb +61 -0
  14. data/lib/awestruct/{commands/deploy.rb → deploy/rsync_deploy.rb} +10 -6
  15. data/lib/awestruct/deployers.rb +15 -0
  16. data/lib/awestruct/engine.rb +172 -411
  17. data/lib/awestruct/extensions/atomizer.rb +7 -4
  18. data/lib/awestruct/extensions/coffeescripttransform.rb +42 -0
  19. data/lib/awestruct/extensions/minify.rb +21 -23
  20. data/lib/awestruct/extensions/paginator.rb +6 -4
  21. data/lib/awestruct/extensions/partial.rb +0 -1
  22. data/lib/awestruct/extensions/pipeline.rb +5 -0
  23. data/lib/awestruct/extensions/posts.rb +11 -9
  24. data/lib/awestruct/extensions/sitemap.rb +2 -1
  25. data/lib/awestruct/extensions/tagger.rb +0 -2
  26. data/lib/awestruct/extensions/template.atom.haml +4 -3
  27. data/lib/awestruct/handler_chain.rb +28 -0
  28. data/lib/awestruct/handler_chains.rb +48 -0
  29. data/lib/awestruct/handlers/asciidoc_handler.rb +57 -0
  30. data/lib/awestruct/handlers/base_handler.rb +111 -0
  31. data/lib/awestruct/handlers/base_sass_handler.rb +42 -0
  32. data/lib/awestruct/handlers/coffeescript_handler.rb +48 -0
  33. data/lib/awestruct/handlers/erb_handler.rb +44 -0
  34. data/lib/awestruct/handlers/file_handler.rb +64 -0
  35. data/lib/awestruct/handlers/front_matter_handler.rb +85 -0
  36. data/lib/awestruct/handlers/haml_handler.rb +54 -0
  37. data/lib/awestruct/handlers/interpolation_handler.rb +28 -0
  38. data/lib/awestruct/handlers/layout_handler.rb +63 -0
  39. data/lib/awestruct/handlers/markdown_handler.rb +50 -0
  40. data/lib/awestruct/handlers/no_op_handler.rb +34 -0
  41. data/lib/awestruct/handlers/orgmode_handler.rb +48 -0
  42. data/lib/awestruct/handlers/page_delegating_handler.rb +54 -0
  43. data/lib/awestruct/handlers/restructuredtext_handler.rb +67 -0
  44. data/lib/awestruct/handlers/sass_handler.rb +21 -0
  45. data/lib/awestruct/handlers/scss_handler.rb +21 -0
  46. data/lib/awestruct/handlers/string_handler.rb +29 -0
  47. data/lib/awestruct/handlers/textile_handler.rb +58 -0
  48. data/lib/awestruct/handlers/yaml_handler.rb +25 -0
  49. data/lib/awestruct/layouts.rb +16 -0
  50. data/lib/awestruct/page.rb +141 -0
  51. data/lib/awestruct/page_loader.rb +82 -0
  52. data/lib/awestruct/pipeline.rb +56 -0
  53. data/lib/awestruct/site.rb +29 -35
  54. data/lib/awestruct/version.rb +1 -1
  55. data/lib/guard/awestruct.rb +38 -0
  56. metadata +115 -88
  57. data/lib/awestruct.rb +0 -2
  58. data/lib/awestruct/asciidoc_file.rb +0 -24
  59. data/lib/awestruct/asciidocable.rb +0 -35
  60. data/lib/awestruct/commands/frameworks/960/base_layout.html.haml +0 -10
  61. data/lib/awestruct/commands/frameworks/base_index.html.haml +0 -5
  62. data/lib/awestruct/commands/frameworks/base_pipeline.rb +0 -6
  63. data/lib/awestruct/commands/frameworks/blueprint/base_layout.html.haml +0 -12
  64. data/lib/awestruct/commands/frameworks/bootstrap/base_index.html.haml +0 -27
  65. data/lib/awestruct/commands/frameworks/bootstrap/base_layout.html.haml +0 -29
  66. data/lib/awestruct/commands/git_hub_pages.rb +0 -55
  67. data/lib/awestruct/commands/init.rb +0 -40
  68. data/lib/awestruct/commands/manifest.rb +0 -205
  69. data/lib/awestruct/erb_file.rb +0 -24
  70. data/lib/awestruct/erbable.rb +0 -19
  71. data/lib/awestruct/front_matter_file.rb +0 -54
  72. data/lib/awestruct/haml/filters/asciidoc.rb +0 -8
  73. data/lib/awestruct/haml_file.rb +0 -27
  74. data/lib/awestruct/hamlable.rb +0 -19
  75. data/lib/awestruct/markdown_file.rb +0 -23
  76. data/lib/awestruct/markdownable.rb +0 -18
  77. data/lib/awestruct/orgmode_file.rb +0 -23
  78. data/lib/awestruct/orgmodeable.rb +0 -15
  79. data/lib/awestruct/renderable.rb +0 -18
  80. data/lib/awestruct/renderable_file.rb +0 -39
  81. data/lib/awestruct/restructuredtext_file.rb +0 -23
  82. data/lib/awestruct/restructuredtextable.rb +0 -38
  83. data/lib/awestruct/sass_file.rb +0 -24
  84. data/lib/awestruct/sassable.rb +0 -33
  85. data/lib/awestruct/scss_file.rb +0 -24
  86. data/lib/awestruct/textilable.rb +0 -22
  87. data/lib/awestruct/textile_file.rb +0 -23
  88. data/lib/awestruct/verbatim_file.rb +0 -12
@@ -1,24 +0,0 @@
1
-
2
- require 'haml'
3
- require 'awestruct/front_matter_file'
4
- require 'awestruct/erbable'
5
-
6
- module Awestruct
7
- class ErbFile < FrontMatterFile
8
-
9
- include Erbable
10
-
11
- def initialize(site, source_path, relative_source_path, options = {})
12
- super(site, source_path, relative_source_path, options)
13
- end
14
-
15
- def output_filename
16
- File.basename( self.source_path, '.erb' )
17
- end
18
-
19
- def output_extension
20
- File.extname( output_filename )
21
- end
22
-
23
- end
24
- end
@@ -1,19 +0,0 @@
1
- require 'sass'
2
-
3
- require 'compass'
4
-
5
- module Awestruct
6
- module Erbable
7
-
8
- def render(context)
9
- erb = ERB.new( raw_page_content )
10
- context.evaluate_erb( erb )
11
- end
12
-
13
- def content
14
- context = site.engine.create_context( self )
15
- render( context )
16
- end
17
-
18
- end
19
- end
@@ -1,54 +0,0 @@
1
- require 'awestruct/renderable_file'
2
-
3
- module Awestruct
4
- class FrontMatterFile < RenderableFile
5
-
6
- attr_reader :raw_page_content
7
- attr_reader :front_matter
8
-
9
- def initialize(site, source_path, relative_source_path, options = {})
10
- super( site, source_path, relative_source_path, options )
11
- @raw_page_content = ''
12
- load_page
13
- end
14
-
15
- protected
16
-
17
- def load_page
18
- full_content = File.read( source_path )
19
- full_content.force_encoding(@site.encoding) if @site.encoding
20
- yaml_content = ''
21
-
22
- dash_lines = 0
23
- mode = :yaml
24
-
25
- full_content.each_line do |line|
26
- if ( line.strip == '---' )
27
- dash_lines = dash_lines +1
28
- end
29
- if ( mode == :yaml )
30
- yaml_content << line
31
- else
32
- @raw_page_content << line
33
- end
34
- if ( dash_lines == 2 )
35
- mode = :page
36
- end
37
- end
38
-
39
- if ( dash_lines == 0 )
40
- @raw_page_content = yaml_content
41
- yaml_content = ''
42
- end
43
-
44
- begin
45
- @front_matter = YAML.load( yaml_content ) || {}
46
- @front_matter.each do |k,v|
47
- self.send( "#{k}=", v )
48
- end
49
- rescue => e
50
- puts "error reading #{self}: #{e}"
51
- end
52
- end
53
- end
54
- end
@@ -1,8 +0,0 @@
1
- module Haml::Filters::AsciiDoc
2
- include Awestruct::AsciiDocable # must come first
3
- include Haml::Filters::Base
4
-
5
- def render_with_options(text, options)
6
- _render(text, options[:relative_source_path], options[:site])
7
- end
8
- end
@@ -1,27 +0,0 @@
1
- require 'haml'
2
- require 'open3'
3
- require 'pathname'
4
- require 'awestruct/front_matter_file'
5
- require 'awestruct/hamlable'
6
- require 'awestruct/asciidocable'
7
- require 'awestruct/haml/filters/asciidoc'
8
-
9
- module Awestruct
10
- class HamlFile < FrontMatterFile
11
-
12
- include Hamlable
13
-
14
- def initialize(site, source_path, relative_source_path, options = {})
15
- super(site, source_path, relative_source_path, options)
16
- end
17
-
18
- def output_filename
19
- File.basename( self.source_path, '.haml' )
20
- end
21
-
22
- def output_extension
23
- File.extname( output_filename )
24
- end
25
-
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- module Awestruct
2
-
3
- module Hamlable
4
- def render(context)
5
- rendered = ''
6
- options = (site.haml || {}).inject({}){|h,(k,v)| h[k.to_sym] = v; h }
7
- options[:relative_source_path] = context.page.relative_source_path
8
- options[:site] = site
9
- haml_engine = Haml::Engine.new( raw_page_content, options )
10
- haml_engine.render( context )
11
- end
12
-
13
- def content
14
- context = site.engine.create_context( self )
15
- render( context )
16
- end
17
- end
18
-
19
- end
@@ -1,23 +0,0 @@
1
-
2
- require 'awestruct/front_matter_file'
3
- require 'awestruct/markdownable'
4
-
5
- module Awestruct
6
- class MarkdownFile < FrontMatterFile
7
-
8
- include Markdownable
9
-
10
- def initialize(site, source_path, relative_source_path, options = {})
11
- super(site, source_path, relative_source_path, options)
12
- end
13
-
14
- def output_filename
15
- File.basename( self.source_path, '.md' ) + output_extension
16
- end
17
-
18
- def output_extension
19
- '.html'
20
- end
21
-
22
- end
23
- end
@@ -1,18 +0,0 @@
1
- require 'rdiscount'
2
-
3
- module Awestruct
4
-
5
- module Markdownable
6
- def render(context)
7
- rendered = ''
8
- doc = RDiscount.new( context.interpolate_string( raw_page_content ) )
9
- doc.to_html
10
- end
11
-
12
- def content
13
- context = site.engine.create_context( self )
14
- render( context )
15
- end
16
- end
17
-
18
- end
@@ -1,23 +0,0 @@
1
- require 'sass'
2
- require 'awestruct/front_matter_file'
3
- require 'awestruct/orgmodeable'
4
-
5
- module Awestruct
6
- class OrgmodeFile < FrontMatterFile
7
-
8
- include Orgmodeable
9
-
10
- def initialize(site, source_path, relative_source_path, options = {})
11
- super( site, source_path, relative_source_path, options )
12
- end
13
-
14
- def output_filename
15
- File.basename( self.source_path, '.org' ) + output_extension
16
- end
17
-
18
- def output_extension
19
- '.html'
20
- end
21
-
22
- end
23
- end
@@ -1,15 +0,0 @@
1
- require 'org-ruby'
2
-
3
- module Awestruct
4
- module Orgmodeable
5
-
6
- def render(context)
7
- Orgmode::Parser.new(raw_page_content).to_html
8
- end
9
-
10
- def output_extension
11
- 'html'
12
- end
13
-
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- require 'ostruct'
2
-
3
- module Awestruct
4
- class Renderable < OpenStruct
5
-
6
- attr_reader :site
7
-
8
- def initialize(site)
9
- super( {} )
10
- @site = site
11
- end
12
-
13
- def render(context)
14
- puts ''
15
- end
16
-
17
- end
18
- end
@@ -1,39 +0,0 @@
1
-
2
- require 'awestruct/renderable'
3
-
4
- module Awestruct
5
- class RenderableFile < Renderable
6
-
7
- def initialize(site, source_path, relative_source_path, options = {})
8
- super( site )
9
- self.source_path = source_path
10
- self.relative_source_path = relative_source_path
11
- self.options = options
12
- unless ( relative_source_path.nil? )
13
- dir_name = File.dirname( relative_source_path )
14
- if ( dir_name == '.' )
15
- self.output_path = output_filename
16
- else
17
- self.output_path = File.join( dir_name, output_filename )
18
- end
19
- end
20
- end
21
-
22
- def raw_page_content
23
- File.read( self.source_path ).tap {|f| f.force_encoding(@site.encoding) if @site.encoding }
24
- end
25
-
26
- def render(context)
27
- raw_page_content
28
- end
29
-
30
- def output_extension
31
- File.extname( self.source_path )
32
- end
33
-
34
- def output_filename
35
- File.basename( self.source_path )
36
- end
37
-
38
- end
39
- end
@@ -1,23 +0,0 @@
1
- require 'open3'
2
- require 'awestruct/front_matter_file'
3
- require 'awestruct/restructuredtextable'
4
-
5
- module Awestruct
6
- class ReStructuredTextFile < FrontMatterFile
7
-
8
- include ReStructuredTextable
9
-
10
- def initialize(site, source_path, relative_source_path, options = {})
11
- super(site, source_path, relative_source_path, options)
12
- end
13
-
14
- def output_filename
15
- File.basename( self.source_path, '.rst' ) + output_extension
16
- end
17
-
18
- def output_extension
19
- '.html'
20
- end
21
-
22
- end
23
- end
@@ -1,38 +0,0 @@
1
- module Awestruct
2
- module ReStructuredTextable
3
-
4
- def render(context)
5
- hl = 1
6
- if front_matter['initial_header_level'].to_s =~ /^[1-6]$/
7
- hl = front_matter['initial_header_level']
8
- end
9
- rendered = ''
10
- begin
11
- doc = execute( "rst2html --strip-comments --no-doc-title --initial-header-level=#{hl}", context.interpolate_string( raw_page_content ) )
12
- rendered = Hpricot( doc ).at( '/html/body/div[@class="document"]' ).inner_html.strip
13
- rescue => e
14
- puts e
15
- puts e.backtrace
16
- end
17
- rendered
18
- end
19
-
20
- def content
21
- context = site.engine.create_context( self )
22
- render( context )
23
- end
24
-
25
- def execute(command, target)
26
- out = ''
27
- Open3.popen3(command) do |stdin, stdout, _|
28
- stdin.puts target
29
- stdin.close
30
- out = stdout.read
31
- end
32
- out.gsub("\r", '')
33
- rescue Errno::EPIPE
34
- ""
35
- end
36
-
37
- end
38
- end
@@ -1,24 +0,0 @@
1
-
2
- require 'sass'
3
- require 'awestruct/renderable_file'
4
- require 'awestruct/sassable'
5
-
6
- module Awestruct
7
- class SassFile < RenderableFile
8
-
9
- include Sassable
10
-
11
- def initialize(site, source_path, relative_source_path, options = {})
12
- super( site, source_path, relative_source_path, options )
13
- end
14
-
15
- def output_filename
16
- File.basename( source_path, '.sass' ) + '.css'
17
- end
18
-
19
- def syntax
20
- :sass
21
- end
22
-
23
- end
24
- end
@@ -1,33 +0,0 @@
1
- require 'sass'
2
- require 'sass/plugin'
3
- require 'compass'
4
-
5
- module Sass::Script::Functions
6
- def site(path)
7
- site = options[:custom]
8
- Sass::Script::String.new(site.send(path.value.to_s).to_s)
9
- end
10
- end
11
-
12
- module Awestruct
13
- module Sassable
14
-
15
- def render(context)
16
- sass_opts = Compass.sass_engine_options
17
- sass_opts[:load_paths] ||= []
18
- Compass::Frameworks::ALL.each do |framework|
19
- sass_opts[:load_paths] << framework.stylesheets_directory
20
- end
21
- sass_opts[:load_paths] << File.dirname( self.source_path )
22
- sass_opts[:syntax] = syntax()
23
- sass_opts[:custom] = site
24
- sass_engine = Sass::Engine.new( raw_page_content, sass_opts )
25
- sass_engine.render
26
- end
27
-
28
- def output_extension
29
- 'css'
30
- end
31
-
32
- end
33
- end
@@ -1,24 +0,0 @@
1
-
2
- require 'sass'
3
- require 'awestruct/renderable_file'
4
- require 'awestruct/sassable'
5
-
6
- module Awestruct
7
- class ScssFile < RenderableFile
8
-
9
- include Sassable
10
-
11
- def initialize(site, source_path, relative_source_path, options = {})
12
- super( site, source_path, relative_source_path, options )
13
- end
14
-
15
- def output_filename
16
- File.basename( source_path, '.scss' ) + '.css'
17
- end
18
-
19
- def syntax
20
- :scss
21
- end
22
-
23
- end
24
- end