awestruct 0.4.8 → 0.5.0.cr
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awestruct/astruct.rb +4 -0
- data/lib/awestruct/astruct_mixin.rb +3 -0
- data/lib/awestruct/cli/auto.rb +6 -6
- data/lib/awestruct/cli/deploy.rb +3 -3
- data/lib/awestruct/cli/generate.rb +5 -3
- data/lib/awestruct/cli/init.rb +1 -1
- data/lib/awestruct/cli/invoker.rb +10 -3
- data/lib/awestruct/cli/manifest.rb +18 -17
- data/lib/awestruct/cli/options.rb +7 -6
- data/lib/awestruct/cli/server.rb +7 -14
- data/lib/awestruct/config.rb +7 -1
- data/lib/awestruct/config/default-site.yml +30 -0
- data/lib/awestruct/context_helper.rb +7 -7
- data/lib/awestruct/dependencies.rb +14 -11
- data/lib/awestruct/deploy/base_deploy.rb +2 -2
- data/lib/awestruct/deploy/github_pages_deploy.rb +1 -1
- data/lib/awestruct/deploy/rsync_deploy.rb +11 -15
- data/lib/awestruct/deploy/s3_deploy.rb +9 -0
- data/lib/awestruct/engine.rb +72 -21
- data/lib/awestruct/extensions/minify.rb +21 -20
- data/lib/awestruct/extensions/paginator.rb +5 -5
- data/lib/awestruct/extensions/partial.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +5 -1
- data/lib/awestruct/extensions/posts.rb +8 -4
- data/lib/awestruct/extensions/relative.rb +7 -2
- data/lib/awestruct/extensions/remotePartial.rb +1 -1
- data/lib/awestruct/extensions/sitemap.rb +1 -1
- data/lib/awestruct/frameworks/bootstrap/base_index.html.haml +1 -1
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +1 -1
- data/lib/awestruct/handler_chains.rb +8 -23
- data/lib/awestruct/handlers/asciidoctor_handler.rb +114 -0
- data/lib/awestruct/handlers/base_tilt_handler.rb +114 -0
- data/lib/awestruct/handlers/css_tilt_handler.rb +43 -0
- data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
- data/lib/awestruct/handlers/interpolation_handler.rb +3 -3
- data/lib/awestruct/handlers/layout_handler.rb +6 -4
- data/lib/awestruct/handlers/restructuredtext_handler.rb +5 -5
- data/lib/awestruct/handlers/template/asciidoc.rb +41 -0
- data/lib/awestruct/handlers/template/mustache.rb +25 -0
- data/lib/awestruct/handlers/tilt_handler.rb +73 -0
- data/lib/awestruct/layouts.rb +1 -1
- data/lib/awestruct/logger.rb +59 -0
- data/lib/awestruct/page.rb +16 -3
- data/lib/awestruct/page_loader.rb +5 -5
- data/lib/awestruct/version.rb +1 -1
- data/man/awestruct.1 +163 -0
- data/spec/asciidoc_handler_spec.rb +75 -0
- data/spec/astruct_spec.rb +52 -0
- data/spec/coffeescript_handler_spec.rb +23 -0
- data/spec/config_spec.rb +22 -0
- data/spec/context_helper_spec.rb +115 -0
- data/spec/deploy_spec.rb +41 -0
- data/spec/disqus_spec.rb +43 -0
- data/spec/engine_spec.rb +115 -0
- data/spec/erb_handler_spec.rb +52 -0
- data/spec/file_handler_spec.rb +57 -0
- data/spec/front_matter_handler_spec.rb +42 -0
- data/spec/github_pages_deploy_spec.rb +56 -0
- data/spec/haml_handler_spec.rb +93 -0
- data/spec/handler_chain_spec.rb +44 -0
- data/spec/handler_chains_spec.rb +25 -0
- data/spec/interpolation_handler_spec.rb +35 -0
- data/spec/invoker_spec.rb +74 -0
- data/spec/javascript_handler_spec.rb +23 -0
- data/spec/layout_handler_spec.rb +77 -0
- data/spec/layouts_spec.rb +32 -0
- data/spec/less_handler_spec.rb +33 -0
- data/spec/markdown_handler_spec.rb +41 -0
- data/spec/minify_spec.rb +61 -0
- data/spec/mustache_handler_spec.rb +29 -0
- data/spec/options_spec.rb +97 -0
- data/spec/orgmode_handler_spec.rb +24 -0
- data/spec/page_delegating_handler_spec.rb +79 -0
- data/spec/page_loader_spec.rb +43 -0
- data/spec/page_loader_spec_for_layouts.rb +36 -0
- data/spec/page_spec.rb +65 -0
- data/spec/pipeline_spec.rb +12 -0
- data/spec/posts_archive_spec.rb +108 -0
- data/spec/redirect_handler_spec.rb +32 -0
- data/spec/restructuredtext_handler_spec.rb +22 -0
- data/spec/rsync_deploy_spec.rb +9 -0
- data/spec/sass_handler_spec.rb +23 -0
- data/spec/scss_handler_spec.rb +23 -0
- data/spec/server_spec.rb +45 -0
- data/spec/slim_handler_spec.rb +81 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/nokogiri_matchers.rb +21 -0
- data/spec/support/shared_handler_example.rb +98 -0
- data/spec/test-data/engine/_config/arbitrary.yml +2 -0
- data/spec/test-data/engine/_config/other.yml +1 -0
- data/spec/test-data/engine/_config/site.yml +14 -0
- data/spec/test-data/front-matter-file-no-content.txt +2 -0
- data/spec/test-data/front-matter-file-no-front.txt +1 -0
- data/spec/test-data/front-matter-file.txt +4 -0
- data/spec/test-data/handlers/asciidoc-page.ad +3 -0
- data/spec/test-data/handlers/asciidoc-page.adoc +3 -0
- data/spec/test-data/handlers/asciidoc-page.asciidoc +3 -0
- data/spec/test-data/handlers/asciidoctor_with_front_matter.ad +6 -0
- data/spec/test-data/handlers/asciidoctor_with_headers.ad +8 -0
- data/spec/test-data/handlers/coffeescript-page.coffee +8 -0
- data/spec/test-data/handlers/erb-page.html.erb +6 -0
- data/spec/test-data/handlers/erb-page.xml.erb +2 -0
- data/spec/test-data/handlers/erb-utf-page.html.erb +2 -0
- data/spec/test-data/handlers/haml-layout-two.html.haml +7 -0
- data/spec/test-data/handlers/haml-layout.html.haml +4 -0
- data/spec/test-data/handlers/haml-page.atom.haml +4 -0
- data/spec/test-data/handlers/haml-page.html.haml +2 -0
- data/spec/test-data/handlers/haml-page.xml.haml +1 -0
- data/spec/test-data/handlers/haml-with-markdown-page.html.haml +6 -0
- data/spec/test-data/handlers/haml-with-textile-page.html.haml +6 -0
- data/spec/test-data/handlers/haml-with-utf.html.haml +2 -0
- data/spec/test-data/handlers/haml-with-variables.html.haml +2 -0
- data/spec/test-data/handlers/inner-page.html.haml +4 -0
- data/spec/test-data/handlers/javascript-page.js +1 -0
- data/spec/test-data/handlers/less-page-include.less +1 -0
- data/spec/test-data/handlers/less-page-with-import.less +4 -0
- data/spec/test-data/handlers/less-page.less +4 -0
- data/spec/test-data/handlers/markdown-page.markdown +2 -0
- data/spec/test-data/handlers/markdown-page.md +2 -0
- data/spec/test-data/handlers/markdown-page.mkd +2 -0
- data/spec/test-data/handlers/mustache-page.html.mustache +2 -0
- data/spec/test-data/handlers/mustache-page.xml.mustache +1 -0
- data/spec/test-data/handlers/orgmode-page.org +6 -0
- data/spec/test-data/handlers/outer-layout.html.haml +2 -0
- data/spec/test-data/handlers/outside_relative/git_keep +3 -0
- data/spec/test-data/handlers/redirect-page.redirect +1 -0
- data/spec/test-data/handlers/restructuredtext-page.rst +8 -0
- data/spec/test-data/handlers/sass-page-include.sass +1 -0
- data/spec/test-data/handlers/sass-page.sass +4 -0
- data/spec/test-data/handlers/scss-page-include.scss +1 -0
- data/spec/test-data/handlers/scss-page.scss +5 -0
- data/spec/test-data/handlers/simple-redirect-page.redirect +1 -0
- data/spec/test-data/handlers/slim-page.atom.slim +4 -0
- data/spec/test-data/handlers/slim-page.html.slim +1 -0
- data/spec/test-data/handlers/slim-page.xml.slim +1 -0
- data/spec/test-data/handlers/slim-with-markdown-page.html.slim +5 -0
- data/spec/test-data/handlers/slim-with-utf.html.slim +2 -0
- data/spec/test-data/handlers/slim-with-variables.html.slim +1 -0
- data/spec/test-data/handlers/textile-page.textile +1 -0
- data/spec/test-data/images/logo.png +0 -0
- data/spec/test-data/index.html +242 -0
- data/spec/test-data/javascript/bootstrap-dropdown.js +92 -0
- data/spec/test-data/out-of-site/page-three.html.haml +2 -0
- data/spec/test-data/page-loader/_layouts/layout-one.md +2 -0
- data/spec/test-data/page-loader/_layouts/layout-two.html.haml +2 -0
- data/spec/test-data/page-loader/page-draft.md +5 -0
- data/spec/test-data/page-loader/page-one.md +2 -0
- data/spec/test-data/page-loader/page-two.html.haml +2 -0
- data/spec/test-data/simple-data.yaml +1 -0
- data/spec/test-data/simple-file.txt +1 -0
- data/spec/test-data/stylesheets/screen.css +688 -0
- data/spec/textile_handler_spec.rb +22 -0
- data/spec/tilt_handler_spec.rb +81 -0
- data/spec/yaml_handler_spec.rb +21 -0
- metadata +243 -202
- data/lib/awestruct/handlers/asciidoc_handler.rb +0 -86
- data/lib/awestruct/handlers/base_sass_handler.rb +0 -42
- data/lib/awestruct/handlers/coffeescript_handler.rb +0 -48
- data/lib/awestruct/handlers/erb_handler.rb +0 -43
- data/lib/awestruct/handlers/haml_handler.rb +0 -54
- data/lib/awestruct/handlers/less_handler.rb +0 -37
- data/lib/awestruct/handlers/markdown_handler.rb +0 -50
- data/lib/awestruct/handlers/mustache_handler.rb +0 -44
- data/lib/awestruct/handlers/orgmode_handler.rb +0 -48
- data/lib/awestruct/handlers/sass_handler.rb +0 -21
- data/lib/awestruct/handlers/scss_handler.rb +0 -21
- data/lib/awestruct/handlers/textile_handler.rb +0 -58
data/lib/awestruct/astruct.rb
CHANGED
data/lib/awestruct/cli/auto.rb
CHANGED
@@ -26,7 +26,7 @@ module Awestruct
|
|
26
26
|
begin
|
27
27
|
if path.eql? current_path
|
28
28
|
unless generate_thread.nil?
|
29
|
-
|
29
|
+
$LOG.info "Same path triggered, stopping previous generation" if generate_thread.alive? && $LOG.info?
|
30
30
|
generate_thread.kill
|
31
31
|
end
|
32
32
|
else
|
@@ -37,15 +37,15 @@ module Awestruct
|
|
37
37
|
generate_thread = Thread.new {
|
38
38
|
begin
|
39
39
|
engine.generate_page_by_output_path( path )
|
40
|
-
|
40
|
+
$LOG.info "Generating.... done!" if $LOG.info?
|
41
41
|
rescue => e
|
42
|
-
|
43
|
-
|
42
|
+
$LOG.error e if $LOG.error?
|
43
|
+
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
44
44
|
end
|
45
45
|
}
|
46
46
|
rescue => e
|
47
|
-
|
48
|
-
|
47
|
+
$LOG.error e if $LOG.error?
|
48
|
+
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/awestruct/cli/deploy.rb
CHANGED
@@ -14,7 +14,7 @@ module Awestruct
|
|
14
14
|
@site_config = site_config
|
15
15
|
@deploy_config = deploy_config
|
16
16
|
@deploy_config['type'] ||= (is_github? ? :github_pages : :rsync)
|
17
|
-
|
17
|
+
$LOG.info "Deploying to #{deploy_type}" if $LOG.info?
|
18
18
|
end
|
19
19
|
|
20
20
|
def deploy_type
|
@@ -25,8 +25,8 @@ module Awestruct
|
|
25
25
|
deployer_class = Awestruct::Deployers.instance[ deploy_type.to_sym ]
|
26
26
|
|
27
27
|
if ( deployer_class.nil? )
|
28
|
-
$
|
29
|
-
$
|
28
|
+
$LOG.error "Unable to locate correct deployer for #{deploy_type}" if $LOG.error?
|
29
|
+
$LOG.error "Deployers available for #{::Awestruct::Deployers.instance.collect {|k,v| "#{v} (#{k})"}.join(', ')}" if $LOG.error?
|
30
30
|
return
|
31
31
|
end
|
32
32
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'awestruct/engine'
|
2
|
+
require 'compass'
|
3
|
+
require 'ninesixty'
|
2
4
|
|
3
5
|
module Awestruct
|
4
6
|
module CLI
|
@@ -15,11 +17,11 @@ module Awestruct
|
|
15
17
|
def run()
|
16
18
|
begin
|
17
19
|
base_url = @profile['base_url'] || @default_base_url
|
18
|
-
|
20
|
+
$LOG.info "Generating site: #{base_url}" if $LOG.info?
|
19
21
|
@engine.run( @profile, @base_url, ( @profile ? @profile['base_url'] || @default_base_url : @default_base_url ), @force )
|
20
22
|
rescue =>e
|
21
|
-
|
22
|
-
|
23
|
+
$LOG.error e if $LOG.error?
|
24
|
+
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
23
25
|
return false
|
24
26
|
end
|
25
27
|
end
|
data/lib/awestruct/cli/init.rb
CHANGED
@@ -27,7 +27,7 @@ module Awestruct
|
|
27
27
|
if ( @scaffold )
|
28
28
|
manifest.copy_file( '_layouts/base.html.haml',
|
29
29
|
File.join( File.dirname(__FILE__), "/../frameworks/#{scaffold_name}/base_layout.html.haml" ) )
|
30
|
-
if ( File.file? File.join( File.dirname(__FILE__), "
|
30
|
+
if ( File.file? File.join( File.dirname(__FILE__), "/../frameworks/#{scaffold_name}/base_index.html.haml" ) )
|
31
31
|
manifest.copy_file( 'index.html.haml',
|
32
32
|
File.join( File.dirname(__FILE__), "/../frameworks/#{scaffold_name}/base_index.html.haml" ) )
|
33
33
|
else
|
@@ -5,8 +5,10 @@ require 'awestruct/cli/generate'
|
|
5
5
|
require 'awestruct/cli/auto'
|
6
6
|
require 'awestruct/cli/server'
|
7
7
|
require 'awestruct/cli/deploy'
|
8
|
+
require 'awestruct/logger'
|
8
9
|
|
9
10
|
require 'pathname'
|
11
|
+
require 'logger'
|
10
12
|
|
11
13
|
module Awestruct
|
12
14
|
module CLI
|
@@ -28,6 +30,11 @@ module Awestruct
|
|
28
30
|
@threads = []
|
29
31
|
@profile = nil
|
30
32
|
@success = true
|
33
|
+
logging_path = Pathname.new '.awestruct'
|
34
|
+
logging_path.mkdir unless logging_path.exist?
|
35
|
+
$LOG = Logger.new(Awestruct::AwestructLoggerMultiIO.new(@options.verbose, STDOUT, File.open('.awestruct/debug.log', 'w')))
|
36
|
+
$LOG.level = @options.verbose ? Logger::DEBUG : Logger::INFO
|
37
|
+
$LOG.formatter = Awestruct::AwestructLogFormatter.new
|
31
38
|
end
|
32
39
|
|
33
40
|
def invoke!
|
@@ -68,11 +75,11 @@ module Awestruct
|
|
68
75
|
end
|
69
76
|
|
70
77
|
unless @profile
|
71
|
-
$
|
78
|
+
$LOG.error "Unable to locate profile: #{options.profile}" if options.profile && $LOG.error?
|
72
79
|
options.profile = 'NONE'
|
73
80
|
@profile = {}
|
74
81
|
end
|
75
|
-
$
|
82
|
+
$LOG.info "Using profile: #{options.profile}" if $LOG.info?
|
76
83
|
end
|
77
84
|
|
78
85
|
def setup_config()
|
@@ -101,7 +108,7 @@ module Awestruct
|
|
101
108
|
deploy_config = profile[ 'deploy' ]
|
102
109
|
|
103
110
|
if ( deploy_config.nil? )
|
104
|
-
$
|
111
|
+
$LOG.error "No configuration for 'deploy'" if $LOG.error?
|
105
112
|
return
|
106
113
|
end
|
107
114
|
|
@@ -16,7 +16,7 @@ class Compass::AppIntegration::StandAlone::Installer
|
|
16
16
|
# no!
|
17
17
|
end
|
18
18
|
def finalize(opts={})
|
19
|
-
|
19
|
+
$LOG.info <<-END.gsub(/^ {6}/, '')
|
20
20
|
|
21
21
|
Now you're awestruct!
|
22
22
|
|
@@ -67,8 +67,8 @@ module Awestruct
|
|
67
67
|
begin
|
68
68
|
step.perform( dir )
|
69
69
|
rescue => e
|
70
|
-
|
71
|
-
|
70
|
+
$LOG.error e if $LOG.error?
|
71
|
+
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -78,8 +78,8 @@ module Awestruct
|
|
78
78
|
begin
|
79
79
|
step.unperform( dir )
|
80
80
|
rescue => e
|
81
|
-
|
82
|
-
|
81
|
+
$LOG.error e if $LOG.error?
|
82
|
+
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -97,32 +97,32 @@ module Awestruct
|
|
97
97
|
def perform(dir)
|
98
98
|
p = File.join( dir, @path )
|
99
99
|
if ( File.exist?( p ) )
|
100
|
-
$
|
100
|
+
$LOG.error "Exists: #{p}" if $LOG.error?
|
101
101
|
return
|
102
102
|
end
|
103
103
|
if ( ! File.directory?( File.dirname( p ) ) )
|
104
|
-
$
|
104
|
+
$LOG.error "Does not exist: #{File.dirname(p)}" if $LOG.error?
|
105
105
|
return
|
106
106
|
end
|
107
|
-
$
|
107
|
+
$LOG.info "Create directory: #{p}" if $LOG.info?
|
108
108
|
FileUtils.mkdir( p )
|
109
109
|
end
|
110
110
|
|
111
111
|
def unperform(dir)
|
112
112
|
p = File.join( dir, @path )
|
113
113
|
if ( ! File.exist?( p ) )
|
114
|
-
$
|
114
|
+
$LOG.error "Does not exist: #{p}" if $LOG.error?
|
115
115
|
return
|
116
116
|
end
|
117
117
|
if ( ! File.directory?( p ) )
|
118
|
-
$
|
118
|
+
$LOG.error "Not a directory: #{p}" if $LOG.error?
|
119
119
|
return
|
120
120
|
end
|
121
121
|
if ( Dir.entries( p ) != 2 )
|
122
|
-
$
|
122
|
+
$LOG.error "Not empty: #{p}" if $LOG.error?
|
123
123
|
return
|
124
124
|
end
|
125
|
-
$
|
125
|
+
$LOG.info "Remove: #{p}" if $LOG.info?
|
126
126
|
FileUtils.rmdir( p )
|
127
127
|
end
|
128
128
|
end
|
@@ -150,14 +150,14 @@ module Awestruct
|
|
150
150
|
def perform(dir )
|
151
151
|
p = File.join( dir, @path )
|
152
152
|
if ( File.exist?( p ) )
|
153
|
-
$
|
153
|
+
$LOG.error "Exists: #{p}" if $LOG.error?
|
154
154
|
return
|
155
155
|
end
|
156
156
|
if ( ! File.directory?( File.dirname( p ) ) )
|
157
|
-
$
|
157
|
+
$LOG.error "No directory: #{File.dirname( p )}" if $LOG.error?
|
158
158
|
return
|
159
159
|
end
|
160
|
-
$
|
160
|
+
$LOG.info "Create file: #{p}" if $LOG.info?
|
161
161
|
File.open( p, 'w' ){|f| f.write( File.read( @input_path ) ) }
|
162
162
|
end
|
163
163
|
|
@@ -168,10 +168,10 @@ module Awestruct
|
|
168
168
|
def notunperform(dir)
|
169
169
|
p = File.join( @dir, p )
|
170
170
|
if ( ! File.exist?( p ) )
|
171
|
-
$
|
171
|
+
$LOG.error "Does not exist: #{p}" if $LOG.error?
|
172
172
|
return
|
173
173
|
end
|
174
|
-
$
|
174
|
+
$LOG.info "Remove: #{p}" if $LOG.info?
|
175
175
|
FileUtils.rm( p )
|
176
176
|
end
|
177
177
|
|
@@ -193,6 +193,7 @@ module Awestruct
|
|
193
193
|
:css_dir=>'_site/stylesheets',
|
194
194
|
:sass_dir=>'stylesheets',
|
195
195
|
:images_dir=>'images',
|
196
|
+
:fonts_dir=>'fonts',
|
196
197
|
:javascripts_dir=>'javascripts',
|
197
198
|
} )
|
198
199
|
cmd.perform
|
@@ -36,6 +36,7 @@ module Awestruct
|
|
36
36
|
@profile = nil
|
37
37
|
@deploy = false
|
38
38
|
@script = nil
|
39
|
+
@verbose = false
|
39
40
|
end
|
40
41
|
|
41
42
|
def self.parse!(args)
|
@@ -66,14 +67,14 @@ module Awestruct
|
|
66
67
|
opts.on( '-u', '--url URL', 'Set site.base_url' ) do |url|
|
67
68
|
self.base_url = url
|
68
69
|
end
|
69
|
-
opts.on( '-d', '--dev', 'Run in development mode (--auto, --server and
|
70
|
+
opts.on( '-d', '--dev', 'Run site in development mode (--auto, --server, --port 4242 and --profile development)' ) do |url|
|
70
71
|
self.server = true
|
71
72
|
self.auto = true
|
72
73
|
self.port = 4242
|
73
74
|
self.profile = 'development'
|
74
75
|
end
|
75
76
|
|
76
|
-
opts.on( '-P', '--profile PROFILE', '
|
77
|
+
opts.on( '-P', '--profile PROFILE', 'Activate a configuration profile' ) do |profile|
|
77
78
|
self.profile = profile
|
78
79
|
end
|
79
80
|
|
@@ -91,12 +92,12 @@ module Awestruct
|
|
91
92
|
opts.on( '-b', '--bind ADDR', 'Server address (default: 0.0.0.0)' ) do |bind_addr|
|
92
93
|
self.bind_addr = bind_addr
|
93
94
|
end
|
94
|
-
opts.on( '-g', '--[no-]generate', '
|
95
|
+
opts.on( '-g', '--[no-]generate', 'Generate site' ) do |g|
|
95
96
|
self.generate = g
|
96
97
|
end
|
97
|
-
opts.on( '--run SCRIPT', '
|
98
|
-
|
99
|
-
end
|
98
|
+
#opts.on( '--run SCRIPT', 'Invoke a script after initialization' ) do |script|
|
99
|
+
# self.script = script
|
100
|
+
#end
|
100
101
|
|
101
102
|
opts.separator ''
|
102
103
|
opts.separator "Common options:"
|
data/lib/awestruct/cli/server.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
require 'rack'
|
2
|
+
require 'rack/server'
|
3
3
|
require 'awestruct/rack/app'
|
4
4
|
|
5
5
|
module Awestruct
|
6
6
|
module CLI
|
7
|
-
|
8
|
-
#WEBrick::HTTPUtils::DefaultMimeTypes.store('atom', 'application/atom+xml')
|
9
|
-
#WEBrick::HTTPUtils::DefaultMimeTypes.store('appcache', 'text/cache-manifest')
|
10
|
-
|
11
7
|
class Server
|
12
8
|
attr_reader :server
|
13
9
|
|
@@ -18,14 +14,11 @@ module Awestruct
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def run
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@server = WEBrick::HTTPServer.new( :DocumentRoot=>@path, :Port=>@port, :BindAddress=>@bind_addr )
|
27
|
-
@server.start
|
28
|
-
end
|
17
|
+
::Rack::Server::start( :app => Awestruct::Rack::App.new( @path ),
|
18
|
+
:Port => @port,
|
19
|
+
:Host => @bind_addr
|
20
|
+
)
|
21
|
+
end
|
29
22
|
end
|
30
23
|
end
|
31
24
|
end
|
data/lib/awestruct/config.rb
CHANGED
@@ -32,7 +32,13 @@ module Awestruct
|
|
32
32
|
@images_dir = Pathname.new( File.join(dir, 'images') )
|
33
33
|
@stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )
|
34
34
|
|
35
|
-
|
35
|
+
# Dir[] doesn't like empty list
|
36
|
+
ignore_file = File.join(dir, ".awestruct_ignore")
|
37
|
+
if File.exists?(ignore_file)
|
38
|
+
ignore_stmts = IO.read(ignore_file).each_line.map(&:strip)
|
39
|
+
end
|
40
|
+
|
41
|
+
@ignore = (!ignore_stmts.nil? and ignore_stmts.size > 0) ? Dir[*ignore_stmts] : []
|
36
42
|
|
37
43
|
@track_dependencies = false
|
38
44
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
content_syntax:
|
2
|
+
coffee: coffeescript
|
3
|
+
md: markdown
|
4
|
+
mkd: markdown
|
5
|
+
org: orgmod
|
6
|
+
adoc: asciidoc
|
7
|
+
ad: asciidoc
|
8
|
+
|
9
|
+
haml:
|
10
|
+
:attr_wrapper: '"'
|
11
|
+
:escape_attrs: :once
|
12
|
+
:format: :xhtml
|
13
|
+
|
14
|
+
haml|html:
|
15
|
+
:format: :html5
|
16
|
+
|
17
|
+
slim:
|
18
|
+
:sort_attrs: false
|
19
|
+
:disable_escape: true
|
20
|
+
:format: :xhtml
|
21
|
+
|
22
|
+
slim|html:
|
23
|
+
:format: :html5
|
24
|
+
|
25
|
+
asciidoctor:
|
26
|
+
:backend: html5
|
27
|
+
:safe: 1
|
28
|
+
:attributes:
|
29
|
+
imagesdir: /images
|
30
|
+
stylesdir: /stylesheets
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'nokogiri'
|
2
2
|
|
3
3
|
module Awestruct
|
4
4
|
module ContextHelper
|
@@ -38,24 +38,24 @@ module Awestruct
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def fully_qualify_urls(base_url, text)
|
41
|
-
doc =
|
41
|
+
doc = Nokogiri::HTML.fragment( text )
|
42
42
|
|
43
|
-
doc.
|
43
|
+
doc.css( "a" ).each do |a|
|
44
44
|
a['href'] = fix_url( base_url, a['href'] ) if a['href']
|
45
45
|
end
|
46
|
-
doc.
|
46
|
+
doc.css( "link" ).each do |link|
|
47
47
|
link['href'] = fix_url( base_url, link['href'] )
|
48
48
|
end
|
49
|
-
doc.
|
49
|
+
doc.css( "img" ).each do |img|
|
50
50
|
img['src'] = fix_url( base_url, img['src'] )
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
if RUBY_VERSION.start_with? '1.8'
|
54
54
|
doc.to_s
|
55
55
|
else
|
56
56
|
doc.to_s.tap do |d|
|
57
57
|
d.force_encoding(text.encoding) if d.encoding != text.encoding
|
58
|
-
end
|
58
|
+
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -27,10 +27,12 @@ module Awestruct
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.push_page(page)
|
30
|
-
|
30
|
+
$LOG.debug "push #{page.output_path}" if $LOG.debug?
|
31
31
|
if ( top_page.nil? )
|
32
|
+
$LOG.debug "clearing dependencies" if $LOG.debug?
|
32
33
|
page.dependencies.clear
|
33
34
|
else
|
35
|
+
$LOG.debug "adding page as a dependency to top_page" if $LOG.debug?
|
34
36
|
top_page.dependencies.add_dependency( page )
|
35
37
|
end
|
36
38
|
@pages.push( page )
|
@@ -38,7 +40,7 @@ module Awestruct
|
|
38
40
|
|
39
41
|
def self.pop_page
|
40
42
|
page = @pages.pop
|
41
|
-
|
43
|
+
$LOG.debug "pop #{page.output_path} #{@pages.empty?}" if $LOG.debug?
|
42
44
|
if ( @pages.empty? && ! page.nil? )
|
43
45
|
page.dependencies.persist!
|
44
46
|
end
|
@@ -48,7 +50,7 @@ module Awestruct
|
|
48
50
|
def self.track_dependency(dep)
|
49
51
|
return if top_page.nil?
|
50
52
|
return if top_page == dep
|
51
|
-
|
53
|
+
$LOG.debug "dep #{top_page.relative_source_path} - #{dep.relative_source_path}" if $LOG.debug?
|
52
54
|
top_page.dependencies.add_dependency(dep)
|
53
55
|
end
|
54
56
|
|
@@ -56,8 +58,8 @@ module Awestruct
|
|
56
58
|
return if !Awestruct::Dependencies.should_track_dependencies
|
57
59
|
return if top_page.nil?
|
58
60
|
return if top_page == dep
|
59
|
-
|
60
|
-
#
|
61
|
+
$LOG.debug "dep key #{top_page.relative_source_path} - #{dep.relative_source_path} -> #{key}" if $LOG.debug?
|
62
|
+
$LOG.debug "callers #{Kernel.caller}" if $LOG.debug?
|
61
63
|
top_page.dependencies.add_key_dependency(dep)
|
62
64
|
end
|
63
65
|
|
@@ -75,7 +77,7 @@ module Awestruct
|
|
75
77
|
end
|
76
78
|
|
77
79
|
def key_hash=(key)
|
78
|
-
|
80
|
+
$LOG.debug "key_hash #{key}" if $LOG.debug?
|
79
81
|
if @key_hash.nil?
|
80
82
|
@has_changed_keys = false
|
81
83
|
else
|
@@ -89,7 +91,7 @@ module Awestruct
|
|
89
91
|
end
|
90
92
|
|
91
93
|
def content_hash=(key)
|
92
|
-
|
94
|
+
$LOG.debug "content_hash #{key}" if $LOG.debug?
|
93
95
|
if @content_hash.nil?
|
94
96
|
@has_changed_content = false
|
95
97
|
else
|
@@ -110,6 +112,7 @@ module Awestruct
|
|
110
112
|
return if @page.do_not_track_dependencies
|
111
113
|
return if @page.output_path.nil?
|
112
114
|
return if dep == @page
|
115
|
+
$LOG.debug "adding dependency #{dep.source_path} to #{page.source_path}" if $LOG.debug?
|
113
116
|
@dependencies << dep
|
114
117
|
dep.dependencies.add_dependent( page )
|
115
118
|
end
|
@@ -141,8 +144,8 @@ module Awestruct
|
|
141
144
|
|
142
145
|
def persist!
|
143
146
|
return if page.output_path.nil? || page.output_path == ''
|
144
|
-
file = File.join( @page.site.config.dir, '.awestruct', 'dependency-cache', page.output_path )
|
145
|
-
|
147
|
+
file = File.join( @page.site.config.dir.to_s, '.awestruct', 'dependency-cache', page.output_path )
|
148
|
+
$LOG.debug "store #{file}" if $LOG.debug?
|
146
149
|
FileUtils.mkdir_p( File.dirname( file ) )
|
147
150
|
File.open( file, 'w' ) do |file|
|
148
151
|
file.puts "ch:#{@content_hash}"
|
@@ -159,10 +162,10 @@ module Awestruct
|
|
159
162
|
def load!
|
160
163
|
return if page.output_path.nil? || page.output_path == ''
|
161
164
|
file = File.join( @page.site.config.dir, '.awestruct', 'dependency-cache', page.output_path )
|
162
|
-
|
165
|
+
$LOG.debug "load #{file}" if $LOG.debug?
|
163
166
|
if ( File.exist?( file ) )
|
164
167
|
File.open( file, 'r' ) do |file|
|
165
|
-
file.
|
168
|
+
file.each_line do |line|
|
166
169
|
type, path = line.split(':')
|
167
170
|
path ||= ""
|
168
171
|
path.strip!
|