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,38 +0,0 @@
1
- require 'awestruct/deploy/rsync_deploy'
2
- require 'awestruct/deploy/github_pages_deploy'
3
-
4
- module Awestruct
5
- module CLI
6
-
7
- class Deploy
8
-
9
- attr_accessor :site_config
10
- attr_accessor :deploy_config
11
-
12
- def initialize(site_config, deploy_config)
13
- @site_config = site_config
14
- @deploy_config = deploy_config
15
- end
16
-
17
- def run()
18
- deploy_type = :rsync
19
-
20
- if ( deploy_config['host'] == 'github_pages' )
21
- deploy_type = :github_pages
22
- end
23
-
24
- deployer_class = Awestruct::Deployers.instance[ deploy_type ]
25
-
26
- if ( deployer_class.nil? )
27
- $stderr.puts "Unable to locate correct deployer for #{deploy_type}"
28
- return
29
- end
30
-
31
- deployer = deployer_class.new( site_config, deploy_config )
32
- deployer.run
33
-
34
- end
35
- end
36
-
37
- end
38
- end
@@ -1,102 +0,0 @@
1
-
2
- module Awestruct
3
- class Dependencies
4
-
5
- attr_reader :page
6
- attr_reader :dependencies
7
- attr_reader :dependents
8
-
9
-
10
- def self.top_page
11
- @pages ||= []
12
- @pages.first
13
- end
14
-
15
- def self.push_page(page)
16
- if ( top_page.nil? )
17
- page.dependencies.clear
18
- else
19
- top_page.dependencies.add_dependency( page )
20
- end
21
- @pages.push( page )
22
- end
23
-
24
- def self.pop_page
25
- page = @pages.pop
26
- if ( @pages.empty? && ! page.nil? )
27
- page.dependencies.persist!
28
- end
29
- end
30
-
31
-
32
- def self.track_dependency(dep)
33
- return if top_page.nil?
34
- return if top_page == dep
35
- top_page.dependencies.add_dependency(dep)
36
- end
37
-
38
- def initialize(page)
39
- @page = page
40
- @dependencies = Set.new
41
- @dependents = Set.new
42
- end
43
-
44
- def <<(dep)
45
- add_dependency( dep )
46
- end
47
-
48
- def add_dependency(dep)
49
- return if @page.do_not_track_dependencies
50
- return if @page.output_path.nil?
51
- return if dep == @page
52
- @dependencies << dep
53
- dep.dependencies.add_dependent( page )
54
- end
55
-
56
- def add_dependent(dep)
57
- @dependents << dep
58
- end
59
-
60
- def remove_dependent(dep)
61
- @dependents.delete( dep )
62
- end
63
-
64
- def clear
65
- @dependencies.clear
66
- @dependents.each{|d| d.remove_dependent( page ) }
67
- end
68
-
69
- def persist!
70
- return if page.output_path.nil? || page.output_path == ''
71
- file = File.join( @page.site.config.dir, '.awestruct', 'dependency-cache', page.output_path )
72
- FileUtils.mkdir_p( File.dirname( file ) )
73
- File.open( file, 'w' ) do |file|
74
- @dependencies.collect{|e| e.relative_source_path }.uniq.each do |d|
75
- file.puts d unless d.nil?
76
- end
77
- end
78
- end
79
-
80
- def load!
81
- return if page.output_path.nil? || page.output_path == ''
82
- file = File.join( @page.site.config.dir, '.awestruct', 'dependency-cache', page.output_path )
83
- #puts "load #{file}"
84
- if ( File.exist?( file ) )
85
- File.open( file, 'r' ) do |file|
86
- file.lines.each do |line|
87
- d = find_page_by_path( line.strip )
88
- add_dependency( d ) unless d.nil?
89
- end
90
- end
91
- return true
92
- end
93
- false
94
- end
95
-
96
- def find_page_by_path(path)
97
- page.site.pages_by_relative_source_path[ path ]
98
- end
99
-
100
-
101
- end
102
- end
@@ -1,61 +0,0 @@
1
- require 'awestruct/deployers'
2
-
3
- module Awestruct
4
- module Deploy
5
-
6
- class GitHubPagesDeploy
7
- def initialize( site_config, deploy_config )
8
- @site_path = site_config.output_dir
9
- @branch = deploy_config[ 'branch' ] || 'gh-pages'
10
- end
11
-
12
- def run
13
- git.status.changed.empty? ? publish_site : message_for(:existing_changes)
14
- end
15
-
16
- private
17
- def git
18
- @git ||= Git.open('.')
19
- end
20
-
21
- def publish_site
22
- current_branch = git.branch
23
- checkout_pages_branch
24
- add_and_commit_site @site_path
25
- push_and_restore current_branch
26
- end
27
-
28
- def checkout_pages_branch
29
- git.branch( @branch ).checkout
30
- end
31
-
32
- def add_and_commit_site( path )
33
- git.with_working( path ) do
34
- git.add(".")
35
- begin
36
- git.commit("Published #{@branch} to GitHub pages.")
37
- rescue Git::GitExecuteError => e
38
- $stderr.puts "Can't commit. #{e}."
39
- end
40
- end
41
- end
42
-
43
- def push_and_restore( original_branch )
44
- git.reset_hard
45
- git.push( 'origin', @branch )
46
- git.checkout( original_branch )
47
- end
48
-
49
- def message_for( key )
50
- $stderr.puts case key
51
- when :existing_changes
52
- "You have uncommitted changes in the working branch. Please commit or stash them."
53
- else
54
- "An error occured."
55
- end
56
- end
57
- end
58
- end
59
- end
60
-
61
- Awestruct::Deployers.instance[ :github_pages ] = Awestruct::Deploy::GitHubPagesDeploy
@@ -1,51 +0,0 @@
1
- require 'awestruct/deployers'
2
-
3
- require 'open3'
4
-
5
- module Awestruct
6
- module Deploy
7
- class RSyncDeploy
8
-
9
- def initialize(site_config, deploy_config)
10
- @site_path = File.join( site_config.output_dir, '/' )
11
- @host = deploy_config['host']
12
- @path = File.join( deploy_config['path'], '/' )
13
- end
14
-
15
- def run
16
- cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+s,ug+w --delete #{@site_path} #{@host}:#{@path}"
17
- Open3.popen3( cmd ) do |stdin, stdout, stderr|
18
- stdin.close
19
- threads = []
20
- threads << Thread.new(stdout) do |i|
21
- while ( ! i.eof? )
22
- line = i.readline
23
- case line[0,9]
24
- when '<f.sT....'
25
- puts " updating #{line[10..-1]}"
26
- when 'cd+++++++'
27
- puts " creating #{line[10..-1]}"
28
- when '<f+++++++'
29
- puts " adding #{line[10..-1]}"
30
- when '<f..T....'
31
- # ignoring unchanged files
32
- # puts " no change to #{line[10..-1]}"
33
- else
34
- puts line
35
- end
36
- end
37
- end
38
- threads << Thread.new(stderr) do |i|
39
- while ( ! i.eof? )
40
- line = i.readline
41
- puts line
42
- end
43
- end
44
- threads.each{|t|t.join}
45
- end
46
- end
47
- end
48
- end
49
- end
50
-
51
- Awestruct::Deployers.instance[ :rsync ] = Awestruct::Deploy::RSyncDeploy
@@ -1,15 +0,0 @@
1
-
2
- module Awestruct
3
-
4
- class Deployers < Hash
5
- def self.instance
6
- @instance ||= Deployers.new
7
- end
8
-
9
- def self.register( key, cls )
10
- Deployers.instance[ key.to_sym ] = cls
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,57 +0,0 @@
1
-
2
- require 'awestruct/handler_chain'
3
- require 'awestruct/handlers/base_handler'
4
- require 'awestruct/handlers/file_handler'
5
- require 'awestruct/handlers/front_matter_handler'
6
- require 'awestruct/handlers/interpolation_handler'
7
- require 'awestruct/handlers/layout_handler'
8
-
9
- module Awestruct
10
- module Handlers
11
- class AsciidocHandler < BaseHandler
12
-
13
- CHAIN = Awestruct::HandlerChain.new( /\.(adoc|asciidoc)$/,
14
- Awestruct::Handlers::FileHandler,
15
- Awestruct::Handlers::FrontMatterHandler,
16
- Awestruct::Handlers::InterpolationHandler,
17
- Awestruct::Handlers::AsciidocHandler,
18
- Awestruct::Handlers::LayoutHandler
19
- )
20
-
21
- def initialize(site, delegate)
22
- super( site, delegate )
23
- end
24
-
25
- def simple_name
26
- p = File.basename( relative_source_path )
27
- File.basename( p, File.extname( p ) )
28
- end
29
-
30
- def output_filename
31
- simple_name + output_extension
32
- end
33
-
34
- def output_extension
35
- '.html'
36
- end
37
-
38
- def content_syntax
39
- :asciidoc
40
- end
41
-
42
- def rendered_content(context, with_layouts=true)
43
- content = delegate.rendered_content( context, with_layouts )
44
- imagesdir = site.config.images_dir
45
- iconsdir = File.join(imagesdir, 'icons')
46
- conffile = File.join(site.config.config_dir, 'asciidoc.conf')
47
- confopt = File.exist?(conffile) ? '-f ' + conffile : ''
48
- content = execute_shell( [ "asciidoc -s -b html5 -a pygments -a icons",
49
- "-a iconsdir='#{iconsdir}'",
50
- "-a imagesdir='#{imagesdir}'",
51
- "#{confopt} -o - -" ].join( ' ' ),
52
- content)
53
- content.gsub( "\r", '' )
54
- end
55
- end
56
- end
57
- end
@@ -1,48 +0,0 @@
1
-
2
- require 'awestruct/handler_chain'
3
- require 'awestruct/handlers/base_handler'
4
- require 'awestruct/handlers/file_handler'
5
- require 'awestruct/handlers/front_matter_handler'
6
- require 'awestruct/handlers/interpolation_handler'
7
-
8
- require 'coffee-script'
9
-
10
- module Awestruct
11
- module Handlers
12
- class CoffeescriptHandler < BaseHandler
13
-
14
-
15
- CHAIN = Awestruct::HandlerChain.new( /\.coffee$/,
16
- Awestruct::Handlers::FileHandler,
17
- Awestruct::Handlers::FrontMatterHandler,
18
- Awestruct::Handlers::InterpolationHandler,
19
- Awestruct::Handlers::CoffeescriptHandler
20
- )
21
-
22
- def initialize(site, delegate)
23
- super( site, delegate )
24
- end
25
-
26
- def simple_name
27
- File.basename( relative_source_path, '.coffee' )
28
- end
29
-
30
- def output_filename
31
- File.basename( relative_source_path, '.coffee' ) + '.js'
32
- end
33
-
34
- def output_extension
35
- '.js'
36
- end
37
-
38
- def content_syntax
39
- :coffeescript
40
- end
41
-
42
- def rendered_content(context, with_layouts=true)
43
- CoffeeScript.compile( delegate.rendered_content( context, with_layouts ) )
44
- end
45
-
46
- end
47
- end
48
- end
@@ -1,44 +0,0 @@
1
-
2
- require 'awestruct/handlers/base_handler'
3
- require 'awestruct/handlers/file_handler'
4
- require 'awestruct/handlers/front_matter_handler'
5
- require 'awestruct/handlers/layout_handler'
6
-
7
- module Awestruct
8
- module Handlers
9
- class ErbHandler < BaseHandler
10
-
11
- CHAIN = Awestruct::HandlerChain.new( /\.erb$/,
12
- Awestruct::Handlers::FileHandler,
13
- Awestruct::Handlers::FrontMatterHandler,
14
- Awestruct::Handlers::ErbHandler,
15
- Awestruct::Handlers::LayoutHandler
16
- )
17
-
18
- def initialize(site, delegate)
19
- super( site, delegate )
20
- end
21
-
22
- def simple_name
23
- File.basename( File.basename( relative_source_path, '.erb' ), output_extension )
24
- end
25
-
26
- def output_filename
27
- File.basename( relative_source_path, '.erb' )
28
- end
29
-
30
- def output_extension
31
- File.extname( output_filename )
32
- end
33
-
34
- def content_syntax
35
- :erb
36
- end
37
-
38
- def rendered_content(context, with_layouts=true)
39
- erb = ERB.new( delegate.rendered_content( context, with_layouts) )
40
- erb.result( context.send( :binding ) )
41
- end
42
- end
43
- end
44
- end
@@ -1,48 +0,0 @@
1
-
2
- require 'awestruct/handler_chain'
3
- require 'awestruct/handlers/base_handler'
4
- require 'awestruct/handlers/file_handler'
5
- require 'awestruct/handlers/front_matter_handler'
6
- require 'awestruct/handlers/interpolation_handler'
7
- require 'awestruct/handlers/layout_handler'
8
- require 'org-ruby'
9
-
10
- module Awestruct
11
- module Handlers
12
- class OrgmodeHandler < BaseHandler
13
-
14
- CHAIN = Awestruct::HandlerChain.new( /\.org$/,
15
- Awestruct::Handlers::FileHandler,
16
- Awestruct::Handlers::FrontMatterHandler,
17
- Awestruct::Handlers::InterpolationHandler,
18
- Awestruct::Handlers::OrgmodeHandler,
19
- Awestruct::Handlers::LayoutHandler
20
- )
21
-
22
- def initialize(site, delegate)
23
- super( site, delegate )
24
- end
25
-
26
- def simple_name
27
- File.basename( relative_source_path, '.org' )
28
- end
29
-
30
- def output_filename
31
- File.basename( relative_source_path, '.org' ) + '.html'
32
- end
33
-
34
- def output_extension
35
- '.html'
36
- end
37
-
38
- def content_syntax
39
- :orgmode
40
- end
41
-
42
- def rendered_content(context, with_layouts=true)
43
- Orgmode::Parser.new(super( context, with_layouts) ).to_html
44
- end
45
-
46
- end
47
- end
48
- end